1 of 16

Building a Game in Scratch

Essential Question

How do you build a game in Scratch?

Warm Up Kahoot:217030

Learning Target

Be able to build and enhance a simple game in Scratch.

Quiz moved to next Wednesday.

2 of 16

Learning Objectives

  • To learn about the process of project design.
  • To be introduced to conditional statements in Scratch.

3 of 16

Outline for the day

  • You will make a game today
  • First we will look at Game Design.
  • Once the game is designed we will implement the game in Scratch

4 of 16

Design a Game: “Run Away”

  • When you start a programming project it is a good idea to brainstorm away from the computer.
  • We will start with a simple game.
  • It has 2 characters and a background.

5 of 16

Design a Game

  • Description of your Good character
  • Description of your Bad character
  • Description of the Background you would like to use for your game.

6 of 16

Design a Game: Controls

Key Used

Movement

Up Arrow

Move Up

Down Arrow

Move Down

Left Arrow

Move Left

Right Arrow

Move Right

Space Bar

7 of 16

Design a Game: Game Play

Game Feature

Working?

Bad Person moves randomly so the Good Person can’t guess where he is going

The Good Person starts with 5 lives (Later Lessons)

If the Good Person is touching the Bad Person then the Good Person loses a life. (Later)

If the Good Persons lives become equal to zero the game stops and a Game Over background appears (Later)

When the Game restarts the background is reset and the lives are initialized back to 5. (Later)

8 of 16

Design a Game: Improvements

  • Enter improvements for your game.

9 of 16

10 of 16

Building the Game

  • Open Scratch and remove the Cat
  • Add your two characters. (Good / Bad)
  • Add your background
  • Program the Good’s movements
    • Select sprite
    • Add scripts for right arrow (Change x by 10), left arrow (Change x by -10), up arrow (Change y by 10), down arrow (Change y by -10).

11 of 16

Sample Good Code

12 of 16

Program the Bad

  • Sample description of motion
  • Sprite will be moving forever (Forever loop)
    • Change x by (Pick random -20 to 20)
    • Wait 0.2 sec
    • Change y by (Pick random -20 to 20)
    • Wait 0.1 sec
    • Turn (pick random -90 to 90)
    • If on edge, bounce
  • Test it. Does the bad move around randomly?
  • Modify as needed to get the motion you would like.

13 of 16

Sample Bad Code

Refine these values to improve the Bad movements.

14 of 16

Ouch!!!

  • Getting the Good to react to bumping into the Bad.
  • This will need to be checked forever. (Loop)
  • Say Ouch
  • Change the character (fisheye, you can pick another effect)
  • Test

15 of 16

Possible Good Code

16 of 16

Extensions

  • Enhance the Good functionality by including a costume change when moving in different directions
  • Add special movement keys for the Good. A jump, …
  • Alter the speed and motion of the Bad to make it more realistic.
  • Demo to your neighbors
  • Check off your sheet
  • Demo to Smith