Advertisement
Guest User

Untitled

a guest
Sep 20th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. /*************
  2. ** PA1_Starter.pde
  3. ** Matthew Landen
  4. ** 7/28/16
  5. ** (section) KEY
  6. ** mlanden@umbc.edu
  7. ** zig zags pacman while bouncing off
  8. ** top and bottom and wrapping around
  9. */
  10.  
  11. //variables
  12. float pacmanX = 80;
  13. float pacmanY = 80;
  14. float xDelta = 2;
  15. float yDelta = 4;
  16. //my variables
  17. float xSpeed = 5;
  18. float ySpeed = 5;
  19. float hismouth = .8;
  20. float smile = radians(295);
  21. int delicious = PIE;
  22. //end my variables
  23.  
  24. //trying new stuff
  25. int rad = 60;
  26. float xpos, ypos;
  27. float xspeed = 2.8;
  28. float yspeed = 2.2;
  29. int xdirection = 1;
  30. int ydirection = 1;
  31. //end new stuff
  32. final float PACMAN_SIZE = 70;
  33.  
  34. /*
  35. * setup - prepares envirnment size and color
  36. */
  37. void setup() {
  38. //set canvas size and color
  39. size(1200, 500);
  40. frameRate(60);
  41. xpos = 80;
  42. ypos = 80;
  43. // Changes I make
  44.  
  45. }
  46.  
  47. /*
  48. * draw - move pacman on diagonals and bounce off top
  49. * and bottom while rapping around left to right
  50. */
  51. void draw() {
  52.  
  53. background(0);
  54.  
  55. xpos = xpos + (xspeed * xdirection);
  56. ypos = ypos + (yspeed * ydirection);
  57.  
  58. if (xpos > width-rad || xpos < rad) {
  59. xdirection *= -1;
  60. }
  61. if (ypos > height-rad || ypos < rad) {
  62. ydirection *= -1;
  63. }
  64.  
  65. fill(255,255,0);
  66. arc(pacmanX,pacmanY,PACMAN_SIZE,PACMAN_SIZE,hismouth,smile,delicious);
  67.  
  68. pacmanX = pacmanX + 1;
  69. pacmanY = pacmanY + 1;
  70. //move pacman if mouse is clicked
  71.  
  72. //check bounds and make pacman bounce off top/bottom
  73. //and wrap right to left
  74.  
  75.  
  76. }
  77.  
  78. /*
  79. * DrawPacman - draws a packman a the given x, y
  80. */
  81. void drawPacman() {
  82.  
  83. }
  84.  
  85. /*
  86. * makePacmanBounce - redirects pacman to opposite direction
  87. * when hitting top/bottom
  88. */
  89. void makePacmanBounce()
  90. {
  91. pacmanX = pacmanX + (xSpeed * xdirection);
  92. pacmanY = pacmanY + (ySpeed * ydirection);
  93.  
  94. if (pacmanX > width-80 || pacmanX < 80) {
  95. xdirection *= -1;
  96. }
  97. if (pacmanY > width-80 || pacmanX < 80) {
  98. ydirection *= -1;
  99. }
  100.  
  101. }
  102.  
  103. /*
  104. * makePacmanWrap - puts pacman on left when it reaches right
  105. */
  106. void makePacmanWrap() {
  107.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement