-
Notifications
You must be signed in to change notification settings - Fork 14
/
state.js
69 lines (56 loc) · 1.61 KB
/
state.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* global W H */
// N.B: constants don't live here
var t = 0, dt,
spaceship = [ W/2, H/2, 0, 0, 0 ], // [x, y, velx, vely, rot]
asteroids = [], // array of [x, y, rot, vel, shape, lvl]
ufos = [], // array of [x, y, vx, vy, timeBeforeShot]
bullets = [], // array of [x, y, velx, vely, life, isAlien]
incomingObjects = [], // array of: [pos, vel, ang, force, rotVel, shape, lvl, key, rotAmp, rotAmpValid, explodeTime]
particles = [], // array of [x, y, rot, vel, life]
dying = 0,
resurrectionTime = 0,
best = 0,
score = 0, // current asteroids player score
scoreForLife, // will track the next score to win a life (10000, 20000, ...)
playingSince = -10000,
deads = 0,
player = 0,
lifes = 0,
AIshoot = 0, AIboost = 0, AIrotate = 0, AIexcitement = 0,
AIboostSmoothed = 0,
shaking = [0,0],
jumping = 0,
jumpingFreq = 0,
jumpingPhase = 0,
jumpingFreqSmoothed = 0,
jumpingAmp = 0,
jumpingAmpSmoothed = 0,
killSmoothed = 0,
musicPhase = 0,
musicTick = 0,
musicPaused = 0,
ufoMusicTime = 0,
excitementSmoothed = 0,
neverPlayed = 1,
neverUFOs = 1,
combos = 0,
combosTarget,
gameOver,
awaitingContinue = localStorage.ba_pl && parseInt(localStorage.ba_pl),
// achievements: [nbAsteroids, nbKills, nbUfos]
achievements,
lastScoreIncrement = 0,
lastJump = 0,
lastBulletShoot = 0,
lastExtraLife = 0,
lastLoseShot = 0,
// Input state : updated by user events, handled & emptied by the update loop
keys = {},
tap,
// variables related to setup
gameScale;
function helpVisible () {
return neverPlayed &&
incomingObjects[0] &&
playingSince>8000;
}