Matth89812 Posted February 21, 2015 Share Posted February 21, 2015 I am trying to make the enemy hit the player and then the health bar decreases by 25 (total is 100) but its subtracting in different random ways. I want the pfscore health bar the decaread to the left. And when the health is completly gone, it comes the game over screen. How do I fix and do it? default.bas Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 22, 2015 Share Posted February 22, 2015 I'm working on a deluxe version of Tinkernut World and one version will have a working health bar. I hope to have it done in a day or two. Quote Link to comment Share on other sites More sharing options...
Matth89812 Posted February 22, 2015 Author Share Posted February 22, 2015 Thanks men! I really owe you one! Quote Link to comment Share on other sites More sharing options...
bogax Posted February 22, 2015 Share Posted February 22, 2015 man I'm no expert but I think your problem is that the sprites routine keeps reseting pfscore1 set pfscore1 to %11111111 before (or at least outside) the sprites routine (forget the pfscore1 = 100) then instead of pfscore1 = pfscore1 - 25 make it pfscore1 = pfscore1 * 4 Quote Link to comment Share on other sites More sharing options...
Mountain King Posted February 22, 2015 Share Posted February 22, 2015 Also the health bar pfscore1 and pfscore2 are really a graphic representation of your health and they don't display correctly unless the value is exactly 255, 127, 63, 31, 15,7,3,1 and 0. You will need to convert your damage value to scale to the pfscore_ value. This is how I originally did it. Bogax showed me a better way. But this way is hopefully clear. If my player0 touched player 1 or missile on it would take 3 damage. Depending on the damage level pfscore2 would display accordingly. Once the damage level became lethal, then it would jump to the death routine. if collision(player0,player1) && !p=6:then r=r+3 if collision(player0,missile1) && !p=6:then r=r+3 if r=0 then pfscore2 = %11111111 if r>30 then pfscore2 = %01111111 if r>60 then pfscore2 = %00111111 if r>90 then pfscore2 = %00011111 if r>120 then pfscore2 = %00001111 if r>150 then pfscore2 = %00000111 if r>180 then pfscore2 = %00000011 if r>210 then pfscore2 = %00000001 if r>240 then pfscore2 = %00000000 if r>242 then goto __gizdead bank4 The more efficient way Bogax showed me looks like this: if collision(player0,player1) && !p=6:then r=r+3 if collision(player0,missile1) && !p=6:then r=r+3 if r > 0 && r < 31 then __skip rem temp1 = r / 30 temp1 = r / 2 : temp1 = ((temp1 / 16) + 1 + temp1) / 16 pfscore2 = tbl[temp1] data tbl %11111111, %01111111, %00111111, %00011111, %00001111, %00000011, %00000001, %00000000 end if r > 242 then goto __gizdead bank4 __skip Quote Link to comment Share on other sites More sharing options...
Matth89812 Posted February 22, 2015 Author Share Posted February 22, 2015 It worked. Now I need help with the game over screen. When the life bar is all gone the game over screen appears. Any suggestion on how to do it? Quote Link to comment Share on other sites More sharing options...
bogax Posted February 22, 2015 Share Posted February 22, 2015 if !pfscore1 then gameover Quote Link to comment Share on other sites More sharing options...
Matth89812 Posted February 22, 2015 Author Share Posted February 22, 2015 That did not work. Quote Link to comment Share on other sites More sharing options...
bogax Posted February 22, 2015 Share Posted February 22, 2015 It would help if you posted your code and were a liitle more precise about what you want to happen. when you get to zero lives you go to your gameover code that does whatever you want to happen when the game ends Quote Link to comment Share on other sites More sharing options...
Matth89812 Posted February 22, 2015 Author Share Posted February 22, 2015 Ok. Here is what I have default.bas Quote Link to comment Share on other sites More sharing options...
bogax Posted February 22, 2015 Share Posted February 22, 2015 if collision(missile0, player1) then score = score + 1 : player1x = rand/2 : player1y = 0 : missile0y = 255 if collision(player0 , player1) then score = score - 1 : player1x = rand/2 : player1y = 0 : missile0y = 255 : pfscore1 = pfscore1*4 rem pfscore1 may have changed so check to see if you've rem run out of lives and if so jump to game over rem !pfscore1 is like pfscore1 = 0 if !pfscore1 then gameover goto __Main_Loop jump goto sprites goto draw_loop gameover playfield: ..XXXXXX..XXXXX..XXXXXXX..XXXXXX ..X.......X...X..X..X..X..X..... ..X.XXX...XXXXX..X..X..X..XXXXXX ..X...X...X...X..X..X..X..X..... ..XXXXX...X...X..X.....X..XXXXXX ................................ ..XXXXXX.X........X.XXXX..XXXX.. ..X....X..X......X..X.....X..X.. ..X....X...X....X...XXXX..XXXX.. ..X....X....X..X....X.....XX.... ..XXXXXX.....XX.....XXXX..X.X... end gameover_loop drawscreen goto gameover_loop something like that then although I assume you're going to want some way to break out of the gameover_loop Quote Link to comment Share on other sites More sharing options...
Matth89812 Posted February 22, 2015 Author Share Posted February 22, 2015 Good but then when the game over screen appears, the player (player0) has to disappear. Quote Link to comment Share on other sites More sharing options...
bogax Posted February 22, 2015 Share Posted February 22, 2015 then make it disappear I think that's usually done by parking it somewhere off the playfield but I assume you could blank it or change the color to match whatever it's over Quote Link to comment Share on other sites More sharing options...
Mountain King Posted February 22, 2015 Share Posted February 22, 2015 You'll need to position your player0 off the screen. Something like: player0x=200:player0y=200 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.