//Walking Pac man V2 - setting boundaries // Copyright © 2014 Jia Tao // Bryn Mawr College, Department of Computer Science // Permission is granted to copy and distribute provided // this entire copyright notice is reproduced in all copies. boolean walkPose = false; boolean left = true; float speed = 5.0; float cX = 100.0; float cY = 100.0; float r = 40.0; color yellow = color(255, 255, 0); void setup() { size(500, 500); smooth(); frameRate(20); strokeWeight(2); } void draw() { background(255); fill(yellow); //pacman's body if (left==false) { arc(cX, cY, r*2, r*2, PI/6, 11*PI/6, PIE); } else { arc(cX, cY, r*2, r*2, 7*PI/6, 17*PI/6, PIE); } //pacman's eye fill(0); ellipse(cX, cY-20, 10, 10); if (walkPose==true) { //pacman's legs line(cX, cY+r, cX+15, cY+r+15); line(cX, cY+r, cX-15, cY+r+15); } else { line(cX, cY+r, cX+5, cY+r+20); line(cX, cY+r, cX-5, cY+r+20); } } void keyPressed() { if (keyCode == UP) { walkPose = !walkPose; if (cY-r >0 ) { cY -= speed; } } else if (keyCode == DOWN) { walkPose = !walkPose; if (cY+r+200) cX -= speed; } else if (keyCode == RIGHT) { walkPose = !walkPose; left = false; if (cX+r