/// project 2.0 // Draw a ball, human, airplane //Locations float ballX, ballY; float humanX, humanY; float airplaneX=200, airplaneY=25; int speed=0; //location of each one void setup() { size( 640, 480 ); humanX= width/2; /// Middle humanY= height/2; ballX= width-20; ///Right lower corner ballY= height-20; } void draw() { // Next frame. scene(); action(); } void action() { // Make them move ball(); human(); airplane(); } void ball() { //// Draw a ball fill( 225, 200, 100 ); stroke( 0, 0, 150 ); smooth(0); ellipse( ballX, ballY, 25, 25 ); } void human() { // A human running to a ball humanX= humanX + (ballX-humanX)/35; humanY= humanY + (ballY-humanY)/35; // Making a human fill( 255, 255, 0 ); rectMode( CENTER ); rect( humanX, humanY, 50, 80 ); fill( 255, 200, 150 ); // head ellipse( humanX, humanY-80/2-30/2, 30, 30 ); } void airplane() { // Drawing a airplane fill(255, 255, 255); triangle( airplaneX, airplaneY, airplaneX-80, airplaneY-10, airplaneX-80, airplaneY+10 ); } void scene() { background(0, 0, 200); fill(100, 255, 100); rectMode(CENTER); rect(300, 300, 800, 430); } void mousePressed() { ballX= mouseX; // Moving a ball ballY= mouseY; background( 200, 200, 5); // lightning speed= speed + 5; }