Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. class vehicle{
  2. int xPos;
  3. int yPos;
  4. int direction;
  5. vehicle(int tempYpos){
  6. xPos = 10;
  7. yPos = tempYpos;
  8. direction = 0;
  9. }
  10.  
  11. void display(){
  12. fill(0,0,255);
  13. rect(xPos,yPos,xPos+10,yPos+10);
  14. }
  15. void move(){
  16. if(direction == 0){
  17. //East
  18. xPos++;
  19. }
  20.  
  21. else if(direction == 1){
  22. //West
  23. xPos--;
  24. }
  25. else if(direction == 2){
  26. //North
  27. yPos++;
  28. }
  29. else if(direction == 3){
  30. //South
  31. yPos--;
  32. }
  33. }
  34. void turnSouth(){
  35. direction = 3;
  36. }
  37. void turnNorth(){
  38. direction = 2;
  39. }
  40. void turnEast(){
  41. direction = 0;
  42. }
  43. void turnWest(){
  44. direction = 1;
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement