Computer Science Grade 5 20 min

Creating Animations

Creating Animations

Tutorial Preview

1

Introduction & Learning Objectives

Learning Objectives Use a loop with a variable to make an object smoothly grow, shrink, or move across the screen. Write a complex conditional (if/else if/else) to switch between three or more different animation states for a character. Combine user input, like a key press, with conditional logic to create interactive animations. Control the speed and timing of an animation by using 'wait' or 'delay' blocks inside loops. Create a simple 'state' variable to keep track of what a character should be doing (e.g., running, jumping, or standing still). Debug an animation where the timing is wrong or the conditional logic is not working as expected. Have you ever wondered how a character in a video game knows when to run, jump, or stand still? 🎮 Let&#...
2

Key Concepts & Vocabulary

TermDefinitionExample Animation StateThe specific action a character or object is currently performing. We use a variable to keep track of the current state.A character's state could be 'standing', 'walking', or 'jumping'. If the state variable equals 'walking', the walking animation plays. Variable-Driven AnimationUsing a variable to control a property of an animation, like its size, speed, or position. This allows the property to change over time.To make a sun rise, you can use a variable called 'sunY' for its vertical position. Inside a loop, you slowly decrease 'sunY' to make it move up the screen. Conditional AnimationUsing an 'if/else' statement to check a condition and decide which animation to play.IF the &...
3

Core Syntax & Patterns

The State Machine Pattern if (state == 'action1') { ... } else if (state == 'action2') { ... } else { ... } Use this pattern inside a 'forever' loop to constantly check a state variable. This allows your character to instantly switch between different animations (like running, jumping, or idling) based on the variable's value. The Loop & Variable Growth Pattern set [myVariable] to [startValue] repeat [number] times { change [property] by [myVariable] change [myVariable] by [increment] } Use this pattern when you want an animation property (like size or speed) to change over the course of a loop. The variable controls how much the property changes in each step. The Input and State Change Pattern when [key] is pressed { set [s...

4 more steps in this tutorial

Sign up free to access the complete tutorial with worked examples and practice.

Sign Up Free to Continue

Sample Practice Questions

Challenging
You are creating a traffic light animation that cycles from green, to yellow, to red, and back to green. Which sequence of blocks inside a 'forever' loop best represents the logic for this timed animation?
A.`set lightState to 'green'; set lightState to 'yellow'; set lightState to 'red'`
B.`show green costume; wait 3 sec; show yellow costume; wait 1 sec; show red costume; wait 3 sec`
C.`when [g] key pressed { set lightState to 'green' }; when [y] key pressed { set lightState to 'yellow' }`
D.`if (lightState == 'green') { change lightState to 'yellow' }`
Challenging
To make a character jump up and then fall back down smoothly using two loops, what would the 'change y by' value need to be in the first loop (going up) and the second loop (coming down)?
A.First loop: a positive number; Second loop: a positive number.
B.First loop: a negative number; Second loop: a positive number.
C.First loop: a positive number; Second loop: a negative number.
D.First loop: a negative number; Second loop: a negative number.
Challenging
To make the slime monster grow faster and faster, you use a variable called `growthAmount`, which starts at 1. What two blocks are needed inside the `repeat` loop to achieve this accelerating growth?
A.`change size by 10; change growthAmount by 1`
B.`change size by growthAmount; change growthAmount by 1`
C.`set size to growthAmount; set growthAmount to 1`
D.`change size by growthAmount; wait 1 second`

Want to practice and check your answers?

Sign up to access all questions with instant feedback, explanations, and progress tracking.

Start Practicing Free

More from Advanced Topics

Ready to find your learning gaps?

Take a free diagnostic test and get a personalized learning plan in minutes.