Can you help me with an issue

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;
  }
  
}
1 Like

Is the problem, Java is case sensitive so it should be
void keyPressed() {

4 Likes