The player should be able to move at least in three ways: forward, backward, and turning. The player's position is defined by a coordinate and a viewing angle. To allow motion, two more attributes are needed. They are the player's movement speed, and the player's turning speed. The player's movement speed defines how many units the player should move when he/she is moving forward or backward. The player's turning speed (measured in angle) defines how many angle to be added or subtracted when the player is turning. We will discuss each how we use these attributes to allow motion.
We define the player's movement speed to be 10 units. (Generally, this can be any number, but the larger number, the less smooth the movement will appear.) The process of finding the x and y displacement is illustrated below. If the player is moving forward, we add the XDisplacement to the current player's X coordinate; and add Ydisplacement to the current player's Y coordinate. If the player is moving backward, we subtract the XDisplacement to the current player's X coordinate; and subtract Ydisplacement to the current player's Y coordinate. (Always check for world/wall boundaries so that the player won't go outside the map or walk through a wall.)