Graphic Overload

TristanZ
06-18-2006, 10:03 AM
I'm making a space shooter similar to space invaders.

I created a 'bullet' class so that there was no limit to the amount of times you could shoot. Every time you click, it draws a new bullet w/out effecting the other ones. However, after a number of bullets, say 100+, the game begins to get jerky in its motions, even after all the bullets have gone offscreen. How can I remedy this?

MikeJ
06-18-2006, 10:28 AM
Are you disposing of the bullet objects after they have cleared the screen?

TristanZ
06-18-2006, 10:56 AM
No. How would I go about doing that?

I don't think I can. I'm actually just drawing on the form using this code:

If firing = True And where.Y > 0 Then
Form2.CreateGraphics.DrawImage(bullet, where)
where.Y = where.Y - 10
End If

firing is the boolean assigned to the click event
where is the PointF location of the bullet

EDIT: I have tried this code:

Public bullet As Bitmap

Public Sub movement_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles movement.Tick
If firing = True And where.Y > 100 Then

Form2.CreateGraphics.DrawImage(bullet, where)
where.Y = where.Y - 10
If where.Y < 100 Then
bullet.Dispose()
Form2.CreateGraphics.Dispose()

End If

End If

Unfortunately, that doesn't work. Am I doing it wrong?

TristanZ
06-21-2006, 08:14 AM
Thanks! It works! I just had to dispose of all the objects related to the bullet, and I had forgotten the timer!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum