AnthraxXx
New Member
- Reaction score
- 25
So basically I'm creating a 2D jet fighter game for my IPT class, and I was wondering how I would go about firing more than 1 bullet on-screen at a time.
I had a system which could fire a bullet, but if I fired again it would just get the bullet I just fired and re-fire it, meaning only 1 bullet could be on-screen at a time.
My group partner and I have thought about it, and have narrowed it down to two possible methods:
1. Bullet Recycling
2. Using a Bullet Class
Bullet Recycling would consist of having multiple arrays, and as a bullet is fired, it is put into an "in" array, as it leaves the game area it is now "out", all bullets in the "out" array are ready to be re-fired. An analogy could be having a real-life gun whose bullets are put into it's magazine after being shot (theoretically), meaning it would never run out of ammunition.
Second is the bullet class, however we have no idea where to begin. Surely you would 'create' the bullet after each shot is fired, and then it would have to move. Does this mean we have to create a timer for EVERY shot fired. Or is it possible to use a single timer for all bullets on-screen by putting them into an array. How would you 'destroy' a bullet after it reaches the game bounds, to avoid bloating the game.
So confusing.
Here's random snippets of what we have/had:
Half of it doesn't make sense because I didn't write it, but have a look anyway.
I'm not asking for answers I just need a push in the right direction.
I had a system which could fire a bullet, but if I fired again it would just get the bullet I just fired and re-fire it, meaning only 1 bullet could be on-screen at a time.
My group partner and I have thought about it, and have narrowed it down to two possible methods:
1. Bullet Recycling
2. Using a Bullet Class
Bullet Recycling would consist of having multiple arrays, and as a bullet is fired, it is put into an "in" array, as it leaves the game area it is now "out", all bullets in the "out" array are ready to be re-fired. An analogy could be having a real-life gun whose bullets are put into it's magazine after being shot (theoretically), meaning it would never run out of ammunition.
Second is the bullet class, however we have no idea where to begin. Surely you would 'create' the bullet after each shot is fired, and then it would have to move. Does this mean we have to create a timer for EVERY shot fired. Or is it possible to use a single timer for all bullets on-screen by putting them into an array. How would you 'destroy' a bullet after it reaches the game bounds, to avoid bloating the game.
So confusing.
Here's random snippets of what we have/had:
Code:
'If InCount > 0 Then
' For p = 0 To InCount
' If Collision(bulletX(p), enemytest) Then
' bulletismoving(bulletsOut(0)) = False
' bulletX(p).Visible = False
' bulletismoving(p) = False
' CentreOn(enemytest, picExplosion)
' picExplosion.Visible = True
' enemytest.Visible = False
' tmrExplosion.Start()
' End If
' Next
' For i = 0 To InCount
' Dim bulletPos(i) As Point
' If bulletismoving(i) = True Then
' bulletX(i).Show()
' bulletPos(i) = New Point(0, -5)
' bulletX(i).Location += bulletPos(i)
' End If
' If bulletPos(i).Y >= boundary1.Y And bulletismoving(i) = False Then
' bulletX(i).Show()
' bulletX(i).Location += bulletPos(i)
' ElseIf bulletiscomputed(i) = False Then
' 'bulletX(i).Hide()
' bulletsOut(outcount) = i
' bulletiscomputed(i) = True
' bulletismoving(i) = False
' InCount -= 1
' outcount += 1
' For o = 0 To InCount
' If bulletsIn(o) = i Then
' For p = (o + 1) To InCount
' bulletsIn(p) = bulletsIn(p - 1)
' Next
' End If
' Next
' End If
' Next
'End If
'''''''''''''''''''
'Old Bullet System'
'''''''''''''''''''
If bulletPos.Y >= boundary1.Y Then
SingleBullet.Show()
bulletPos = New Point(0, -5)
SingleBullet.Location += bulletPos
Else
tmrBullet.Stop()
SingleBullet.Hide()
End If
Half of it doesn't make sense because I didn't write it, but have a look anyway.
I'm not asking for answers I just need a push in the right direction.