Moving objects
In our game we would want objects to move, rotate, or just change position. That's the essence of a 2D game. So we are going to move an object across the screen and also are going to rotate it.
Rotating objects
We will create a 10 x 10 square and specify the rotation angle as 0
using the love.graphics.rotate()
function; what the code will do is make the object rotate with keyboard actions. The Boolean love.keyboard.isDown()
function is used to make keyboard inputs do certain things. Just to cause the object to rotate, we will make the rotation angle increase or decrease in delta time. math.pi
is the angular speed, which means that the object will rotate at an angular speed of 180 degrees. Replace the previous code with the next code snippet.
First of all, we can define our variables for the angle, width, and height. A variable is a name or an identifier for a place in the computer's memory where dynamic content is stored; variables store information that will be used later in...