I am making a test program that consists of:
- 4 buttons, up, down, left and right.
- A spaceship, formed by a Rectangle (
Rectangle
) and its respective image (Texture
).
Boton arriba,
moves up
Boton abajo
, it moves down.
Boton izquierdo
, rotates counterclockwise on itself
Boton derecho
, rotates clockwise on itself
I can't find any method to make the right and left button work. Thanks in advance.
You can also use the class
Polygon
instead ofRectangle
Unlike the rectangle, the polygon is defined according to its vertices:
In render();
Well I managed to see how to solve this simple error.
If we create the
Rectangle
we will not be able to manipulate it much, we should create aShapeRender
: We create four pointsand now in our
void draw()
We give value to radians, to the main point I give pi/2, and we are already adding its respective angle to each point. We do this with each point of the array.