Welcome to ouzz.eu! Follow me on twitter to stay tuned.

contact: support@ouzz.eu

The last version of the game at the end of this tutorial.

Arrows to move & jump. W/Z to kill enemies!

Made with Stencyl

Last update: 29.03.2018

Jump tutorial…But not a simple jump!

I found nothing on the web about jump movment. So, i decided to make my own tutorial.

First of all, i apologize for my English. I’m French and not fluent in English. But i’ll do my best to be as understandable as possible.

Jump: 3 behaviors…

1 - You press the button and the sprite JUMP and then FALLS DOWN QUICKLY.

​

2 - You press the button and the sprite JUMP and then you hold the button pressed down and the sprite FALLS DOWN SLOWLY.

If you release the button, the sprite SPEED UP…If you press again, he keeps on falling slowly, etc.

​

3 - You hold the button pressed and the sprite JUMP and then FALLS DOWN SLOWLY.

…and of course the sprite can moves to the LEFT and to the RIGHT…On floor…and in the air (while jumping)!!!

The scene…

- 20x30 tiles  (16x16 pix)

- The Vertical Gravity is set to 100

Game Attributes...

1 - direction.

The Direction GA is used to know if the sprite is moving to the LEFT or to the RIGHT and to display the correct sprite animation (Run left, Run Right, jump left, jump right, idle left, idle right).

This GA is set to 0 (left) or 1 (right).

​

2 - OnAIr.

The OnAir GA is used to know if the sprite is in the air (1) or on the floor (0)

​

3 - Xspeed.

Xspeed GA records in real time the horizontal speed. If <0, the sprite is moving to the left. If >0, he’s moving to the right…

​

4 - Yspeed.

Yspeed GA records in real time the vertical speed. If <0, the sprite is moving UP. If >0, he’s moving DOWN…

Move the sprite to the left, or to the right…

If the LEFT control is down, x-speed is set to a value <0.

Two conditions:

The sprite is in the air (OnAir = 1) or not (OnAir = 0).

Likewise with the Right control…

Jump…simple jump.

…Press again and hold the button to fall down slowly.

Y and X speed are recorded…

The sprite is on the floor: OnAir =0

​

-direction = 0 (the sprite is turned to the left)

​

-direction = 1 (the sprite is turned to the right).

​

Don’t forget to set OnAir = 1 (the sprite is in the air while jumping)

​

Set the Y-speed you need.

Only if the sprite is in the air and falls down: Yspeed >= 0, and OnAir = 1.

Yspeed >= 0 and not > 0…Why? Because the Speed is at 0 on floor AND at the top of the jump just before to fall. So if  you set  > 0, the sprite will do a double jump because OnAir will be reset at 0 at the top of the jump. My last tutorial works with > 0, but i think it was a bug. After cleaning project, the sprite began to double jump. So, now i use >= 0!

Finally, you can start to jump by holding the button pressed…

The sprite is on the floor: OnAir =0

​

-direction = 0 (the sprite is turned to the left)

​

-direction = 1 (the sprite is turned to the right).

​

Don’t forget to set OnAir = 1 (the sprite is in the air while jumping)

​

After the beginning of the jump, set the TIME after which the sprite starts to fall. This time depends on the initial Yspeed you have set. Then set the force you need to slow down.

Display the correct animation while jumping, and IDLE when the sprite hit the floor!

Direction = 0….you have to display left animations while jumping (Speed not=0)

If on the floor -> reset OnAir to 0

Direction = 1….you have to display right animations while jumping (Speed not=0)

If on the floor -> reset OnAir to 0

How to make your sprite not stuck in walls?

​

​

Test the last update of the game to see the differences:

-First version: for example, jump and hit the wall on the left and hold the left button pressed: The sprite is stuck while the button is pressed. If you release the button the sprite falls down.

​

-New version: Do the same thing…see the differences!

You have to set friction = 0 if the left or right side of the sprite hit tiles >>>

I hope you have enjoyed this tutorial. You can leave a comment on my twitter account!