vb.net more performance for moving objects
Posted
by René
on Stack Overflow
See other posts from Stack Overflow
or by René
Published on 2010-05-31T20:10:15Z
Indexed on
2010/05/31
20:13 UTC
Read the original article
Hit count: 177
vb.net
I have the mission to make a small game for a school project. Pictures boxes, moved by a timer for walking enemies.If there are around 5 or 6 moving picture boxes at the form, my application get troubles and lags. After I kill some enemies (remove them from the Controls Collection of the Form/Panel) It come back smooth.
I think the loop of the enemy movement is too complicated but I don't know how to make that simpler.
Private Sub TimerEnemyMovement_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerEnemyMovement.Tick
For Each Enemy As Control In PanelBackground.Controls
If Enemy.Name.Substring(0, 5) = "Enemy" Then
_enemy.MoveEnemy(Enemy, 2)
End If
Next
End Sub
I also thought about Multithreading but not sure this would solve the problem and there is also the problem that I can't access the Controls of my mainform.
You see, I don't have much knowledge about vb.net
Any ideas how to fix that lag?
© Stack Overflow or respective owner