Pong Quest File for setting initial system and global variables and polling the keyboard. @author: Caffeine (a.k.a. L. Scotty Hoag) / /** Sets initial system variables. */ void setup() { size(800, 600, OPENGL); frameRate(60); noStroke(); noSmooth(); //smooth(); game = new Main(); leftArrowKeyDown = rightArrowKeyDown = shiftKeyDown = upArrowKeyDown = downArrowKeyDown = false; aKeyDown = sKeyDown = dKeyDown = wKeyDown = pKeyDown = spaceKeyDown = false; } /** Main game loop. */ void draw() { game.update(); } /** Polls keys that have been pressed. */ void keyPressed() { switch(key) { case CODED: switch(keyCode) { case UP: upArrowKeyDown = true; break; case DOWN: downArrowKeyDown = true; break; case LEFT: leftArrowKeyDown = true; break; case RIGHT: rightArrowKeyDown = true; break; case SHIFT: shiftKeyDown = true; break; } break; case 'a': case 'A': aKeyDown = true; break; case 's': case 'S': sKeyDown = true; break; case 'd': case 'D': dKeyDown = true; break; case 'w': case 'W': wKeyDown = true; break; case 'p': case 'P': pKeyDown = true; break; case 'j': case 'J': jKeyDown = true; break; case 'k': case 'K': kKeyDown = true; break; case 'l': case 'L': lKeyDown = true; break; case 'i': case 'I': iKeyDown = true; break; case ' ': spaceKeyDown = true; game.handleKeys(key); break; } } /** Polls keys that have been released. */ void keyReleased() { switch(key) { case CODED: switch(keyCode) { case UP: upArrowKeyDown = false; break; case DOWN: downArrowKeyDown = false; break; case LEFT: leftArrowKeyDown = false; break; case RIGHT: rightArrowKeyDown = false; break; case SHIFT: shiftKeyDown = false; break; } break; case 'a': case 'A': aKeyDown = false; break; case 's': case 'S': sKeyDown = false; break; case 'd': case 'D': dKeyDown = false; break; case 'w': case 'W': wKeyDown = false; break; case 'p': case 'P': pKeyDown = false; break; case 'j': case 'J': jKeyDown = false; break; case 'k': case 'K': kKeyDown = false; break; case 'l': case 'L': lKeyDown = false; break; case 'i': case 'I': iKeyDown = false; break; case ' ': spaceKeyDown = false; break; } } /* Globals */ Main game; boolean upArrowKeyDown, downArrowKeyDown, spaceKeyDown; boolean leftArrowKeyDown, rightArrowKeyDown, shiftKeyDown; boolean aKeyDown, sKeyDown, dKeyDown, wKeyDown, pKeyDown; boolean jKeyDown, kKeyDown, lKeyDown, iKeyDown; /** Graphics */ PFont font; PImage storyScreen; PImage goodEnding; PImage badEnding; PImage poster_a; PImage poster_s; PImage poster_w; PImage poster_d; PImage poster_j; PImage poster_k; PImage poster_i; PImage poster_l; PImage poster_shift_left; PImage poster_shift_right; PImage poster_space_left; PImage poster_space_right; PImage poster_reset; PImage arrow_down; PImage arrow_left; PImage arrow_up; PImage arrow_right; PImage poster_ball; PImage poster_paddle_left; PImage poster_paddle_right; PImage poster_or; PImage poster_up_arrow_key; PImage poster_down_arrow_key; PImage poster_left_arrow_key; PImage poster_right_arrow_key; /* Direction Constants */ static final int SOUTH = 0; static final int WEST = 1; static final int NORTH = 2; static final int EAST = 3; /* Object IDs

Source code: PongQuest Ball BaseObject Door FloorPanel HPaddle Main MapMaker Paddle Poster VPaddle

Built with Processing