Keyboard Input #6 Unit 3 - Interactive Animations and Games ('24-'25)
Keyboard Input #6 Unit 3 - Interactive Animations and Games ('24-'25)
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