Skip to content

Instantly share code, notes, and snippets.

@aefreedman
Created November 3, 2021 13:03
Show Gist options
  • Select an option

  • Save aefreedman/1eb12598e713cefab3d5620e09d1259f to your computer and use it in GitHub Desktop.

Select an option

Save aefreedman/1eb12598e713cefab3d5620e09d1259f to your computer and use it in GitHub Desktop.
var PLAYER_INITIAL_VELOCITY_BOOST=2; //player gets a little burst of velocity when a key is pressed
var PLAYER_ACCEL = 200; //the player's movement acceleration
var PLAYER_MAXSPEED = 400; //the player's top speed is capped
var PLAYER_DRAG = 0.96; //how quickly you slow down after letting go of the cursor keys
var PLAYER_HITBOX_WIDTH=32; //in shooters we want the player's collision box to have its own size
var PLAYER_HITBOX_HEIGHT=32;
var PLAYER_MAXHEALTH =3; //number of hits until player killed
var PLAYER_REVIVE_DELAY=2.25; //delay before player revived
var PLAYER_ANIMATE_FRAME_RATE = 30; //speed to animate plane moving left/right
var PLAYER_SAFE_ZONE = 280; //area at bottom of screen that the enemies won't move into
var PLAYER_DEATH_PAUSE = 0.3; //pause the game momentarily when the player dies
var PLAYER_EXPLOSION_SCALE = 1.25; //player explosion could be bigger than enemy explosions
var LARGE_EXPLOSION_FRAMERATE = 8; //frame rate for explosion animation
var SMALL_EXPLOSION_FRAMERATE = 60;
var EXPLOSION_SCREEN_SHAKE_TIME = 1.0; //we'll shake the screen when things explode
var EXPLOSION_SCREEN_SHAKE_AMOUNT = 12;
var ENEMY_EXPLODE_SCALE = 0.8;//how big should the enemy explosions be?xx
var BULLET_SPEED = 120; //player's bullet speed
var BULLETS_INHERIT_PLAYER_VELOCITY = 0.1; //should bullets pick up speed from player?
var BULLET_ACCELERATION = 30; //player's bullet acceleration: negative values slow bullets down
var BULLET_AUTOFIRE = true; //should the gun fire when the fire button is held down?
var BULLET_AUTOFIRE_DELAY = 1.8; //time between autofires
var MAX_NUM_BULLETS = 300; //max number of bullets onscreen
var BULLET_STARTPOS = -12; //start bullets some number of pixels from edge of player body
var ENEMY_MAXSPEED = 300; //enemy top speed
var ENEMY_ACCEL = 100; //enemies accelerate toward a random point
var ENEMY_DODGESPEED = 60; //enemies add additional speed to avoid the player shooting them
var ENEMY_VERTICAL_DODGERANGE = 380; //enemies try and dodge the player if closer than this
var ENEMY_HORIZONTAL_DODGERANGE = 64; //enemies try and dodge the player if closer than this
var ENEMY_BULLET_SPEED=400; //speed of enemy bullets
var ENEMY_BULLET_DRAG=0.99; //make enemy bullets slow down every frame, multiplying velocity by this
var ENEMY_BULLET_DAMAGE=2; //bullets do this much damage to player
var ENEMY_TOUCH_DAMAGE=4; //player receives this much damage when touching enemy
var ENEMY_FIRE_DELAY_MAX = 6.0; //enemy bullets spawn at a random interval
var ENEMY_FIRE_DELAY_MIN = 0.2;
var ENEMY_SPAWN_RATE = 2000; //delay between enemy spawning (in milliseconds)
var ENEMY_BOUNCE = 0.4; //amount enemies bounce on colliding with walls or the player
var ENEMY_MAXHEALTH = 3; //number of hits before enemy killed
var MAX_NUM_ENEMIES = 64; //max number of enemies on screen
var MAX_NUM_ENEMY_BULLETS = 24;//max number of enemy bullets onscreen
var SCROLL_SPEED = 0.02; //background scrolling speed
var SCROLL_PARALLAX_DEPTH = 2.5; //higher values make a bigger speed difference between background layers
var DEBUG = false; //show debug bodies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment