class Plane implements Drawable, Movable, Manipulable { PImage img; float posX, posY; int angle; float rotation; float power; float accel; float offset; Wind wind; Plane(int x, int y, float power, float accel, int angle) { posX = x; posY = y; this.angle = angle; this.power = power; this.accel = accel; this.offset = 0; img = loadImage("plane.png"); } void draw() { if(scene.crashed) tint(200, 0, 0); else noTint(); pushMatrix(); translate(posX, posY); rotateZ(radians(angle)); image(img, (int) -img.width/2, (int) -img.height/2); popMatrix(); } void move() { if(offset < power) offset += 1; if(offset > power) offset -= 1; posX += map(offset, 0, 100, 0, 30) * cos(radians(angle)); posY += map(offset, 0, 100, 0, 30) * sin(radians(angle)); posX %= scene.WIDTH; } void affectedBy(Effect effect) { if( ! (effect instanceof Wind) ) return; wind = (Wind) effect; } void manipulate() { posX += wind.power * cos(radians(wind.angle)); posY += wind.power * sin(radians(wind.angle)); } }