Captain Spazer Posted January 31, 2020 Share Posted January 31, 2020 I'm having a bit of trouble with an idea, I'm using the multisprite kernel and I got 4 of the sprites as things to pick up to get score, this works fine. I'm trying to get a counter working so that once the four items have been collected an event triggers, but I can't get it to trigger. This is the code I'm using for collision and adding score: if (player0y + 6) >= player2y && player0y <= (player2y + 10) && (player0x + 10) >= player2x && player0x <= (player2x - 1) then score = score + 1 : player2y=200 if (player0y + 6) >= player3y && player0y <= (player3y + 10) && (player0x + 10) >= player3x && player0x <= (player3x - 1) then score = score + 1 : player3y=200 if (player0y + 6) >= player4y && player0y <= (player4y + 10) && (player0x + 10) >= player4x && player0x <= (player4x - 1) then score = score + 1 : player4y=200 if (player0y + 6) >= player5y && player0y <= (player5y + 10) && (player0x + 10) >= player5x && player0x <= (player5x - 1) then score = score + 1 : player5y=200 Now, if I was to add at the end for example p = p + 1 when colliding with the sprite, it does nothing. My none working experiment: if p <=4 && player0x < player1x then _P1_L_R = _P1_L_R - 0.10 : REFP1=0 if p <=4 && player0x > player1x then _P1_L_R = _P1_L_R + 0.10 : REFP1 = 8 if p <=4 && player0y < player1y then _P1_U_D = _P1_U_D - 0.10 if p <=4 && player0y > player1y then _P1_U_D = _P1_U_D + 0.10 if (player0y + 6) >= player2y && player0y <= (player2y + 10) && (player0x + 10) >= player2x && player0x <= (player2x - 1) then score = score + 1 : player2y=200 : p = p + 1 if (player0y + 6) >= player3y && player0y <= (player3y + 10) && (player0x + 10) >= player3x && player0x <= (player3x - 1) then score = score + 1 : player3y=200 : p = p + 1 if (player0y + 6) >= player4y && player0y <= (player4y + 10) && (player0x + 10) >= player4x && player0x <= (player4x - 1) then score = score + 1 : player4y=200 : p = p + 1 if (player0y + 6) >= player5y && player0y <= (player5y + 10) && (player0x + 10) >= player5x && player0x <= (player5x - 1) then score = score + 1 : player5y=200 : p = p + 1 Since this code doesn't say what happens when p > 4 then player1 should stop. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 31, 2020 Share Posted January 31, 2020 What happens if you do this: if p > 4 then goto __Skip_p1_Movement if player0x < player1x then _P1_L_R = _P1_L_R - 0.10 : REFP1=0 if player0x > player1x then _P1_L_R = _P1_L_R + 0.10 : REFP1 = 8 if player0y < player1y then _P1_U_D = _P1_U_D - 0.10 if player0y > player1y then _P1_U_D = _P1_U_D + 0.10 __Skip_p1_Movement 1 Quote Link to comment Share on other sites More sharing options...
+TwentySixHundred Posted February 1, 2020 Share Posted February 1, 2020 (edited) 6 hours ago, Captain Spazer said: Now, if I was to add at the end for example p = p + 1 when colliding with the sprite, it does nothing. Since this code doesn't say what happens when p > 4 then player1 should stop. From what i am reading you have kinda answered it yourself "Since this code doesn't say what happens when p > 4". If there is no instruction for 'P' the program will just continue and that variable is basically doing nothing other then addition. As you can see with RT's example, there is an if-condition for "P" that has a solution if the value is true (this is at that start of the codeblock). Then there is a label after the codeblock for the "P" condition to jump to if that condition is true. Basically if true that will skip all code between the two and by the looks of it deactivate "player1". Edited February 1, 2020 by TwentySixHundred 1 Quote Link to comment Share on other sites More sharing options...
Captain Spazer Posted February 5, 2020 Author Share Posted February 5, 2020 Oh yeah, thanks guys! Silly of me. 1 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.