0% found this document useful (0 votes)
42 views18 pages

Scratch Coding

Uploaded by

fredricmuriuki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views18 pages

Scratch Coding

Uploaded by

fredricmuriuki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Scratch Coding: Chrome Dinosaur game

Tutorial plan
1- What is the Chrome Dinosaur game ?

2- Set Up the Chrome Dinosaur game in Scratch

What is the Chrome Dinosaur game ?


The Chrome Dinosaur Game, also known as "Dino Runner" or "T-Rex
Game", is a built-in offline mini-game in the Google Chrome browser.
It appears when your device is not connected to the internet.

In the game, you control a pixelated T-Rex dinosaur running through


a desert. Your goal is to avoid obstacles such as cacti and flying
pterodactyls by jumping or ducking. The game speeds up the longer
you survive, making it more challenging over time. The game ends
when the dinosaur hits an obstacle.

How It Works ?

- The dinosaur runs automatically.

- Press space bar or up arrow to make it jump.

- You need to avoid obstacles like Cactus

- The game gets faster over time.

- It continues until the player crashes.

Set Up the Chrome Dinosaur game in Scratch


Step 1: Prepare the game background

The background of the Dinosaur Game in Scratch is designed to


closely resemble the simple, retro style of the original Google
Chrome Dino Game. It features a minimalist desert landscape, using
a white or light gray sky and a straight black ground line to give the
illusion of endless running.

1) Go to import a background to add the space image.


2) Choose the image for the game background :

Meilleures consoles de jeux vidéo

Step 2: Creation of the Dinosaur sprite

The dinosaur typically has a cute, cartoon-like appearance, making it


appealing for younger users. It’s more detailed and colorful than the
pixelated Chrome Dino version.

1) Go to import a sprite to add the Dinosaur image.


2) Choose the Dinosaur-1 image:

3) Added costumes to Dinosaur sprite

Scratch dinosaur sprites often include multiple costumes to animate


movement, actions, and expressions. These costumes help bring the
character to life in games and stories.

Best video game consoles


a) At the top of the screen, click on the “Costumes” tab (next to
"Code" and "Sounds").
b) Click the “Upload Costume” icon (arrow pointing up).
c) Choose images from your computer.
We obtain a Dinosaur sprite containing 4 costumes
4) Added sound files to Dinosaur sprite

Sound files play an important role in enhancing the user experience


when creating a Sprite Dinosaur game.

Meilleures consoles de jeux vidéo


Jump Sound: When the dinosaur jumps, a short sound indicates the
action was registered.

Collision/Crash Sound: When the dinosaur hits an obstacle (like a


cactus), a sound effect alerts the player of game over.

a) Click the "Sounds" tab at the top (next to "Costumes").

b) Click the "Choose a Sound" button (speaker icon in the bottom


left)

Meilleures consoles de jeux vidéo


c) Import a custom .wav or .mp3 file from your computer
We obtain the sound files in Dinosaur sprite :
5) Script for the Dinosaur sprite
5) Explanation of Each Block

Block Role

This block is used to start script automatically


when the user clicks the green flag

This block places the Dinosaur at its starting position when the game begins

Meilleures consoles de jeux vidéo

The Forever block is used in the Dinosaur sprite


to handle jumping and detecting the cactus

The if block lets the dinosaur react


when it detect the cactus

The touching [Cactus] block is used to detect collisions between the Dinosaur and the Cactus obstacle.

The costume changes to dino-dead

This block sends a message to Cactus sprite

The say block is used to display "Game Over!" on the screen

Best video game consoles

This block is used to play a sound effect


when the dinosaur collides with a cactus

This block is used to pause after a collision before ending the game

Meilleures consoles de jeux vidéo

We use "the stop all" block to end the game

Meilleures We use an if else block to check if the space key is pressed.


consoles de
jeux vidéo

This block is used to detect when the player presses the space bar

This block is used to play a jump sound each time the dinosaur jumps

This block is used to Make the dinosaur look like it's jumping by switching to a special jumping costume

We use this block to makes the Dinosaur face up

This block makes the Dinosaur glide upward,


like it's jumping.

This block is used to create a delay


between going up and coming back down.

This block makes the Dinosaur sprite face down

This block can is used to make the Dinosaur move downward

This block is used To simulate Dinosau rwalking


This block is used To simulate Dinosau rwalking

Step 3: Creation of the Cactus sprite

A cactus sprite typically refers to the graphical object used in a game


(like the one in the Google Chrome "Dino Game") to represent a
cactus as an obstacle.

1) Go to import a sprite to add the Cactus image.

2) Choose the cactus-1 image:


3) Added costumes to Cactus sprite

We use costumes in a Cactus sprite in Scratch to create variation and


increase game difficulty or visual interest

a) At the top of the screen, click on the “Costumes” tab (next to


"Code" and "Sounds").
b) Click the “Upload Costume” icon (arrow pointing up).
c) Choose images from your computer.
We obtain a Cactus sprite containing 3 costumes

4) Script for the Cactus sprite


5) Explanation of Each Block

Block Role

This block is used to start script automatically


when the user clicks the green flag

The show block makes the Cactus sprite appear on the Stage.

This block places the Cactus at its starting position when the game begins

Initialize the score variable

Initialize the stop variable

This block makes the Cactus continuously move,check for collisions, or keep appearing during thegame.

This block is a control block that lets the Cactus sprite choose between two actions

This block is a sensing block that checks if the Cactus is touching the edge of the Stage.

This block makes the Cactus move smoothly


from right to left

This block used at the end of a glide makes the Cactus look different each time it appears

The if block checks if the cactus touches the Dinosaur

This block is used to checks if the variable stop is equal to 0

This block increments the score variable

You might also like