Advertisement
Guest User

Chapter 1: Tank Game Course

a guest
Apr 30th, 2022
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var TankGame = (function() {
  2.   var TARGET_WIDTH = 801; // Desired width
  3.   var TARGET_HEIGHT = 601;
  4.   var WIDTH; // Actual width of game, scaled to fit screen
  5.   var HEIGHT;
  6.   var GUI_HEIGHT = 150;
  7.   var DEBUG = false;
  8.   // WASD
  9.   var P1_UP = 87;
  10.   var P1_DOWN = 83;
  11.   var P1_LEFT = 65;
  12.   var P1_RIGHT = 68;
  13.   var P1_FIRE = 49;
  14.  
  15.   // Arrow keys
  16.   var P2_UP = 38;
  17.   var P2_DOWN = 40;
  18.   var P2_LEFT = 37;
  19.   var P2_RIGHT = 39;
  20.   var P2_FIRE = 189;
  21.  
  22.   // Other settings
  23.   var TANK_SIZE = 15;
  24.   var TANK_SPEED = 1;
  25.   var TANK_TURN_SPEED = 5;
  26.   var WALL_WIDTH = 2;
  27.   var CELL_SIZE = 50;
  28.   var RESET_COUNTER_MAX = 200;
  29.   var EPSILON = 0.001;
  30.  
  31.  
  32.   var MAX_DIST_FOR_COLLISIONS = 2; // (this is multiplied by CELL_SIZE)
  33.   var TANK_P1, TANK_P2;
  34.   var CELLS_X, CELLS_Y;
  35.   var CANVAS, CTX, KEYSTATE, GAME_OBJECTS;
  36.   var PRERENDERED_CANVAS, PRERENDERED_CTX, PRERENDERED_REDRAW_NEEDED;
  37.   var GUI_REDRAW_NEEDED;
  38.   var END_ROUND = false;
  39.   var RESET_COUNTER;
  40.  
  41.   var P1 = 1;
  42.   var P2 = 2;
  43.   var P1_SCORE = 0;
  44.   var P2_SCORE = 0;
  45.  
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement