health system not working.
BlitzPlus Forums/BlitzPlus Programming/health system not working.
| ||
Hello! I have some problems with my health system. You have 3 life's, if you get hit by a bullet you are supposed to lose 1 life but instead you instantly die. here's the full code: http://pastebin.com/jbgqGKyJ I think this part of the code is the problem: Function Fplayerscore() If ImagesCollide(bullet1Image,bullet1X,bullet1Y,0,player2Image,player2X,player2Y,0) Then P1score = P1score - 1 If ImagesCollide(bullet2Image,bullet2X,bullet2Y,0,player1Image,player1X,player1Y,0) Then P2score = P2score - 1 If P1score = 0 Then stage = 2 If P2score = 0 Then stage = 3 End Function |
| ||
thanks for any help! |
| ||
Your problem seems to be that at no point are you destroying the bullet once it has hit something. The upshot of that, is that it's in contact with the player for several screen refreshes/collision checks and wiping out all the lives one after the other. When you detect a collision, destroy the bullet right away. |
| ||
I tried change the bullet1s Y to -20 if it collided with Player2 and the same thing for bullet2 but it didn't work :( Just so you know, I'm really new to blitzplus. |
| ||
Is there not a remove or destory command? |
| ||
Simply remove the bullet when it has collided and you've handled the collision. |