Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more.

https://storage.googleapis.com/files.cs-first.com/game-design/game-icon%402x.png

1. Side Scrolling Games and If-Else Statements

Transcript

(upbeat music)

Hey, and welcome to scratch games day eight.

Today, you'll create a side scrolling game, while learning about if else statements.

You might be familiar with recent side scrolling games, like Helicopter and Flappy Bird.

You'll notice that in these games, the sprite only moves up and down.

The illusion of moving forward is created by moving the background.

To create today's game, you'll also learn about if else statements.

If else statements are very similar to if statements.

Remember, an if statement reads like this.

If a condition is true, do this action, or else, do nothing.

An if else statement reads like this.

If a condition is true, do this action, or else, do this action instead.

If else statements are useful, because it lets you specify a default action.

Watch how if else statements are used to program video games.

In Tetris, the bestselling video game of all time, the user must manipulate falling shapes to arrange them into rows.

If the user presses the down arrow, the falling shapes fall down really fast.

Else, they fall down at the regular speed.

An if else statement is useful here, because the falling shapes need to do one action all the time, but switch to doing another action when something specific happens.

In Plants vs. Zombies, the user must defeat waves of zombies using plants with special powers.

If there is a zombie near the scary shroom, it cowers down, and doesn't shoot.

Else, it continuously shoots at the zombies.

Just like the creators of those popular games, you'll use if else statements to build your project today.

In this game, a sprite is controlled using an if else statement.

For example, if the space bar is being pressed, then go up, else, go down.

Before moving on to the next screencast, click and open the starter project link next to this page.

Once you've completed the screencast, move on to the screencast to learn how to create a scrolling background.

Instructions
  1. Open the starter project.
  2. Remix the project.
  3. Sign in to Scratch.
  4. Add a New Sprite (preferably one that flies).
Attributions
  • "Tetris - NES Gameplay" by NESguide.com (https://www.youtube.com/watch?v=CvUK-YWYcaE) -- Licensed by Creative Commons Attribution-Share Alike 3.0 Unported (https://creativecommons.org/licenses/by-sa/3.0/deed.en) -- Video trimmed to needed length | Audio removed | Cropped on edges | Video scaled up, and blurred in background
  • "Plants vs Zombies 2 : It's About Time! - Pyramid of Doom - Level 107 (IOS) Gameplay Walkthrough" by Captain Hack vs Zombies (https://www.youtube.com/watch?v=lO9sjCBo9m80) -- Licensed by Creative Commons Attribution-Share Alike 3.0 Unported (https://creativecommons.org/licenses/by-sa/3.0/deed.en) -- Video trimmed to needed length | Audio removed | Video cropped on edges | Video scaled up, and blurred in background
  • "Flappy Bird Gameplay on iOS" by Cammygirl192 (https://www.youtube.com/watch?v=As-5sPilIx0) -- Licensed by Creative Commons Attribution-Share Alike 3.0 Unported (https://creativecommons.org/licenses/by-sa/3.0/deed.en) -- Video trimmed to need length | Audio removed | Video scaled up, cropping edges and blurred in background | Black border added around video