syntax error
in
Programming Questions
•
2 years ago
Does anyone know whats wrong with this?
I made the class :
class Dog {
float xc;
float yc;
Dog(float xcoord, float ycoord) {
xc=xcoord;
yc=ycoord;
}
void display() {
fill(205,133,63);
//tail
ellipse(xcoord-80,ycoord-80, 20,0);
//body
ellipse(xcoord,ycoord,100,100);
fill(0);
//left ear
ellipse(xcoord-40,ycoord-25,75,100);
//right ear
ellipse(xcoord+40,ycoord-25,75,100);
//head
fill(205,133,63);
ellipse(xcoord,ycoord-25,75,75);
fill(255);
//left eye
ellipse(85,75,20,50);
fill(0);
ellipse(xcoord-15,ycoord-25,15,25);
//right eye
fill(255);
ellipse(xcoord+15,ycoord-25,20,50);
fill(0);
ellipse(xcoord+15,ycoord-25,15,25);
//left cheek
fill(255);
ellipse(xcoord-15,ycoord-5,30,30);
//right cheek
ellipse(xcoord+15,ycoord-5,30,30);
//nose
fill(0);
ellipse(xcoord,ycoord-5,15,15);
}
void move() {
xcoord=xcoord+100;
if(xcoord>width) {
xcoord=0;
}
}
}
float xc;
float yc;
Dog(float xcoord, float ycoord) {
xc=xcoord;
yc=ycoord;
}
void display() {
fill(205,133,63);
//tail
ellipse(xcoord-80,ycoord-80, 20,0);
//body
ellipse(xcoord,ycoord,100,100);
fill(0);
//left ear
ellipse(xcoord-40,ycoord-25,75,100);
//right ear
ellipse(xcoord+40,ycoord-25,75,100);
//head
fill(205,133,63);
ellipse(xcoord,ycoord-25,75,75);
fill(255);
//left eye
ellipse(85,75,20,50);
fill(0);
ellipse(xcoord-15,ycoord-25,15,25);
//right eye
fill(255);
ellipse(xcoord+15,ycoord-25,20,50);
fill(0);
ellipse(xcoord+15,ycoord-25,15,25);
//left cheek
fill(255);
ellipse(xcoord-15,ycoord-5,30,30);
//right cheek
ellipse(xcoord+15,ycoord-5,30,30);
//nose
fill(0);
ellipse(xcoord,ycoord-5,15,15);
}
void move() {
xcoord=xcoord+100;
if(xcoord>width) {
xcoord=0;
}
}
}
////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
so then i called it in another sketch window
Dog movDog;//declare object
void setup() {
size(500,500)
movDog = new Dog(100, 100);
}
void draw() {
background(0);
movDog.move();
movDog.display();
}
void setup() {
size(500,500)
movDog = new Dog(100, 100);
}
void draw() {
background(0);
movDog.move();
movDog.display();
}
and now it keeps highlighting
movDog = new Dog(100, 100);
and sayign syntax error maybe a semicolon, but theres a semicolon there?
and sayign syntax error maybe a semicolon, but theres a semicolon there?
Any help would be appreciated thankyou!
1