Vehicle mysteriously getting longer?

For school I have to make a "vehicle class" which just has to move and show itself. For some reason when I run it, it gets longer for no apparent reason.

Here's the relevant code: `class vehicle{ int xPos; int yPos; int direction; vehicle(int tempYpos){ xPos = 10; yPos = tempYpos; direction = 0; }

void display(){ fill(0,0,255); rect(xPos,yPos,xPos+10,yPos+10); } void move(){ if(direction == 0){ //East xPos++; }

else if(direction == 1){ //West xPos--; } else if(direction == 2){ //North yPos++; } else if(direction == 3){ //South yPos--; } } void turnSouth(){ direction = 3; } void turnNorth(){ direction = 2; } void turnEast(){ direction = 0; } void turnWest(){ direction = 1; } }`

Answers

Sign In or Register to comment.