Hey PacMan, stop running off the screen where I can’t see you, ma bitch!
/* Pac-Man */
Pacman pacMan = new Pacman(8, 10, 10, 20, 20, radians(45), radians(315));
Redguy redGuy;
Pinkguy pinkGuy;
Blueguy blueGuy;
Slowguy slowGuy;
void setup() {
redGuy = new Redguy();
pinkGuy = new Pinkguy();
blueGuy = new Blueguy();
slowGuy = new Slowguy();
size(620, 560);
background(0);
frameRate(30);
}
void draw() {
pacMan.drawPM();
pacMan.update();
}
class Pacman {
int PacmanRadius, PMXpos, PMYpos, PMWidth, PMHeight;
float PMStart, PMStop;
Pacman(int a, int b, int c, int d, int e, float f, float g) {
// PacManRadius = a;
PMXpos = b;
PMYpos = c;
PMWidth = d;
PMHeight = e;
PMStart = f;
PMStop = g;
}
void update() {
arc(PMXpos, PMYpos, PMWidth, PMHeight, radians(PMStart), radians(PMStop));
fill(255, 255, 0);
}
void drawPM() {
if (keyPressed) {
if (key == ‘a’ || key == ‘A’) {
PMStart = 225;
PMStop = 495;
background(0);
if (PMXpos > PMWidth/2){
PMXpos -= 10;} else {
}
}
if (key == ‘d’ || key == ‘D’) {
PMStart = 45;
PMStop = 315;
background(0);
if (PMXpos < width-(PMWidth/2)){
PMXpos += 10;} else {
}
}
if (key == ‘w’ || key == ‘W’) {
PMStart = 315;
PMStop = 585;
background(0);
if (PMYpos > PMHeight/2){
PMYpos -= 10;} else {
}
}
if (key == ‘s’ || key == ‘S’) {
PMStart = 135;
PMStop = 405;
background(0);
if (PMYpos < height-(PMHeight/2)){
PMYpos += 10;} else {
}
}
else {
}
}
}
}
class Redguy extends Ghost {
}
class Pinkguy extends Ghost {
}
class Blueguy extends Ghost {
}
class Slowguy extends Ghost {
}
class Ghost {
}