I'm trying to get SPRITE HIT to return a value of 1 if a bullet hits a sprite, and if possible, return the given number of said sprite to be returned as well. I'm using an array to handle the Bullets.
I've tried putting "Bullets" , "Bullets(b,2)" "b", and "b+11" where (SPRITE NUMBER) of the SPRITE HIT command is supposed to go, but it keeps telling me that "sprites does not exist".
Text 1600, 47, "SPRITE HIT: " +str$ (Sprite hit( "???" , 5))
Here is the code:
box 0,0,50,50
get image 2,0,0, 5,10 `bullet
get image 1,0,0,1,1,1
load image "sprites\player\player_ship.bmp", 3
load image "sprites\enemies\enemy_1.bmp",5
sprite 3,896,990,3 //Player
sprite 5, 500,500,5 //Enemy
`======Max bullet life
MaxLife = 200
MaxNumOfBullets=200
Dim Bullets(maxnumofbullets,2)
BulletWait = 200 : `Number of milliseconds between each bullet
`======
`====== vars
X = 320
Y = 240
Ang=0
Velocity# = 0.0
`============
repeat
goSub Bullets
GoSub Feedback
sync
Bullets:
rem Loop through each bullet "slot"
for b = 1 to MaxNumOfBullets
rem Fire Sprite
if controlkey()=1 and Bullets(b,1)=0 and (timer()-LastCreated) > BulletWait
sprite b+10, s_centre_x -5, s_centre_y -30, 2
rotate sprite b+10,(sprite angle(3) +180)
Bullets(b,1)=1
Bullets(b,2)=0
show sprite b+10
move sprite b+10,3
play sound 1
rem Store time when bullet was last created, to allow a few secs between each create
LastCreated = timer()
endif
rem If fired, move
if Bullets(b,1)=1
move sprite b+10,6
`DBP bug - cannot decrement arrays
l = bullets(b,2)
inc l
Bullets(b,2) = l
endif
rem Stop if at end of life and decrement bullets
if Bullets(b,2) > maxlife
Bullets(b,1)=0
hide sprite b+10
endif
next b
`=======FEEDBACK====
Feedback:
Text 1724, 27, " & PLAYER Y: "+str$(sprite Y (3))
Text 1600, 47, "SPRITE HIT: " +str$ (Sprite hit( ???? , 5))
return
`==================================
return
end
Thanks in advance.
CPU: AMD Phenom II X4 3.2GHz Quad-core HD: 640GB(6GB/s) RAM: G.Skill 4GB (1600MHz) GPU: ATI Radeon 5870
MoBo: ASUS M4A88TD-V EVO OS: Win 7 Home 64-bit