Running into a tinny issue with my "laser bullet" not wrking correctly. I can get it to appear on screen but it does not move. i went with settign it up as a class because I figured it would be easier to manage as well and add on to it if needed. This is to prevent a form with a crap ton of code in it. So I like to use classes to keep the main form code trimmed. Anyway here is the current code:
Public Class Bullet
Dim image As Image = My.Resources.Laser1
Dim bmp As New Bitmap(Image)
Dim rc As Rectangle
'Dim objGraphic As Graphics = Graphics.FromImage(image)
Sub New(ByVal shipx As Integer, ByVal shipy As Integer)
rc = New Rectangle(shipx, shipy + 5, image.Width, image.Height)
End Sub
Public Sub draw(ByRef objGraphic As Graphics)
objGraphic.DrawImage(bmp, rc, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel)
End Sub
Public Sub IncreaseY(ByVal increaseBy As Integer)
rc.Y += increaseBy
End Sub
End Class
Snippets from main form:
'bullets
Dim bullets(-1) As Object
Private Sub FireBullet()
ReDim Preserve bullets(bullets.Length)
bullets(bullets.Length - 1) = New Bullet(pb_Ship.Location.X, pb_Ship.Location.Y)
End Sub
Private Sub DrawTimer_Tick() Handles DrawTimer.Tick
For Each projectile In bullets
projectile.IncreaseY(10)
projectile.draw(Me.CreateGraphics)
Next
End Sub
I broke up the code a bit so I hope this makes sense.