Having a hard time with multiple shots
-
Having trouble with some code i'v been putting off as i'v always had trouble with it with other programs.
Currently i'v got thismaxArrow = 9 Arrow = createGameSprites (maxArrow) numArrows = 0 //number of players current arrows to use which is tied to the controls function createArrow() for i = 0 to maxArrow loop if !Arrow[i].active then list of sprite properties...... Arrow[i].active = true setspriteimage... animation ... collision shape .. break endif repeat return void
so the sprite is ready to be used so i call it with
if numArrows >0 and c.r and !oldc.r then createArrow() numArrows -=1 endif
This all works as expected i even have player direction dictating the direction and speed of the arrow working.
my main issue is when it comes to collision with other enemies something i'v done time and time again but with a single sprite vs for looped ones but with 2 sets of looped sprites the first shot will register but past that they don't.
i'v tried all sorts plus removing the sprite to refresh the array. Don't want to do what i'v done before with dodgy code probably something simple im missing ;) -
I'm not sure if this is what you need but this is how I deal with collision with two sets of sprites
for sh = 0 to len(pshots) loop for en = 0 to len(enemies) loop col = detectspritecollision(pshots[sh], enemies[en]) if col then removesprite([pshots[sh]) pshots[sh] = createsprite() pshots[sh].active = false removesprite(enemies[en]) enemies[en] = createsprite() enemies[en].active = false endif repeat repeat
-
@SteveZX81 yep i was only processing one of the loops in my collision code so now it works with processing both ! , iv added life counters to my enemies spawn code so now to respawn its just enemylife =1 and there all reset.
cheers steve !