Unexpected Character in class problem
in
Programming Questions
•
2 years ago
Ok… I just got into "Object Oriented Programing" AKA using classes and objects and I am getting an error in the class(not
surprised) and the tutorial
isn't helping
I'm trying to make it so the ship moves left and right when the arrow keys are pressed (this is the start to a game type thing)
but I get "unexpected token: ("
From other examples I have seen, you need something in the "()" in the "Ship()"
Here is the class:
class Ship {
int x // x poistion of ship
Ship() { //
THIS IS WHERE THE ERROR IS
x = 255
}
void show{
fill(255);
triangle(30+x,75,58+x,10,86+x,75);
}
void keys {
if(keyPressed && key == LEFT){
x = x + 50;
}
else if(keyPressed && key == RIGHT);{
x = x - 50
}
else(){
}
}
1