//very simple program of animating bat and witch //variables to move the robot int rx, ry; //variables to move the car int Crx, Cry; //a function to set up the general drawing parameters void setup() { size(400, 400); background(#1B48E3); smooth(); rx = 400; ry = 100; Crx = 0; Cry = 380; frameRate(20); } //press any key to reset the bat and witch void keyPressed() { rx = 400; ry = 100; Crx = 0; Cry = 380; } //function to draw the bat void drawrobot() { fill(#313632); stroke(0); fill(#0A0000); rect(0,-20,20,20); rect(0,0,20,40); rect(0,40,5,15); rect(15,40,5,15); quad(-20,20,0,0,0,10,-25,35); quad(20,0,40,20,45,35,20,10); fill(#FA080C); rect(5,-13,5,5); rect(13,-13,5,5); } //function to draw the car void drawcar() { fill(0); //the body rect(0,10,20,10); ellipse(10,8,10,10); //wheels ellipse(3,23,5,5); ellipse(15,23,5,5); fill(#0A0000); quad(400,400,0,0,0,0,1,1); } //the draw function - which will loop void draw() { int i; i = 0; background(#1B48E3); //the ground fill(#9B895B); noStroke(); rect(0, 370, 400, 35); //the moon fill(#F0B00C); ellipse(37, 30, 50, 50); //draw the bat in an updated position using variables pushMatrix(); translate(rx, ry); scale(1.5); drawrobot(); popMatrix(); //draw the witch in an updated position using variables pushMatrix(); translate(Crx, Cry); scale(2.0); drawcar(); popMatrix(); //update my bat variables - either randomly update y rx = rx - 2; ry = ry + int(random(-5, 5)); //update my witch variables Crx = Crx + 2; Cry = Cry -2; }