Graphic Overload

06-18-2006, 09: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?

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

06-18-2006, 09: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

End If

End If

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

06-21-2006, 07: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