# Lesson 6 Platforms and Jumping (1)

Learning Objectives

• To add platforms to the game.
• To make the main character jump.
• To understand the jump physics.

Learning Outcomes

All must Add script to main character. (Level 5)

Most should Create a navegable series of platforms in the game. (Level 6)

Keywords

Words to learn: Newtonian Jump, script, key binding.

Starter

Before we start, we need to think about jumping and physics.  Mario was quite famous in the ealry days, for the implementation of Newtonian Physics in a video game, giving him an extremely realistic jump…

Think of gravity constantly pulling as he takes off.  He leaps into the air quickly, but the higher he goes, the less he accelerates, until he starts to drop, getting steadily faster, as gravity makes him accelerate back to earth…

Main – Feet on the ground

We’ll need to open up the game we were working on last lesson.

Our first job is to move the character into view better, and add some platforms.  This process is very easy.

Remember the character was made of different elements?  Our first job is to lock them together so we can move him around.

Once he’s away from the corner,  we look to the ground.  First, we just create a rigidbody2d as we did before, with sprite, and collisionshape2d as before.  We assign an image to the sprite, and re-size it.  It is important to change the mode to static though… Otherwise the platform will fall through the air!

The components of the ground must be locked together as before.

If we then give the ground a sensible name, we can right-click on it and select “duplicate”.  This gives us another platform, which can be re-positioned.  You’ll need several to start with.

These steps can be seen here:

### The Jump

Think about the programming you’ve done so far. Code to jump shouldn’t be difficult:

if(up_key_is_pressed):
character_move_up

Basically, that’s, all there is to it.