|
Computer Science Home
6th Grade Tech Ed
7th Grade Computer Science
8th Grade Computer Science A
Gmail
Google Drive
Google Classroom
Infinite Campus
Typing.com
(Join Class through Google Classroom)
Schoology
Code.org
Tynker Coding Website
Tynker Resource Page
Tynker Online Support Video Help
Quizlet | Quizlet LIVE
Everfi
Khan Academy
Social Media Tips
Netsmartz
Code HS
Karel the Dog class code: 1251
CSTA Standards
ISTE Standards
|
301 Variables (14) ***
Students will be able to:
- create local and global variables.
- add health to actors.
- add a score to a game.
Vocabulary
- Variable - a custom-designed block with its own name and value.
- Local Variable - a variable that is only used for one actor.
- Global Variable - a variable that is used for all actors in the program.
- Health - measured in health points or hit points and indicates the condition of a character or opponent in a video game.
New Tynker Code Blocks
The blocks we will be learning about in this lesson are 'Set Variable To', 'change variable by', 'less than' and 'greater than' operators, 'touching clone of' and 'touching' blocks.
1. Concepts
Let’s find out more about how to use set/change variables and local/global variables.
- Click on the 'Concepts' icon.
- Read the captions on the screen.
- Click anywhere to move to the next screen
2. Local Variables (DIY project)
- This DIY project will show your students how variables can be used for hitpoints in games.
- Hitpoints, or health, are an excellent use case for variables because they are almost always simple numbers that are being changed through addition and subtraction.
- In this case, the health variable activates the plane’s explosion animation when it reaches zero. Tell your students to notice the “hide” block at the end of the “when health < 1 occurs” code. The “hide” block ensures that the plane completely disappears after it explodes.
3. Global Variables (DIY project)
- This module will introduce the idea of using a global variable for a score. Global variables work well as scores because they can be modified by any Actor or the Stage.
- In this instance, there is only a single Actor modifying the score, but there is a second Actor reading the score. The “win” actor pops up and plays a victory message once the score is sufficiently high.
- This game is currently too simple because the plane doesn’t move and respawns in the same place it disappeared from. Tell your students to make the game more dynamic and fun!
4. Super Helicopters (puzzle)
In this puzzle we need to program the helicopters so they lose health when shot and explode when they run out of health?
Question 1: What should be in the Change/by block?
It should say "Change health by -1".
Question 2: What happens when health is less than 1?
the plane explodes.
Question 3: What keeps track of the health of the planes?
It is the 'health' variable that holds the health of the planes and is updated each time a plane is hit by a fireball.
5. Snowball Fight (DIY project)
- This game has lost most of its code! Your students will need to add most of the code themselves to make it work again.
- No draggable blocks are provided in the tutorial panels, so this module will be more of a challenge.
6. Quiz
Conclusion
In this lesson we learned how to create local and global variables in order to add health to actors and a score to a game.
U.S. Standards
|