What is wrong with this Car class?
in
Programming Questions
•
8 months ago
I was trying the OOP tutorial and just copying the tutorial code exactly i still had errors, is there anything wrong with the code here?:
class Car {
color c;
float xpos;
float ypos;
float xspeed;
void setup() {
Car() {
c = color(255);
xpos = width/2;
ypos = height/2;
xspeed = 1;
}
}
void draw() {
background(0);
display();
drive();
}
void display() {
rectMode(CENTER);
fill(c);
rect(xpos,ypos,20,10);
}
void drive() {
xpos = xpos + xspeed;
if (xpos > width) {
xpos = 0;
}
}
}
1