Write Your First Computer Game!
description
Transcript of Write Your First Computer Game!
![Page 1: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/1.jpg)
Write Your First Computer Game!
![Page 2: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/2.jpg)
Coding: Programming Languages• Just like you can speak Chinese to someone
who understands Chinese to tell them what to do…• A programming language tells a computer what
to do!• During this project, we will learn how to tell a
computer how to make a fun game about a Tadpole and Frog!
![Page 3: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/3.jpg)
Big Ideas
What is Coding?
How Can you Write
Code?What is Scratch?
![Page 4: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/4.jpg)
This is Scratch!
![Page 5: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/5.jpg)
To sign up: Go to http://scratch.mit.edu
and click on Join Scratch
![Page 6: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/6.jpg)
Enter a username and password
Use your Type2Learn username and
password on the label
![Page 7: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/7.jpg)
Enter birth month and year, gender, country and e-mail
Use this e-mail address
![Page 8: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/8.jpg)
Click on Let’s Go!
Click on OK Let’s Go!
![Page 9: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/9.jpg)
Create a New Project
Click on Create
![Page 10: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/10.jpg)
Title your project
Title your project first name + last initial + 1
![Page 11: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/11.jpg)
Scratch: Stage
Stage
Like in real life, the stage is where the performance, or game happens!
![Page 12: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/12.jpg)
Scratch: Sprite
Sprite
Not the soda! An actor or a character that is on the stage, doing what you tell it to do!
![Page 13: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/13.jpg)
Scratch: Script
Scripts
This is where you tell your actor/sprite what to do!
![Page 14: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/14.jpg)
Create Tadpole and Evil Fish
Change the Stage:Choose a background
Code to make Evil Fish move randomly
Code to make Tadpole escape Evil Fish
Make it a gameEnd game when Tadpole gets caught or besomes a frog after 20 seconds of avoiding the evil fish!
![Page 15: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/15.jpg)
Delete the cat sprite
First click on the cut tool
Then click on the cat sprite
![Page 16: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/16.jpg)
Create a SpriteLet’s Get our Hero on Stage!
Click here to find our tadpole!
![Page 17: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/17.jpg)
Create a SpriteHere is our tadpole. On stage, ready to respond to our commands!
![Page 18: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/18.jpg)
The Evil FishNow lets’ get the evil fish on stage!
Choose a sprite from the
library!
![Page 19: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/19.jpg)
The Evil FishNow lets’ get the evil fish on stage!
Choose fish 2. He looks ready
to eat!
![Page 20: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/20.jpg)
Ready for Instructions!Both our actors are on stage. Now we need to tell them what to do!
![Page 21: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/21.jpg)
But first, let’s put them in the water!We need the stage to look like a pond. So let’s do that…
Choose a new backdrop!
![Page 22: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/22.jpg)
But first, let’s put them in the water!Choose “underwater” scene 1, 2, or 3!
Nature Scenes
![Page 23: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/23.jpg)
Our Tadpole and Fish are in Water
![Page 24: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/24.jpg)
Let’s Start by Giving Evil Fish instructions
Click on Evil Fish, so he knows we are telling him what to do.
Click to make him active
![Page 25: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/25.jpg)
Scripts: Instructions to your sprites
There are all sorts of script blocks. These blocks are instructions to tell your sprite what to do. We’ll start with “motion” blocks.
Make sure “motion” is selected
![Page 26: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/26.jpg)
Make Evil Fish Move Forward!
Point at “move” block and DRAG to the script area.
Choose move 10 steps
![Page 27: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/27.jpg)
Nothing Happened!You have to TELL him when to start moving!Click on Events.Drag When [green flag] clicked onto your scripts area.
Choose when green flag is clicked
![Page 28: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/28.jpg)
Move Blocks together to give instructions to your character
Now, the fish will move 10 steps when you click the green flag!
Give it a try!
Slide the blocks together!
![Page 29: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/29.jpg)
Evil Fish Doesn’t Move Very FarEach click of the green flag moves him only 10 steps. Let’s make him keep moving!
Keep pressing the green flag to see Evil Fish move 10
steps
![Page 30: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/30.jpg)
Make Evil Fish Swim ForeverGo to the CONTROL area. These are blocks that let you CONTROL your sprites even more
CONTROL options control what your sprites do
![Page 31: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/31.jpg)
Make Evil Fish Move ForeverA Forever loop tells Evil Fish to do what is inside the loop FOREVER. Till the end of time. And then keep going!
Choose Forever
![Page 32: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/32.jpg)
Make Evil Fish Move ForeverA forever loop tells Evil Fish to move 10 steps FOREVER. Till the end of time.
Give it a try!
Forever loops tell your charater to do what you say
forever and ever
![Page 33: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/33.jpg)
Uh-oh! He disappeared!Evil Fish disappeared. We have to tell him to stay on stage!
If on edge, bounce
![Page 34: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/34.jpg)
Now he’s going only back and forth… lets’ have him turn
Use the turn motion block to tell him to turn
Turn right 15 degrees
![Page 35: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/35.jpg)
Now he’s spinning. Let’s randomize it!
Random: let the computer pick a number!
Let the computer choose a number to turn Evil Fish
![Page 36: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/36.jpg)
Lets do that with the steps too!
This makes it harder to guess where Evil Fish will move next!
![Page 37: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/37.jpg)
Evil Fish is Ready for The Game!
Let’s remember to tell Evil Fish to get on stage to start
the game!
![Page 38: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/38.jpg)
Let’s Save our Progress!
Enter a name for your game
Then click SAVE NOW
![Page 39: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/39.jpg)
Time to Move The Tadpole
First, we need to select the sprite we want to give instructions to.
Click on the tadpole!
![Page 40: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/40.jpg)
Follow The Mouse!For Tadpole to escape the evil fish, we need to make her move by following the mouse pointer around.
![Page 41: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/41.jpg)
Follow The Mouse!For Tadpole to escape the evil fish, we need to make her move by following the mouse pointer around.
Uh-oh. She stopped when he moved once. How do we make her always follow the mouse pointer around?
![Page 42: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/42.jpg)
Follow The Mouse!Now tadpole will follow the mouse pointer forever.
![Page 43: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/43.jpg)
Let’s Make it a Game!
In order for a tadpole to grow into a frog, she needs to be able to avoid evil fish long enough to grow up!
Let’s make it so that Tadpole has to stay away from Evil Fish for 20 seconds to become a frog!
![Page 44: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/44.jpg)
Adding Time to The Game
First, click on your stage.
We are going to now set controls for the whole game, not just our actors/sprites
![Page 45: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/45.jpg)
Adding Time to The GameWhen the flag is clicked, we want to wait 20 seconds then alert the game that the tadpole has won!
From Control
From Sensing
![Page 46: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/46.jpg)
Adding Time to The GameAfter 20 seconds goes by, we need to send off a broadcast, which tells all the actors to pay attention and do something special!
From Events. Choose New Message
Broadcast frog
![Page 47: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/47.jpg)
Adding Time to The GameWhen the actors hear the broadcast frog we need them all to do something!
Tadpole should change into his frog costume.
Evil fish should stop swimming because the game is over!
When 20 seconds has gone by, all the actors will
hear the message frog.
![Page 48: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/48.jpg)
Tell Tadpole She Won!
Click back on Tadpole. Let’s have her respond to the frog broadcast.
Click on Event and choose When I receive . . .
Change this to be frog
![Page 49: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/49.jpg)
Make Tadpole Turn into a Frog!
Tadpole needs to change into her Frog costume
Click on New Costume and choose the Frog costume
![Page 50: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/50.jpg)
Make Tadpole Turn into a Frog!
Choose Frog, click OK
![Page 51: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/51.jpg)
Make Tadpole Turn into a Frog!
Go back to Scripts and Have Tadpole Change costumes when she receives the Frog message!
Check your work! Click the flag. Do you see the timer? Does Tadpole turn into a frog?
![Page 52: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/52.jpg)
Make Evil Fish Stop and Hide!Click back on the Evil Fish so that you can see the script for him.
Click on this last one in the list to tell the other script (the one above that is moving evil fish)
to stop running.
Check your work! Click the flag. Do you see the timer? Does Tadpole turn into a frog?
![Page 53: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/53.jpg)
Wait! Tadpole is still a Frog!We have to go back to the start and have Tadpole get her tadpole costume on!
Tells tadpole actor to start in the tadpole costume
![Page 54: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/54.jpg)
Now . . . if Tadpole swims away for 20 seconds, she turns into a frog!
![Page 55: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/55.jpg)
But wait . . .
What if Evil Fish catches Tadpole???
![Page 56: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/56.jpg)
If Tadpole touches Evil Fish . . .then she loses
An If . . .then looptells a computer: IF something happens, THEN do something
Find this in CONTROL
Let’s put that in code!
Touches the evil fish
Choose evil Fish
Find this in SENSING
![Page 57: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/57.jpg)
If touching evil fish Drag touching
onto the IF until it turns white
Let’s put that in code!
Send a message it’s game over Broadcast!
If Tadpole touches Evil Fish . . .then she loses
![Page 58: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/58.jpg)
Final instructions for tadpole
Tell tadpole what to do if she hears game over!
Tadpole hides!
If Tadpole touches Evil Fish . . .then she loses
![Page 59: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/59.jpg)
But Evil Fish wins!
Tells everyone he won
So if Evil Fish hears GAME OVER…
Tells Evil Fish to stop moving
![Page 60: Write Your First Computer Game!](https://reader035.fdocuments.in/reader035/viewer/2022062302/56816625550346895dd9814b/html5/thumbnails/60.jpg)
Final project:
http://scratch.mit.edu/projects/19135697/