In this video, you'll program
the sprite to turn when the arrow keys are pressed.
To start, select events and drag out
two when key pressed blocks.
Change their values in the drop down
to left arrow and right arrow.
For motion, add the appropriate turn blocks to teach arrow.
Press the right and left arrow keys to test.
Cool.
The sprites turn when the arrow key is pressed,
but they don't turn smoothly.
To fix this, you will program the sprite to repeat turning
until the arrow key is no longer being pressed.
This will make the sprite turn smoothly
when the key is pressed and held down.
Click control and add a repeat until block
around one of the turns.
Because you'll have to program this twice,
it's a good idea to try it on one turn,
see if it works, then copy the code for the other turn.
Clock operators and add a not block
into the repeat until block.
From sensing add a key pressed block
and change the value to the correct arrow key.
Test your code.
If you stop the game with the player sprite in the corner,
it stays there even when a new game is started.
To fix this, add a go to block at the beginning of the code.
Change the value of this block to a position
on the left side of the stage.
Now test the code again.
Perfect!
Finally, test the entire program to make sure
that it works the way you want it.
Tinker with the values in the move blocks
to make sure that the sprite is moving
and turning at a speed that works for your game.
Adjusting these can make your game a lot easier
or a lot harder, it's up to you.
In the next video, you'll program this game
to level up with spawning enemies.
Now it's your turn.
Program the arrow keys to turn the sprite right and left,
then make the sprite turn smoothly using
repeat until, key pressed, and not blocks.