We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
Sorry, for some reason pressing the button that says C and pasting my code didn't work, here's a pastebin
Can you please post a MCVE that demonstrates the problem?
@KevinWorkman Here you go!
Look at this line:
By default, the
rect()
function takes 4 parameters: an x and y position, and a width and a height.See also: https://processing.org/reference/rectMode_.html
@KevinWorkman
...It's been a while.
Anyway, thank you!