www. programming a shooter game design
DESCRIPTION
Learning Objectives – To understand how to use variables to record the direction of the character – To understand how to program the firing of a bullet from your main character. Success Criteria – To develop the platform game (started last week) so that the character can fire a bullet left and right. Literacy – Key Words Variable‘Storage box’ used in programming to store data SpriteProgrammable objects in Scratch ScriptsBlocks of programming code in ScratchTRANSCRIPT
![Page 1: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/1.jpg)
www.computerscienceuk.com
Programming a Shooter
Game Design
![Page 2: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/2.jpg)
www.computerscienceuk.com
Starter• On your whiteboards write down an
example script block to get a sprite moving right when the right arrow is pressed.
![Page 3: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/3.jpg)
www.computerscienceuk.com
Learning Objectives• Learning Objectives
– To understand how to use variables to record the direction of the character
– To understand how to program the firing of a bullet from your main character.
• Success Criteria– To develop the platform game (started last week) so that the
character can fire a bullet left and right.
Literacy – Key WordsVariable ‘Storage box’ used in programming to store dataSprite Programmable objects in ScratchScripts Blocks of programming code in Scratch
![Page 4: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/4.jpg)
www.computerscienceuk.com
Hands up if you know how to program a shooter in Scratch?
![Page 5: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/5.jpg)
www.computerscienceuk.com
What needs to happen to create a shooter? Planning
1. We need a main character2. We need an object to fire
3. We need out object to follow (attach to) the main character
4. When the cat is facing right, we want the object to move to the right when we press space
5. When the cat is facing left, we want the object to move to the left when we press space
![Page 6: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/6.jpg)
www.computerscienceuk.com
How can we record if the character is facing right of left?
Answer:We can use a variable which can be set to:
0 when the left arrow key is pressed1 when the right arrow key is pressed
![Page 7: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/7.jpg)
www.computerscienceuk.com
1. Use a variable to record which way the main sprite is facing1
2
3
Main
Character!!
![Page 8: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/8.jpg)
www.computerscienceuk.com
Whiteboard Practice• Write the script to move the sprite left
when the left arrow is pressed. The script must also set a variable to 0 (so that the direction can be recorded)
![Page 9: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/9.jpg)
www.computerscienceuk.com
Whiteboard Practice…again• Write the script to move the sprite
right when the right arrow is pressed. The script must also set a variable to 1 (so that the direction can be recorded)
![Page 10: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/10.jpg)
www.computerscienceuk.com
Demonstration of Shooter
How is this done?
![Page 11: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/11.jpg)
www.computerscienceuk.com
2. Program the shooter (object firing)
After we press the green flag
We check if the space is pressed
If it is and the direction is left (0), the bullet points to the left (-90), it is shown and it moves 10 steps.
This is repeated until the bullet hits the edge of the stage.
If the space is pressed and the direction is right (1), the bullet points to the right (90), it is shown and it moves 10 steps.
This is repeated until the bullet hits the edge of the stage.
If however, the space is not pressed, the bullet hides and stays permanently with the main character.
![Page 12: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/12.jpg)
www.computerscienceuk.com
Hands up if you know how to program a shooter in Scratch?
![Page 13: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/13.jpg)
www.computerscienceuk.com
Write down on your whiteboard, in your own words, how this script works
3 minutes
![Page 14: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/14.jpg)
www.computerscienceuk.com
2. Program the shooter (object firing)
After we press the green flag
We check if the space is pressed
If it is and the direction is left (0), the bullet points to the left (-90), it is shown and it moves 10 steps.
This is repeated until the bullet hits the edge of the stage.
If the space is pressed and the direction is right (1), the bullet points to the right (90), it is shown and it moves 10 steps.
This is repeated until the bullet hits the edge of the stage.
If however, the space is not pressed, the bullet hides and stays permanently with the main character.
![Page 15: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/15.jpg)
www.computerscienceuk.com
Programming Task 1 and 2Open the Lesson Task Sheet and complete the tasks
’20 Minutes’
1. Open your semi completed game from last week (a sprite that jumps from platform to platform).
2. Create a variable (call it direction) and adapt your movement scripts so that direction = 0 when the left arrow is pressed and direction = 1 if the right arrow is pressed. Then print screen your script and explain how it works in the worksheet.
3. Create a bullet sprite.
4. Add a script to your bullet sprite so that it follows the main character (hidden) and fires in the correct direction when a key of your choice is pressed. Then print screen your script and explain how it works in the worksheet.
Use this presentation for support if you require it.
![Page 16: Www. Programming a Shooter Game Design](https://reader036.vdocuments.us/reader036/viewer/2022082601/5a4d1b797f8b9ab0599b83b2/html5/thumbnails/16.jpg)
www.computerscienceuk.com
Assessment CriteriaLevel Programming Skills
7• I fully understand how the script programs the shooter and
my explanations are detailed and clearly show my understanding.
• I can create the correct script blocks without help.• I can see how other objects can be programmed in a similar
way.
6• I understand how the scripts programs the shooter and my
explanations are detailed and clearly show my understanding.
• I can create the correct script blocks without help.
5• I generally understand how the scripts create the shooter
but my explanation is brief and not that clear.• I can create the correct script blocks but do need a little
help from the help guides.
4• I don’t fully understand how the scripts program the
shooter.• I struggle to make the correct script blocks to program the
shooter.