Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lives and Scoring Games Programming in Scratch. Games Programming in Scratch L2 Lives and Scoring Learning Objectives Define a variable Understand the.

Similar presentations


Presentation on theme: "Lives and Scoring Games Programming in Scratch. Games Programming in Scratch L2 Lives and Scoring Learning Objectives Define a variable Understand the."— Presentation transcript:

1 Lives and Scoring Games Programming in Scratch

2 Games Programming in Scratch L2 Lives and Scoring Learning Objectives Define a variable Understand the importance of using meaningful variable names Write algorithms which use variables to hold values such as Number of Lives Left or Score in a computer game Understand the purpose of comments in a program Annotate a program with comments

3 Games Programming in Scratch L2 Lives and Scoring What happens when one sprite touches another? When? Forever / When clicked / On a key- press Condition? If touching… / If time exceeds… / If x = y… What do you want to happen? Change colour / end game / go back to start

4 Games Programming in Scratch L2 Lives and Scoring Looping and Selection If... Then If Pacman touches Ghost then Game Over Forever loops

5 Games Programming in Scratch L2 Lives and Scoring Modifying your game Use the Forever loop and the If block to make movement smoother:

6 Games Programming in Scratch L2 Lives and Scoring Using Variables A variable represents a location in memory This location is used to hold a value which you assign to it. You can change the value in the program. You give a variable a name, which you use to refer to it, for example to set an initial value, change, use or output the value. For example: A variable called “Lives” might hold the value “3”. Set Lives = 3

7 Games Programming in Scratch L2 Lives and Scoring Variables

8 Games Programming in Scratch L2 Lives and Scoring Writing the algorithm What are the steps required to set the starting value of lives and reduce that by one when one sprite touches another? 1. 2. 3. 4. 5. 6.

9 Games Programming in Scratch L2 Lives and Scoring Programming Lives 1.When game starts 2.Start with 3 lives 3.Check constantly 4.If.. 5.you are touching an enemy 6.Subtract 1 life

10 Games Programming in Scratch L2 Lives and Scoring Scoring What makes you earn points in the game? – Collecting something? – Beating a timer? – Solving a problem? Use of Show and Hide blocks

11 Games Programming in Scratch L2 Lives and Scoring Variable display settings Show or Hide Integer variable Slider Large or Small (With or without label) Moveable

12 Games Programming in Scratch L2 Lives and Scoring Adding Scoring Work out how you can use the same techniques with variables to add a scoring element to your game.

13 Games Programming in Scratch L2 Lives and Scoring Ending the game End the game using an Stop block Add a message for the user

14 Games Programming in Scratch L2 Lives and Scoring Adding Comments in Scratch Comment boxes in Scratch help you, and others, understand your code at a later date Commenting is good practice for professional programmers


Download ppt "Lives and Scoring Games Programming in Scratch. Games Programming in Scratch L2 Lives and Scoring Learning Objectives Define a variable Understand the."

Similar presentations


Ads by Google