Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement