Lesson: 2D Motion
Time: 45+ mins
IntroductionIn this lesson, campers will learn how to make Actors follow the mouse-pointer (for web) or user's touch location (for mobile) and go to specific x-y locations on the screen. They'll also learn how to create their own Obstacle Course game! Coding concepts include go to and operators.
- Computer, laptop, or tablets (1 per camper)
New Code Blocks
: Start the program when the play button is selected. : Keep repeating the blocks inside this loop forever. : If the condition is true, then run the code inside the block. : Move the Actor to the specified x- and y-coordinates on the Stage. : This is an addition operator that returns the sum of the two parameters. : Make the Actor switch to the next costume. : Pause the program for a specific number of seconds. : React when the specified parameter is detected. : Broadcast a message to all Actors in the program. : Stop running the current script. : Point the Actor towards the specified parameter.
- Coding: Using a computer language to tell the computer what to do
- Sequence: The order in which steps or events happen
- Actors: Tynker characters and objects that can talk and interact with each other
- Costume: Different appearances for an Actor, such as poses used in a character’s animation
- Command: A specific action or instruction that tells the computer to do something
- Loop: An action that repeats one or more commands over and over
- Infinite loop: A loop that repeats forever and does not end until the program stops
- Condition: A logical expression that evaluates to true or false
- Conditional statement: A type of statement that executes different parts of the code based on whether a logical expression evaluates to true or false
- Use code blocks to move Actors to specified locations
- Apply coding concepts to solve a puzzle
- Create an Obstacle Game project
Getting Started (5 minutes)
- Ask if anyone can think of a game where Actor continuously follows the mouse-pointer or user's touch location (for example, slither.io). Next, tell campers that they're going to be creating their own games where the Actor follows their mouse-pointer (for web) or touch location (for mobile).
- Optional: Prepare campers for today's Obstacle Course project by asking them to sketch out a race track with obstacles. What kind of obstacles are they going to use? Is there an object at the finish line? Point out to campers that they don't have to draw a race car. For example, their game can be about a dog avoiding obstacles to get to its bone at the end of the track.
Coding Activities (40+ minutes)The lessons are intended for self-directed learning. Your role will be to facilitate as campers complete the 2D Motion modules on their own:
1. Introduction (Video)
- Campers will watch a short video of space aliens helping an astronaut.
- A friendly astronaut introduces two coding concepts:
- Go to- Campers will learn that the "go to" code block can be used to move an Actor to any part of the screen.
- Operators- Campers will watch different examples of operators. The space human points out that operators can be used for arithmetic operations such as add, subtract, multiply, and divide.
- In this tutorial, campers will learn how to make an animated Actor go to a specific x-y location on the Stage.
- Coding activities include adding a space background, spaceship Actor, and costumes. Additionally, campers will need to animate the spaceship to look like it's hovering and program it to start at the location (50,50).
- Make sure campers are manually typing the values for the "wait" and "go to x-y" code blocks.
- Remind campers that an animation is created by switching between costumes.
- In this tutorial, campers will learn how to make two animated ships fly and follow a mouse-pointer (for web) or user's touch location (for mobile).
- Activities include adding a space background, animating the spaceships, and programming the spaceships to follow the mouse-pointer (for web) or user's touch location (for mobile).
- Point out to campers that they need to offset the ship2 Actor's code by -150 so it is beside and not on top of ship1.
- To solve this puzzle module, campers need to program the spaceships to follow the mouse-pointer (for web)/ user's touch location (for mobile).
- Give a hint: Ask campers…
- What code blocks can we use to make the spaceship continuously follow the mouse-pointer (for web) or user's touch location (for mobile)? (Answer: Go to mouse x, mouse y.)
- Why does the bad guy spaceship need to be offset by -150? (Answer: If the -150 wasn't there, the ships would be right on top of each other.)
- In this DIY (do-it-yourself) project, campers will follow step-by-step directions to create their own obstacle game where the car Actor follows the mouse-pointer (for web) or user's touch location (for mobile) while avoiding obstacles.
- Step 1 of the tutorial tab provides a completed project example. How to play: Use the mouse-pointer (for web) or user's touch location (for web) to navigate the car while avoiding obstacles.
- Coding activities include changing the background, adding Actors, programming the car Actor to follow the mouse-pointer (for web) or user's touch location (for mobile), designing an obstacle course, and adding a goal Actor at the end of the course.
- Step 8 of the tutorial includes a bonus section that encourages campers to add moving obstacles or a timer.
- If campers finish early, ask them to add sound effects, background music, special effects, or draw their own Actors.
Wrap UpUnplugged Activity: Discussion
Review today’s coding adventure by leading a discussion. Ask campers:
- What does the "go to x-y" code block do? (Answer: Moves an Actor instantly to the specified x-y location on the Stage.)
- What do the math operators do? (Answer: Allow you to perform mathematical operations like addition, multiplication, and subtraction in your programs)
- What kind of obstacles did you add to your obstacle game? How did you customize your project? Did anyone complete the bonus activity?
These student-facing slide presentations help educators seamlessly run Tynker lessons in a virtual or physical classroom setting. Each lesson has its own set of slides that introduce the big ideas, suggest unplugged activities, and include a section for each activity module. While running lesson slides, you can switch back and forth between the activity, the slides, answer keys and other lesson materials.
A sample slide presentation is available for your review. Please log in to view all the class presentations available with your plan..
Lights, Music, Action
Make Games - Animated Greeting Card
Make Games - Music Video
Make Games - Maze Game
Make Games - 2-Player Battle Game
Make Games - Animated Story