eros
Central Cavern
Posts: 2
|
Post by eros on Oct 14, 2022 20:26:23 GMT
Hi, newbie here, Im using MPAGD (thanks btw its awesome) and have been putting together a platformer for the ZX following lots of tutorials and generally getting the hang of things.
I wanted to try the mechanism to kill the player should it fall from a certain height. Iv read the other posts on the forum regarding it, but i am not quite sure I understand it.
Basically if i have
IF TYPE = 0 ; PLAYER KILL ENDIF I have a default jump of 7... there is a note on in the TIPs that basically if the player falls at a JUMPSPEED of 8 or above, fell to far is called? In this case, Jumping on the spot, kills the player each time.
If I add an IF statement to the Event Fell to Far such as
IF TYPE = 0 ; PLAYER
IF JUMPSPEED > 10 KILL
ENDIF ENDIF Basically nothing happens, the player doesn't die when falling, no matter the height (I used one of Minilop's guides, deep dive into jumping to check the speed and print it so i could get an idea of the speed)
Only thing I can think of is that basically at the point of collision with the ground, the jump speed is 0 , and such the IF statement is never satisfied.
If so... How might I go about this check? Or modify the default when the event is called?
Many thanks and again, super nice environment, always wanted to have a go at making a ZX game but couldn't get beyond moving simple characters around the screen.
|
|
|
Post by ramon on Oct 21, 2022 15:25:50 GMT
Best regards.
The solution:
Put this code anywhere you want inside your player event.
IF CANGODOWN LET A = JUMPSPEED ELSE ; I hit the ground AT 4 1 DISPLAY A IF A >= 8 LET A = 0 KILL ENDIF ENDIF
Explanation:
First: You have to know is that the sprite properties are only accessible during the sprite event. So the player's JUMPSPEED is only accessible in the player's event.
Second: The Fell too far event only occurs if JUMPSPEED is 8. Neither 7 nor 9.
Third: The script: "If I hit the ground and JUMPSPEED is greater than 8 it means I'm flying from very high." It must necessarily be in the Player event.
Extra: If you want to share JUMPSPEED with another event or with an enemy assign it a variable: for example LET H = JUMPSPEED to use it. Other properties are: X,Y,FRAME,TYPE,IMAGE,DIRECTION,SETTINGA,SETTING,JUMPSPEED or DATA.
|
|
eros
Central Cavern
Posts: 2
|
Post by eros on Oct 28, 2022 19:37:57 GMT
ah the player script, i might have known! Thanks, i popped that in place and it works, kills the player for variable height drops, i had to add another nested if statement as when we hit walls sideways it puts the value at 100+  amazing thanks!!!
|
|
|
Post by ramon on Oct 30, 2022 16:47:03 GMT
Congratulations. You're right.
IF CANGODOWN LET A = JUMPSPEED ELSE ; I hit the ground AT 4 1 DISPLAY A IF A >= 8 IF A < 128 ; I am falling LET A = 0 KILL ENDIF ENDIF ENDIF
|
|