float birdx=50; float birdy=50; float dx=2, dy=1; boolean falling=false; void setup() { size (640,480); } void draw() { background(150,255,255); movebird(); drawbird(birdx, birdy); } void keyPressed(){ if (key=='f') falling=true; // bird will fall when f is pressed else falling=false; //bird will fly when other key is pressed } void drawbird(float x, float y) { //draws the bird fill(0); triangle(x,y, x+35,y,x,y+20); } void movebird() { if (falling){ birdy =birdy+dy; //moves bird down when f is pressed }else{ birdx =birdx + dx; birdy =birdy + dy; } if(birdx>width) dx= -dx; // when bird touches end of right screen it changes direction if(birdy>height) dy= -dy;// when bird touches end of bottom screen it changes direction if (birdx<0) dx= -dx; // when bird touches end left of screen it changes direction if (birdy<0) dy= -dy; // when bird touches end top of screen it changes direction }