Open the starting file. Open the Objects folder; you should see the objects already there. Make sure you are in Advanced Mode!

Moving Left

Go into the object character and add the <Left> Keyboard event:

  • Change Sprite: set to the left character sprite (don’t worry about subimage or speed)
  • Check Empty: is just to the left of the character empty?
    (-4,0), only solid, relative
  • Jump to Position: (-4,0), relative

Moving Right

Duplicate the previous event for the <Right> Keyboard event.

Open the Change Sprite action and change it to the right-facing character sprite.

Then change the X values to 4 for the Check Empty and Jump to Position actions. They should stay relative.

So your <Right> event looks like this…

Save then test the game, make sure the character moves left and right.

Jumping

Jumping up only if character on the floor

We have to let the character jump when the up arrow key is pressed. But this must only happen when the character is currently on the floor.

Add an <Up> event. We first test whether the position below the character creates a collision…

  • Check Collision: is character on the floor/platform?
    with only solid objects at (0,1), relative
  • Speed Vertical: set to -10

If character is in the air

Now add a Step event…add a Comment action (type in the box “check whether in the air”)

If character is in the air, if the position just below character is empty (no solid objects), then set the gravity to a positive number.

  • Check Empty: (0,1), only solid, relative
  • Set Gravity: direction = 270 (=down), gravity = .5 (not relative).
  • Else
  • Set Gravity: direction = 270, gravity = 0 (not relative)

We also want to limit the vertical speed so if it’s more than 12, we’ll set back to 12. So add a few more actions:

  • Comment – “limit vertical speed”
  • Test Variable: if variable vspeed > 12
  • Speed Vertical: set to 12

Landing

In the character object, we have to make sure he lands correctly on the floor (when collides with a block object). We need to place the character back to its previous position just before the collision; if it’s already at the current position, it doesn’t move.

Add the Collision with block event.

  • Move to Contact: direction = “direction” (indicates the current direction of motion of the object), maximum = “12”, against solid objects
  • Speed Vertical: set to 0

Save then test your game.

Your character should be able to jump up and land on platforms…

Mushrooms

Go into the mushroom object and add a new Create event.

  • Change Sprite: subimage = random(10) and speed = 0

To give a bit of variation, the mushroom sprite contains 10 different mushrooms sub-images. Set it so when the room loads, it randomly picks which subimage to show for each mushroom object.

Collecting mushrooms

Go into the character object, add a Collision with mushroom event.

  • Set Score: give player 10 points
  • Destroy Instance: other (= mushroom)

Room

Add about 6 mushroom objects to your room (on floor & platforms).

Save and test your game.

When you play the game, you should see different mushroom sprites.

If you collect some of the mushrooms, the score should go up.

Next Level

Go into your player object and add a Collision with nextLevel. Add the actions as shown below…

Room

Add the nextLevel object on the right side of your room. For now, if you get to it, the highscore table should pop up and you’ll restart the room.

Pits

Player Falls into Pit

Go into the character object and add a Collision with death event.

  • Sleep
  • Set Lives: lose a life (make sure it’s relative!)
  • Restart Room

Player Jumps Outside Room

Add an Outside Room event for the character…

  • Test Variable: y > room_height
    test whether the character jumped outside the playing field
  • Restart Room

Room

Go into your room and add 4 death objects in a row along the bottom (this will still be an easy amount to jump over).

Save and test your game.

Test is if the player jumps back to its starting position with these 2 scenarios:

  • if the player lands on the death object
  • if it falls off an edge