// CSC220F19DemoB_Function Parson's csc120 recap int elx, ely ; int exspeed, eyspeed ; int ewidth = 75, eheight = 50 ; // setup() called once at the start of Run void setup() { size(500, 500); // At a minimum set display window size in setup(). frameRate(60); // Must be explicit in newer Macs after setting size. elx = width / 2 ; ely = height / 3 ; exspeed = 5 ; eyspeed = -3 ; rectMode(CENTER); ellipseMode(CENTER); } // draw() is called in a loop at the frameRate, defaults to once every 60th sec. void draw() { background(255, 255, 0); // screen color, use Tools -> Color Selector, RGB display(); // function call to the display() function to display avatar move(); } void display() { // display my avatar stroke(0, 0, 255); // Sets stroke around shapes, alternatively noStroke() fill(255, 128, 0); // Sets fill within closed shape, alternatively noFill() ellipse(elx, ely, ewidth, eheight); // X, Y, Ewidth, Eheight stroke(0); fill(255); rect(elx, ely, ewidth/2, eheight/2); } void move() { // move my avatar elx = elx + exspeed ; ely += eyspeed ; if (elx > width+ewidth) { // if horizontal loc is off right side of display exspeed = - exspeed ; // reverse direction } else if (elx < 0-ewidth) { // if horizontal loc is off left side of display exspeed = - exspeed ; } if (ely < 0-eheight || ely > height+eheight) { // if vertical off top or bottom eyspeed = - eyspeed ; } }