`first of all create the array to store all bullet data
dim bullet_dat(50,3)
`the 1 is the xval, the 2 is the yval and the 3 is the direction
`this means that bullet_dat(1,1) is the xposition of bullet nr 1
`bullet_dat(5,2) means the yposition of bullet nr 5
`bullet_dat(25,3) means the direction of bullet nr 25
`this variable is going to be used to check wich bullet is at turn.
currentbullet = 0
do
`only bulletcode here
`if the spacekey is pressed and the delay = 0 then shoot
`the delay var is used to stop shooting at incredible speed.
`if currentbullet < 50 (max bullets) the you cannot shoot anymore
`--> you need to reload.
if spacekey() = 1 and delay = 0 and currentbullet < 50
`delay
delay = 30
`increase the current bullet
inc currentbullet
`make the bullet data match the player data
bullet_dat(currentbullet,1) = playerx
bullet_dat(currentbullet,2) = playery
bullet_dat(currentbullet,3) = direction
`(direction: 1 = up, 2 = right, 3 = down and 4 = left)
endif
`handle bullets
for bullet = 1 to 50
`if the bullet is in the screen...
if bullet_dat(bullet,1) > 0 and bullet_dat(bullet,1) < screen width() and bullet_dat(bullet,2) > 0 and bullet_dat(bullet,2) < screen height()
`then check the direction the bullet is heading
`(check the arrays for the data)
`and move the bullets
select bullet_dat(bullet,3)
case 1 : bullet_dat(bullet,2) = bullet_dat(bullet,2) - 1 : endcase
case 2 : bullet_dat(bullet,1) = bullet_dat(bullet,1) + 1 : endcase
case 3 : bullet_dat(bullet,2) = bullet_dat(bullet,2) + 1 : endcase
case 4 : bullet_dat(bullet,1) = bullet_dat(bullet,1) - 1 : endcase
endselect
sprite bullet,bullet_dat(bullet,1),bullet_dat(bullet,2),b_image
else
`if the bullet is out of the screen then reset it's position
bullet_dat(bullet,1) = -5
bullet_dat(bullet,2) = -5
hide sprite bullet
endif
endif
`handle delay (if 0, you can shoot again)
if delay > 0 then dec delay
sync
loop
I added a couple of things than in the previous code.
I cannot guarantee that the code will work, since I didn't test it. If something isn't right, please tell me.
The code is fully commented
Immunity and Annihalation makes Immunihalation...