0% found this document useful (0 votes)
63 views1 page

Keyboard Input #6 Unit 3 - Interactive Animations and Games ('24-'25)

Lesson 16 focuses on keyboard input for sprite movement in a simple game. It instructs users to use if statements with keyDown() to move a sprite left or right on the screen. The lesson includes code snippets and examples for implementing these movements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views1 page

Keyboard Input #6 Unit 3 - Interactive Animations and Games ('24-'25)

Lesson 16 focuses on keyboard input for sprite movement in a simple game. It instructs users to use if statements with keyDown() to move a sprite left or right on the screen. The lesson includes code snippets and examples for implementing these movements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Share Remix Lesson 16: Keyboard Input

Saved 3 days ago


6



MORE
Martin  

Code Animation  Instructions Help & Tips Rubric % ▶

Move in All Directions

You can use if () statements with the keyDown() to make a simple game that moves a sprite around the screen.

Do This 
 Toolbox ⚙ Workspace # Version History  Show Text

 World Sprites
1 var backdrop = createSprite(200,200) → ;
Drawing Control
2 backdrop.setAnimation( "rainbow");
Math Variables
3 var flyer = createSprite(200,200) → ;
function draw() {} → 4 flyer.setAnimation( "wing_bot");
drawSprites() 5
6 function draw() { →
keyDown(code)
7
World.mouseX 8 //1) Add code to move the sprite left when the left arrow is pressed
World.mouseY 9 if ( keyDown( "left") ) {
Show grid World.frameRate
Reset Finish 10 flyer.x = flyer.x - 4 ;
// Comment
11 } +
12
13 //2) Add code to move the sprite right when the right arrow is pressed
14 if ( keyDown( "right") ) {

} +


% English  © Version: 2024  Debug Console  Debug Sprites: Off  Clear Watchers 

You might also like