Scratch Internet- Open Chrome hit “Create” 1.

16
Scratch Internet- Open Chrome http://scratch.mit.edu/ hit “Create” 1

Transcript of Scratch Internet- Open Chrome hit “Create” 1.

Page 1: Scratch Internet- Open Chrome  hit “Create”  1.

1

Scratch Internet- Open Chromehttp://scratch.mit.edu/

hit “Create”

Page 2: Scratch Internet- Open Chrome  hit “Create”  1.

2

Agenda: Intro to ScratchIntro to programming conceptsCreate game of “War”

Objective: Students will create a game of war that uses programming concepts such as variables and operators.

Page 3: Scratch Internet- Open Chrome  hit “Create”  1.

3

First we will make a variable called “Player 1 Card”.

1.Select Data2.Make a Variable3.Name the Variable

“Player 1 Card”

Page 4: Scratch Internet- Open Chrome  hit “Create”  1.

4

Once you have created the variable “Player 1 Card” additional programming options appear on the Data menu and it appears on the stage.

A variable is a “placeholder” in a program that can change in value. We will be programming “Player 1 Card” to select a random value between 1 and 10 later in this lesson.

Page 5: Scratch Internet- Open Chrome  hit “Create”  1.

5

Make the following variables:1. Player 2 Card2. Player 1 Score3. Player 2 Score

We will repeat the steps used to make a variable.1.Select Data2.Make a Variable3.Name the Variable

Page 6: Scratch Internet- Open Chrome  hit “Create”  1.

6

You should now have the four variables in your program.

Page 7: Scratch Internet- Open Chrome  hit “Create”  1.

7

Click and drag the variables to separate the players.

Player 2Player 1

Page 8: Scratch Internet- Open Chrome  hit “Create”  1.

8

Now we will program our game to pick card values for each player. We do this by the following:

1. Under “Events” select 2. Select Data tab3. Set “Player 1 Card to” (leave the space

blank)4. Select Operators tab.5. Select “pick random (1) to (10)” and drag

it into the blank space from Step 3.

5. You will need to do this for both of the Player Cards

Page 9: Scratch Internet- Open Chrome  hit “Create”  1.

9

We will now program the game to award a point to the player that has the higher card value.

Click and Drag the Following Blocks:

“If then” (Control Tab) “Player 1 Card” (Data Tab) “Player 2 Card” (Data Tab) “Change Player 1 Score” (Data Tab) “Greater Than” block (Operators Tab)

Arrange the blocks according to the picture.

Page 10: Scratch Internet- Open Chrome  hit “Create”  1.

10

We will now program the Cat to announce that Player 1 wins the round.

1. Select the “Say “Hello” for ___ secs” (Looks tab)

2. Change the text to read “Player 1 Wins the Round” and change the time to “2”.

Page 11: Scratch Internet- Open Chrome  hit “Create”  1.

11

We will now repeat the process for when Player 2 Card is greater than Player 1 Card.

1. Separate this section of the code.2. Right click on the block and select duplicate.

After you have duplicated the blocks, change the values in the duplicated block to award Player 2 a point.

Page 12: Scratch Internet- Open Chrome  hit “Create”  1.

12

An important step in Computer Programming is to check your programs as they are in development to make sure they work properly.

Take a moment to test your program to make sure there are no “bugs” in it.

Press the space bar several times to test the program. It should show a number for each player and award a point to the player that won.

Page 13: Scratch Internet- Open Chrome  hit “Create”  1.

13

We will now program the game to declare a winner when a player gets to 10 points.

For this we will use the following blocks:

We will need the following blocks: “If then” (Control Tab) Player 1 Score (Data Tab) “Equal to ” (Operators Tab) “Say Block for ____ secs” and the

“Say Block” (Look Tab)

Arrange them in the following order.

Page 14: Scratch Internet- Open Chrome  hit “Create”  1.

14

We will now repeat the process for Player 2

Detach the player “if then” block you just created.Right click and select duplicate.

Change the information so that it reads as follows.

Page 15: Scratch Internet- Open Chrome  hit “Create”  1.

15

We will now set up the “Reset” button.

Select “when green flag clicked” from the Events tab.

From the Data tab select the “set__________ to 0”. You will need to do this 4 times.

Connect the blocks as shown to the right and assign each of the variables to a block.

Page 16: Scratch Internet- Open Chrome  hit “Create”  1.

16

Extensions

1.Program the cat to say “It’s a tie” when the players’ cards are equal to each other.

2.Program the cat to say what the value of the winning card is in each round.