I can’t understand why triangle does not rotating.
spaceShip ship;
void setup() {
size(640, 360);
ship = new spaceShip();
}
void draw() {
background(0);
ship.render();
//ship.turn(0.1);
}
void KeyPressed() {
if (keyCode == RIGHT)
ship.turn(0.1);
if (keyCode == LEFT)
ship.turn(-0.1);
}
class spaceShip {
PVector pos = new PVector (width/2, height/2);
float r = 10;
float heading = 0;
spaceShip() {
}
void render() {
translate(pos.x, pos.y);
noFill();
stroke(255);
rotate(heading);
triangle(-r, r, r, r, 0, -r);
}
void turn(float angle) {
heading+=angle;
}
}