Learning about Game Development A Activity Guide
By
Trainings Department Dated 3/28/2020
© LearnOBots – All Rights Reserved 2020-21
Page 1
Contents Introduction ................................................................................................................................................ 3 ScratchX ...................................................................................................................................................... 3 Introduction ............................................................................................................................................ 3 Activity 1: Introduction to Scratch X ........................................................................................................... 4 1.
Sprites ............................................................................................................................................. 4
2.
Backgrounds.................................................................................................................................... 4
3.
Scripts ............................................................................................................................................. 4
Activity 2: Making Cat and Mouse Game .................................................................................................... 5 Challenge activity: ................................................................................................................................. 22 Activity 3: Adding Score to the Game ....................................................................................................... 23 Challenge activities: .............................................................................................................................. 25
© LearnOBots – All Rights Reserved 2020-21
Page 2
Learning about Game Development A Introduction Everyone loves to play games. Today, we are going to learn how to build games using a visual tool used for game development known as Scratch. In this session, you will learn about the basic concepts of visual programming through Scratch. We will also be forming our own games by the end of this session.
ScratchX Website URL: https://scratchx.org/#scratch
Introduction Scratch is a visual tool that comes with a drag and drop environment enabling the user to program with ease. With Scratch, you can program your own creative stories, games and animations. Today, we will be exploring ScratchX and build an interactive game so let’s start.
Open “Google Chrome” the following link.
browser on your laptop/computer. Open ScratchX in your browser using
https://scratchx.org/#scratch
Game Interface
Programming Area Blocks Area
© LearnOBots – All Rights Reserved 2020-21
Page 3
Activity 1: Introduction to Scratch X Let’s explore some of the functions of different blocks.
1. Sprites You can add, create and upload sprites from Scratch and your computer/laptop directory respectively.
2. Backgrounds You can add, create and upload backgrounds for your game from Scratch and your computer/laptop directory respectively.
3. Scripts In scripts there are multiple drawers like motion, events, control and looks etc.
3 1 2 There are different drawers in scripts that have different functions like: Motion: It consists of blocks related to movement, turning and changing the position of a sprite. Events: It contains blocks related to the events that trigger the game/sprite to perform actions. Control: It contains blocks related to loops, conditions and repeat commands. Looks: It contains the blocks of changing costumes, effects and size of sprite along with say commands. Operators: It consists of mathematical operations commands. Pen: The blocks in this drawer are used to draw lines via sprite. Data: You can create new variables and list for all the sprites. © LearnOBots – All Rights Reserved 2020-21
Page 4
Activity 2: Making Cat and Mouse Game In this activity, we will learn the functions of different blocks by making an interactive game of cat and mouse. Follow the steps to complete the activity.
Step 1 Click on
the button to choose a new sprite from the library.
Now Sprite Library will be opened. Click on Animals from Category menu and choose Cat 2.
1
2
Š LearnOBots – All Rights Reserved 2020-21
Page 5
Step 2 Go to the “Motion” drawer and take out the area.
block and place it in the programming
1
3
2
Step 3 Take out the
block and place it as shown below.
2 1
© LearnOBots – All Rights Reserved 2020-21
Page 6
Step 4 Go to the “Events” drawer and take out the
block and place it above the
as shown. Now change the “Space” to “Right arrow” in
3
1
2
block
Step 5 Now go to the “Motion” drawer and take out the
block and place as shown below.
1 3 2 © LearnOBots – All Rights Reserved 2020-21
Page 7
Now when you press your right key, the cat starts moving right. So, the next step is to make it move in the left, top and down direction.
Step 6 Take your cursor to the start of your code i.e. duplicate.
and press right-click and select
Step 7 Now change the “Right arrow” to “Left arrow” in the “-90” in block.
block and change “90” to
1
2
© LearnOBots – All Rights Reserved 2020-21
Page 8
Step 8 Again, duplicate the code to make the cat move up. We will need to change the “Right arrow” to “Up arrow” and “90” to “0”.
1
2
3 Step 9 Similarly, for the cat to move down. Change the “Right arrow” to “Down arrow” and “90” to “180”.
1
2
3 © LearnOBots – All Rights Reserved 2020-21
Page 9
Now test the movement of your cat in any direction using your arrow keys.
Right
Left
Movement
Movement
Top
Down
Movement
Movement
Step 10 Now again go to the Sprite Library and from Animals category, chose a Mouse 1.
1 2
Š LearnOBots – All Rights Reserved 2020-21
Page 10
Step 11 Now we will start coding for mouse. Go to the “Looks” drawer and take out the block and place it in the programming area. Change “100%” to “30%”.
1
3 2
Step 12 Now go to the “Events” drawer and take out the
block `and place it above the
block.
1
3
2
© LearnOBots – All Rights Reserved 2020-21
Page 11
Step 13 Click on the green flag
and you will see that size of your mouse changes.
Step 14 Now we will create a hole from where the mouse will enter in the game. So, go to the “Costumes” drawer and you will see the following screen.
© LearnOBots – All Rights Reserved 2020-21
Page 12
Step 15 Now make a circle around the mouse.
Step 16 Fill the circle with the black colour to make it look like a hole.
Š LearnOBots – All Rights Reserved 2020-21
Page 13
Step 17 Now change the name of the mouse from “mouse 1-a” to “hole”.
Step 18 Now again go to Scripts. Go to Looks and take out shown below. Change “mouse 1-b” to “hole”.
2
and place it as
1
4
3
© LearnOBots – All Rights Reserved 2020-21
Page 14
Step 19 From “Looks” drawer, take out the
block and place it above the
block.
1 3 2
Step 20 Now go to the “Control” drawer and drag out the block and place it as shown below. Clone block is used when we need multiple copies of the same sprite.
1
3
2 © LearnOBots – All Rights Reserved 2020-21
Page 15
Step 21 Take out the
block and place it as shown.
1 2
Step 22 Take out the
1
block and attach it as shown below.
2
© LearnOBots – All Rights Reserved 2020-21
Page 16
Step 23 From “Control” drawer, drag out the area.
block and place it inside the programming
2
1 Step 24 Now go to “Looks” drawer and take out the
block and place it below the
block.
1
3
2
© LearnOBots – All Rights Reserved 2020-21
Page 17
Step 25 Forever loops are used when we want to repeat the same process again and again until some condition is met. From “Control” drawer, take out the
block and place it as shown below.
1 3 2
Step 26 From “Motion” drawer, take out the
block and place it inside the
loop.
1 2
3
© LearnOBots – All Rights Reserved 2020-21
Page 18
Step 27 Now take out the
1
block and place it under
block.
2
Step 28 Now go to the “Operators” drawer and take out the block. Change 1 to -10 in
bock and place it inside the block.
1 3 2 4 © LearnOBots – All Rights Reserved 2020-21
Page 19
Step 29 Now go to the “Motion” drawer and take out the
block and place it inside the
block.
1 3
2 Step 30 Now go to the “Control” drawer and take out the as shown below.
block and place it inside the
loop
1
3 2
© LearnOBots – All Rights Reserved 2020-21
Page 20
Step 31 Now go to the “Sensing” drawer and take out the
block and place it inside the
block as shown. Click on the tiny black triangle in the drop down menu.
block and select “Cat 2” from the
1 2 3
Step 32 We want our cat to hide whenever it touches the Cat. In order to do so, go to the “Looks” drawer and take out the
block and place it inside the
loop.
1
3
2 Now click on the green flag
and see what happens? Play your game!!!
© LearnOBots – All Rights Reserved 2020-21
Page 21
Step 33 Next click on
icon to add a background to your game.
You can choose any background for your game.
Challenge activity: 1. Add any sound when your cat eats the mouse.
© LearnOBots – All Rights Reserved 2020-21
Page 22
Activity 3: Adding Score to the Game Now the next step is to add Score to your Game. Score should be zero when the game starts and it should increase by 1 when the cat eats the mouse. We need to create variable for this purpose.
Step 1 Go to the “Data” drawer and click on “Make a Variable” button. Write the name of your variable as “Score”.
After naming the variable, Click on OK and these blocks will be added to your Data drawer.
© LearnOBots – All Rights Reserved 2020-21
Page 23
Step 2 Now take out the
block and place it below as shown in the figure.
2 1
Step 3 Take out the
block and place it inside the
loop.
1 2 Now again click on the green Flag
and see what happens?
Š LearnOBots – All Rights Reserved 2020-21
Page 24
To play our game on full screen, click on the
icon at the top left corner and start Playing. Hurray!!
Challenge activities: 1. After 20 points, the speed of the coming mice should increase. 2. After 30 points, the size of the cat should increase.
Š LearnOBots – All Rights Reserved 2020-21
Page 25