0% found this document useful (0 votes)
2 views

class 8 scratch code

This document outlines a project for creating a game using Scratch, where players collect healthy and unhealthy food items in a bowl while managing a score and timer. It provides step-by-step instructions for selecting backdrops and sprites, creating scripts for movement and scoring, and saving the project. Additionally, it includes an activity to further enhance coding skills by moving a robot sprite and implementing similar scoring mechanics.

Uploaded by

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

class 8 scratch code

This document outlines a project for creating a game using Scratch, where players collect healthy and unhealthy food items in a bowl while managing a score and timer. It provides step-by-step instructions for selecting backdrops and sprites, creating scripts for movement and scoring, and saving the project. Additionally, it includes an activity to further enhance coding skills by moving a robot sprite and implementing similar scoring mechanics.

Uploaded by

atl.167bniketan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

PROJECT BASED

ON SCRATCH

Make a game for collecting healthy and unhealthy food in a bowl.


Learn to add score and timer in your game.

STEPS:

A.SELECT A BACKDROP

1.Click on choose a Backdrop button.

2.Click on Paint option.


3.Change Background and select rectangle for drawing base where you want
to place a bowl.

4.Select another background for Game Over Screen using paint and text
option.

2 3

4
B.SELECT A SPRITE

6.Select sprite from choose a sprite option.

7.Choose Bowl ,healthy food items (any fruit),unhealthy food items


(donut,burger ,chips etc) from sprite library option.

C.CREATE SCRIPT FOR EACH SPRITE

SCRIPT FOR BOWL


8.First Select from Sprite list and Click on code.

9.Select from event option.

10.Choose block from motion option for selecting the


initial position of sprite(bowl).

11.For repetition of code select from Control option.

12.Place 2 if condition block for left and right movement of


bowl from Control option.
For movement of Bowl in Left Direction

13. Select from Sensing Block and place it in first if

Block.

14. Select from motion block for moving bowl in left


direction.

For movement of Bowl in Right Direction

15. Select from Sensing Block and place it in Second if

Block.

16. Select from motion block for moving bowl in Right


direction.
ADD TIMER IN YOUR GAME

17.Select Make a Variable Block from Variable option for creating


Timer option.

18.You can write Timer in New variable name and Click on ok.When
you Click on o.k Timer will display on Stage area.
177

187

Script for adding Timer

19.Select from event option.

20.Choose block from looks option for selecting


background1.

21.Set Value of timer by selecting from variable option and


write value of timer in number.

22.Select from contol option for giving delay of 1 second


for changing numbers.
23.For repetition of code select from Control option and

select from operators and place before =

operator and write 0 after = operator

24.Decrease the value of timer by 1 by using from


variable option place it in repeat until block

25.Select from contol option for giving delay of 1 second


delay.

FOR CHANGING BACKGROUND WHEN TIMER VALUE SHOWS 0 VALUE


IN TIMER

26.Select from EVENT option and click on New message

option .

27.Write message name in Text Box and Click on


OK.

28. Select and Place option outside repeat until block.


29.

Select from EVENT option and place seperately in coding


area of bowl.

30.Select from LOOKS option and place it under

block.

31.Select from CONTROL option and place it after

block for stop execution after GAME OVER background.

SCRIPT FOR APPLE


32.First Select from Sprite list and Click on code.

33.Select from event option.

34.Choose block from motion option for selecting


random position of sprite(apple).

35.Select block from motion block so that apple starts


from top position.

36.For repetition of code select from Control option.

37. Select from motion block and drop it in


forever Block.

38.Place if condition block for giving condition from Control


option.

39. For giving condition in if block

,Select from operators and select from Motion


block and place it in < condition ,give value -170.
40. Repeat Step 34 and Step 35 and place it in if Block.

ADD SCORE IN GAME AND IF SPRITE TOUCHES BOWL (2 POINTS WILL


BE ADDED IN SCORE VARIABLE)

41.Repeat Step 17 and Step 18,You can write SCORE in New variable
name and Click on ok, SCORE will display on Stage area.

42.Repeat Step 33 and select from variable option for se


the value of score to 0.

43. For repetition of code select from Control option.

Place if condition block in Forever Loop.

44.For step ,select from sensing block and


place it in if condition .

45. You can add sound from from Sound Block for
adding sound after touching bowl.

46.Drag from variable block for changing the value by


2 for adding score and place it after sound option.

47.Repeat Step 34 and Step 35 and place it in if Block.


48. Repeat Step 29,30and 31.

SCRIPT FOR DONUT

49.Select from sprite list and Click on code.

50.Copy all Script of apple in donut coding.Change step 46 by changing


score by -2 when donut touches bowl.

SAVING A PROJECT

To save your project ,follow these steps:

1.Click on the File menu in the menu bar and select the Save option
from the drop-down list.
2.Choose the location where you want to save your project ant type a
suitable name in the File name box.

3.Click on the Save button.

2
3

To open a saved project ,follow these steps:

1.Click on the File menu in the menu bar and select the Load
from your computer option from the list.

2.Select the location where you saved your project.

3.Select the project and click on the Open button.


1

Good job! You have created your own game by learning code.Now
you can play game by clicking on Green Flag.

ACTIVITY

TIME

In this activity move the robot in all direction by changing costumes,


Select Star,Crystal and Lightning as Sprite.Write Code for Collecting
Star and Crystal and add score and timer as variable for showing
score and time.
(Note:If Robot Collects star and crystal five points will be added in
score but if robot collect cystal score will be reduced by point 2.)

You might also like