How to Jump?

376 views
Skip to first unread message

hunterja...@gmail.com

unread,
Oct 11, 2013, 7:26:16 PM10/11/13
to puzzle...@googlegroups.com
I am a newb and very young. Can someone please tell me how you can make the player jump. (and if possible add gravity?)

sftr...@gmail.com

unread,
Oct 11, 2013, 7:41:37 PM10/11/13
to puzzle...@googlegroups.com, hunterja...@gmail.com
There are lots of different approaches for this. The easiest way will make the player instantly drop to the floor (rather than an animated fall). To do this, you just need the following rule:

DOWN [ Player | NO Solid ] -> [ | Player ]

where Solid is a group of objects that you would like the player to land on. Something like:

Solid = Wall or Block

Now think about why it works. The rule looks for a Player object with no Solid object below it (DOWN tells it to only look for downward patterns). So it basically finds a Player not standing on anything. It replaces the first tile in the pattern (the Player) with nothing and replaces the empty tile below with the Player. So the Player has moved into the empty tile below!

Rules are applied repeatedly until they can't be applied any more and only then will the graphics get updated. So the Player will keep moving into the empty space below until it hits a Solid object, then the graphics will update. It will look like the Player fell due to gravity.

ff68...@gmail.com

unread,
Oct 12, 2013, 8:01:07 PM10/12/13
to puzzle...@googlegroups.com, hunterja...@gmail.com
I don't know if it's too late.

stfr explains quite well how to implement gravity ("If there is space below the player -> make the player appear in that space").

Then there is the problem how to jump. You can't press right and up simultaniously, so that has to be two turns. (Everything is turn based in puzzlescript! You won't be able to script Super Mario.)

When someone presses up, you could let the player just move up (no rule required), but also mark the field he is now on with an invisible "flying" marker.
As long as the player is on the same field as a "flying" marker, he would be forbidden to move up and exempt from the gravity rule.

UP [ > Player | | ] -> [ | | Player Flying ]  ( two tiles high jump - not tested! )

In order to jump over gaps, you would either make gravity work in a way, it pulls you down only one tile per turn, or make two sideways steps instead of one when flying.

Do you need some example code? Maybe look in http://puzzlescriptgallery.tumblr.com/ for games with jumping (there are some) and look how they did it.
Reply all
Reply to author
Forward
0 new messages