Advertisement
Guest User

Car class

a guest
Jan 22nd, 2020
163
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None
  1. int xInput;
  2. int speed;
  3. color carColor;
  4. color back;
  5. int i;
  6. int sped;
  7. boolean Forward;
  8.  
  9. Car(int big, int yKey, color car, color nice, int speed, boolean direction){
  10. size = big;
  11. yInput = yKey;
  12. carColor = car;
  13. back = nice;
  14. sped = speed;
  15. Forward = direction;
  16. if (Forward) {
  17. xInput = size * -1;
  18. }
  19. else {
  20. xInput = size + width;
  21. }
  22. }
  23.  
  24. void display() {
  25. for(int i = 0; i < sped; i++){
  26. background(back);
  27. if(Forward) {
  28. xInput++;
  29. }
  30. else {
  31. xInput--;
  32. }
  33. carBody();
  34. }
  35. }
  36.  
  37. void carBody() {
  38. rectMode(CENTER);
  39. stroke(0, 0, 0);
  40. fill(carColor);
  41. rect(xInput, yInput + size/4, size * 2, size/2);
  42. quad(xInput - size/2, yInput, xInput - size/4, yInput - size/2, xInput + size/4, yInput - size/2, xInput + size/2, yInput);
  43. fill(0, 0, 0);
  44. ellipse(xInput - size * 2/3, yInput + size/2, size/2, size/2);
  45. ellipse(xInput + size * 2/3, yInput + size/2, size/2, size/2);
  46. }
  47. }
Advertisement
RAW Paste Data Copied
Advertisement