I am new to processing, I am working on a Pacman assignment and finding it quite difficult, if anyone can help me I would be very grateful.
So far I have managed to create a Pacman class and object which moves with KeyPressed via the arrow keys, I have managed to create a class for the dots and created the object, covering the canvas with ellipses similar to a gird. I do not know how to make Pacman eat the dots, once in contact, I have attempted a boolean and if statement, but I am not sure what I have done wrong, the program runs. I also have not been able to make Pacman face the direction he is moving in.
Here is all of the code to better explain
// main program
float cx = 250,
cy = 250,
dx = 0,
dy = 0;
PImage Pac;
Pacman P1;
Food F;
int Fx,
Fy,
S,
G;
void setup() {
size(500, 500);
Pac = loadImage ("Pacman 48x48px.png");
P1 = new Pacman (cx, cy, dx, dy, Pac);
F = new Food (Fx, Fy, S, G);
}
Food (int Fx, int Fy, int S, int G){
this.Fx= Fx;
this.Fy = Fy;
this.S = S;
this.G = G;
}
void Draw () {
G = 30;
S = 10;
for(int Fx = 0; Fx <= width; Fx += G){
for(int Fy = 0; Fy <= height; Fy += G){
ellipse (Fx, Fy, S, S);
fill (White);
stroke (Red);
}
}
}
}
color Yellow = color(255, 255, 0);
color Red = color(255, 0, 0);
color Green = color(0, 255, 0);
color Black = color(0, 0, 0);
color White = color(255, 255, 255);
color Blue = color(0, 0, 255);
color Orange = color(255, 127, 0);
This is all the code I have managed to do, if anyone can guide me or show me how to make Pacman at least make the dots disappear when they both come in contact I would be very grateful. Apologies if I am unclear or ambiguous on my problem.