Basic Platform Jump Game

  1. Make our character Sprite run left and right with Arrow keys

  2. Make our character Sprite jump on platforms with the Space key

  3. Let character Sprite fall if NOT touching a platform

  4. Add a moving platform and a Lava Pit obstacle

  5. Let our character Sprite reach the Portal to advance to the next Level

  6. Use a Variable and Broadcast message to manage Levels and know when the player wins by getting past the last level

  7. See a list of Challenges to improve the game on your own

Sign in at Scratch

Go To: http://scratch.mit.edu/

scratch-signin

CoderDojo Indigo Studio

Go To: http://scratch.mit.edu/studios/585122/ and click Platform Game (Starter)

CoderDojo Indigo

Click the "See inside" button

Notice the sections: Title, Instructions and Notes and Credits

see-inside

Click the "Remix" button

This will make a copy of the project under your name

remix

Rename the Project

It's a good practice to name your project something unique

rename

Sprite Control with Keys

Code your sprite to move left and right with arrow keys

left-right

Fix Sprite Orientation

Set left/right orientation and add "point in direction" code blocks

sprite-orientation

Simple Sprite Animation

Add "wait" and "next costume" code blocks

sprite-next-costume

Sprite Jump Control

Code blocks to set start location, "space" key press, sound and upward motion

sprite-jump

Sprite should Respect Gravity!

Your Sprite should fall if NOT on a platform; use a "not" Operator

sprite-fall

Jump only from a Surface

Add this new rule for your Sprite with an "and" Operator

jump-platform

Add a Moving Platform

Add a starting point, "show" block and a "forever" loop

moving-platform

Add a Variable for "Level"

Click back on "Giga" Sprite; Data -> Make a Variable; name it "Level"

variable

Set your "Level" Variable

You can move your variable on stage; Add "set variable" block to a start block

set-variable

Get to the Portal!

This code block checks for Sprite touching "Portal", then increments the "Level" variable and moves Sprite back to start location

portal-advance

A more Interesting Portal

Select the "Portal" Sprite; Add code block to change color forever

portal-color

Broadcast Message

Select "Giga" Sprite; Add a "Broadcast message block"; Select "new message..."

broadcast-message

Broadcast Message

Name the message "NewLevel" and click "OK"; You will tell other sprites to listen for this message...

message-name

Stage Backdrops

Peek at Backdrops tab, then add code blocks to switch backdrops at start and when it hears the "Newlevel" message

stage-backdrops

"Platforms" Sprite Costumes

Select the "Platforms" Sprite; Look at the Costumes tab
(Note: the "Levels" could have been drawn right on Stage backdrops)

platform-costumes

"Platforms" Costume Updates

Set the "Platforms" Sprite to listen for the "NewLevel" message and switch costumes depending on the Level

platform-costumes

"Moving Platform" Locations

Set the "Moving Platform" Sprite to listen for the "NewLevel" message and change its location depending on the Level

moving-platform-location

Hide the "Portal" at the End

Set the "Portal" Sprite to listen for the "NewLevel" message and hide itself at the end; This is why we added a "show" block upon start

hide-portal

The Lava Pit Sprite was Hiding

Select "Danger1" Sprite; Click the "Info" icon and check the "show: " box

obstacle

The Lava Pit Sprite Animation

Add code blocks to animate costumes and "show" on Level 2 only (if-then-else)

obstacle-show

What Happens if Character hits Lava Pit?

Right now, nothing! We need to code that back on the "Giga" Sprite!

obstacle-collision

Finishing the Game

We only created 3 Levels; so the last backdrop is "You Won" and all Sprites are hidden with our "NextLevel" message and Level = 4 code logic (except for "Giga").

you-won

Congratulations!

You built a platform game! Now, here are a few Challenges:

  1. Build more levels (backgrounds, platforms, obstacles)

  2. Add special platforms (like springs or transporters)

  3. Create a variable to track number of lives and end of game

  4. Add items to pick up for points or more lives

  5. Add music or more sound effects

  6. Add velocity for more realistic Sprite movement

  7. Add a "Start Over" button

If you got stuck anywhere, see the completed project with comments here: http://scratch.mit.edu/projects/34001904/!

/