Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************
- ** PA1_Starter.pde
- ** Matthew Landen
- ** 7/28/16
- ** (section) KEY
- ** mlanden@umbc.edu
- ** zig zags pacman while bouncing off
- ** top and bottom and wrapping around
- */
- //variables
- float pacmanX = 80;
- float pacmanY = 80;
- float xDelta = 2;
- float yDelta = 4;
- //my variables
- float xSpeed = 5;
- float ySpeed = 5;
- float hismouth = .8;
- float smile = radians(295);
- int delicious = PIE;
- //end my variables
- //trying new stuff
- int rad = 60;
- float xpos, ypos;
- float xspeed = 2.8;
- float yspeed = 2.2;
- int xdirection = 1;
- int ydirection = 1;
- //end new stuff
- final float PACMAN_SIZE = 70;
- /*
- * setup - prepares envirnment size and color
- */
- void setup() {
- //set canvas size and color
- size(1200, 500);
- frameRate(60);
- xpos = 80;
- ypos = 80;
- // Changes I make
- }
- /*
- * draw - move pacman on diagonals and bounce off top
- * and bottom while rapping around left to right
- */
- void draw() {
- background(0);
- xpos = xpos + (xspeed * xdirection);
- ypos = ypos + (yspeed * ydirection);
- if (xpos > width-rad || xpos < rad) {
- xdirection *= -1;
- }
- if (ypos > height-rad || ypos < rad) {
- ydirection *= -1;
- }
- fill(255,255,0);
- arc(pacmanX,pacmanY,PACMAN_SIZE,PACMAN_SIZE,hismouth,smile,delicious);
- pacmanX = pacmanX + 1;
- pacmanY = pacmanY + 1;
- //move pacman if mouse is clicked
- //check bounds and make pacman bounce off top/bottom
- //and wrap right to left
- }
- /*
- * DrawPacman - draws a packman a the given x, y
- */
- void drawPacman() {
- }
- /*
- * makePacmanBounce - redirects pacman to opposite direction
- * when hitting top/bottom
- */
- void makePacmanBounce()
- {
- pacmanX = pacmanX + (xSpeed * xdirection);
- pacmanY = pacmanY + (ySpeed * ydirection);
- if (pacmanX > width-80 || pacmanX < 80) {
- xdirection *= -1;
- }
- if (pacmanY > width-80 || pacmanX < 80) {
- ydirection *= -1;
- }
- }
- /*
- * makePacmanWrap - puts pacman on left when it reaches right
- */
- void makePacmanWrap() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement