Movement - Using Keys - Lakelands Computing

Title
Go to content
Making Sprites Move - Using Keys
If you are planning a game or anything similar you are going to want to control the movement of the sprites using keys so you have a playable character.

The simplest way to do this is using the point in direction and move steps commands.

This code will make the sprite move a small number of steps each time you press the key. It is good for slow moving games but less so for fast moving games as you would end up hammering the keys over and over to try and move quick enough (see this page for a method for fast games)

The directions are degrees or compass points so 0 is up, 180 is down, 90 is right, 270 or -90 is left
All Text copyright Lakelands Academy & Mr T Purslow 2020.
All images copyright free / creative commons unless otherwise stated.
You are welcome to use under a Creative Commons Attribution-nonCommercial-ShareAlike License.
All Text copyright Lakelands Academy & Mr T Purslow 2020.  All images copyright free / creative commons unless otherwise stated. You are welcome to use under a Creative Commons Attribution-nonCommercial-ShareAlike License.
All Text copyright Lakelands Academy & Mr T Purslow 2020.  All images copyright free / creative commons unless otherwise stated. You are welcome to use under a Creative Commons Attribution-nonCommercial-ShareAlike License.
Back to content