We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm having an issue where Processing is telling me that function move does not exist. I believe that this is linked to the other issue that I'm getting which is variable x and variable y do not exist. For the life of me, i am unable to see the issue. If any of you are able to show me what my issue is or even point me in the right direction I would be eternally grateful. Thank you for your time and advice. I apologize in advance there is a lot of code but I wasn't sure if the issue could be solved if I only posted bits and pieces.
Ghost Blinky;
Ghost Inky;
Ghost Pinky;
Ghost Clyde;
Pac Man;
void setup() {
size(800, 800);
smooth();
Blinky = new Ghost(color(255, 0, 0), 0, 60, 2, 1);
Inky = new Ghost(color(0, 233, 252), 0, 60, 3, 2);
Pinky = new Ghost(color(248, 0, 252), 0, 60, 1, 3);
Clyde = new Ghost(color(252, 80, 0), 0, 60, 2, 4);
Man = new Pac(color(254, 255, 8), 0, 60, 3, 1);
}
void draw() {
background(255);
Blinky.move();
Blinky.display();
Inky.move();
Inky.display();
Pinky.display();
Pinky.move();
Clyde.display();
Clyde.move();
Man.display();
Man.move1();
}
class Ghost {
color c;
float x = 80;
float y = 60;
float speedX;
float speedY;
Ghost(color vC, float Xpos, float Ypos, float Xspeed, float Yspeed) {
c = vC;
x = Xpos;
y = Ypos;
speedX = Xspeed;
speedY = Yspeed;
}
}
class Pac {
color b;
float xX = 80;
float yY = 60;
float speedX;
float speedY;
Pac(color cB, float Xpos, float Ypos, float Xspeed, float Yspeed) {
b = cB;
xX = Xpos;
yY = Ypos;
speedX = Xspeed;
speedY = Yspeed;
}
}
void display() {
fill(c);
// Ghost Body
beginShape();
vertex(x - 20, y - 50);
vertex(x - 20, y - 40);
vertex(x - 30, y - 40);
vertex(x - 30, y - 30);
vertex(x - 40, y - 30);
vertex(x - 40, y - 25);
vertex(x - 50, y - 25);
vertex(x - 50, y - 13);
vertex(x - 55, y - 13);
vertex(x - 55, y + 51);
vertex(x - 47, y + 51);
vertex(x - 47, y + 60);
vertex(x - 35, y + 60);
vertex(x - 35, y + 51);
vertex(x - 25, y + 51);
vertex(x - 25, y + 43);
vertex(x - 20, y + 43);
vertex(x - 20, y + 51);
vertex(x - 10, y + 51);
vertex(x - 10, y + 60);
vertex(x + 5, y + 60);
vertex(x + 5, y + 51);
vertex(x + 10, y + 51);
vertex(x + 10, y + 43);
vertex(x + 20, y + 43);
vertex(x + 20, y + 51);
vertex(x + 25, y + 51);
vertex(x + 25, y + 60);
vertex(x + 40, y + 60);
vertex(x + 40, y + 51);
vertex(x + 45, y + 51);
vertex(x + 45, y);
vertex(x + 40, y);
vertex(x + 40, y - 10);
vertex(x + 35, y - 10);
vertex(x + 35, y - 30);
vertex(x + 30, y - 30);
vertex(x + 30, y - 40);
vertex(x + 20, y - 40);
vertex(x + 20, y - 50);
vertex(x - 20, y - 50);
endShape();
fill(255, 255, 255);
// Right EYE
beginShape();
vertex(x + 30, y - 40);
vertex(x + 20, y - 40);
vertex(x + 20, y - 30);
vertex(x + 10, y - 30);
vertex(x + 10, y - 10);
vertex(x + 20, y - 10);
vertex(x + 20, y);
vertex(x + 30, y);
vertex(x + 30, y - 10);
vertex(x + 35, y- 10);
vertex(x + 35, y - 30);
vertex(x + 30, y - 30);
vertex(x + 30, y - 40);
endShape();
fill(255, 255, 255);
//LEFT EYE
beginShape();
vertex(x - 10, y - 30);
vertex(x - 20, y - 30);
vertex(x - 20, y - 40);
vertex(x - 30, y - 40);
vertex(x - 30, y - 30);
vertex(x - 40, y - 30);
vertex(x - 40, y - 10);
vertex(x - 30, y - 10);
vertex(x - 30, y);
vertex(x - 20, y);
vertex(x - 20, y - 10);
vertex(x - 10, y - 10);
vertex(x - 10, y - 30);
endShape();
fill(0, 0, 0);
// LEFT PUPIL
beginShape();
vertex(x - 10, y - 30);
vertex(x - 20, y - 30);
vertex(x - 20, y - 20);
vertex(x - 10, y - 20);
vertex(x - 10, y - 30);
endShape();
fill(0, 0, 0);
//RIGHT PUPIL
beginShape();
vertex(x + 35, y - 30);
vertex(x + 25, y - 30);
vertex(x + 25, y - 20);
vertex(x + 35, y - 20);
vertex(x + 35, y - 30);
endShape();
// Pac Man
fill(230, 247, 5);
beginShape();
vertex(xX + 48, yY);
vertex(xX + 48, yY - 10);
vertex(xX + 42, yY - 10);
vertex(xX + 42, yY - 15);
vertex(xX + 36, yY - 15);
vertex(xX + 36, yY - 23);
vertex(xX + 25, yY - 23);
vertex(xX + 25, yY - 30);
vertex(xX - 29, yY - 30);
vertex(xX - 29, yY - 22);
vertex(xX - 37, yY - 22);
vertex(xX - 37, yY - 15);
vertex(xX - 45, yY - 15);
vertex(xX - 45, yY - 7);
vertex(xX - 55, yY - 7);
vertex(xX - 55, yY + 2);
vertex(xX - 61, yY + 2);
vertex(xX - 61, yY + 60);
vertex(xX - 55, yY + 60);
vertex(xX - 55, yY + 70);
vertex(xX - 47, yY + 70);
vertex(xX - 47, yY + 75);
vertex(xX - 40, yY + 75);
vertex(xX - 40, yY + 85);
vertex(xX - 29, yY + 85);
vertex(xX - 29, yY + 95);
vertex(xX + 25, yY + 95);
vertex(xX + 25, yY + 85);
vertex(xX + 30, yY + 85);
vertex(xX + 30, yY + 75);
vertex(xX + 43, yY + 75);
vertex(xX + 43, yY + 68);
vertex(xX + 48, yY + 68);
vertex(xX + 48, yY + 60);
vertex(xX + 35, yY + 60);
vertex(xX + 35, yY + 50);
vertex(xX + 20, yY + 50);
vertex(xX + 20, yY + 43);
vertex(xX + 10, yY + 43);
vertex(xX + 10, yY + 35);
vertex(xX - 5, yY + 35);
vertex(xX - 5, yY + 25);
vertex(xX + 10, yY + 25);
vertex(xX + 10, yY + 18);
vertex(xX + 20, yY + 18);
vertex(xX + 20, yY + 8);
vertex(xX + 30, y + 8);
vertex(xX + 30, yY);
vertex(xX + 48, yY);
endShape();
// Power Pellet
fill(255);
beginShape();
vertex(xX + 90, yY + 20);
vertex(xX + 80, yY + 20);
vertex(xX + 80, yY + 30);
vertex(xX + 70, yY + 30);
vertex(xX + 70, yY + 40);
vertex(xX + 80, yY + 40);
vertex(xX + 80, yY + 50);
vertex(xX + 90, yY + 50);
vertex(xX + 90, yY + 40);
vertex(xX + 100, yY + 40);
vertex(xX + 100, yY + 30);
vertex(xX + 90, yY + 30);
vertex(xX + 90, yY + 20);
endShape();
}
void move() {
x = x + speedX;
y = y + speedY;
// SETS THE BOUNDARIES for Ghosts
if ( x > width)
{
speedX = - speedX;
} else if ( x < 1)
{
speedX = - speedX;
} else if ( y > height)
{
speedY = - speedY;
} else if ( y < 1)
{
speedY = - speedY;
}
}
void move1() {
xX = xX + speedX;
yY = yY + speedY;
// SETS THE BOUNDARIES for Ghosts
if ( xX > width)
{
speedX = - speedX;
} else if ( xX < 1)
{
speedX = - speedX;
} else if ( yY > height)
{
speedY = - speedY;
} else if ( yY < 1)
{
speedY = - speedY;
}
}
Answers
The way you are calling this it is expecting move() to be a method within the Clyde instance of the Ghost class, which is where it should be.
But your move() is at the same level as setup and draw, not part of the class...
note the classes (Dog, Cat) traditionally start with a Capital but instances (fido, fluffy) don't.
(look closely and you'll see that your ghost and your pacman are the same...(apart from how they appear))