littlejsengine 1.8.9 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +17 -17
  2. package/build/littlejs.d.ts +352 -288
  3. package/build/littlejs.esm.js +695 -658
  4. package/build/littlejs.esm.min.js +1 -1
  5. package/build/littlejs.js +694 -658
  6. package/build/littlejs.min.js +1 -1
  7. package/build/littlejs.release.js +629 -594
  8. package/examples/breakout/game.js +4 -4
  9. package/examples/breakout/index.html +3 -3
  10. package/examples/breakoutTutorial/index.html +2 -2
  11. package/examples/electron/game.js +1 -1
  12. package/examples/electron/index.html +2 -2
  13. package/examples/favicon.png +0 -0
  14. package/examples/js13k/build.js +1 -1
  15. package/examples/js13k/index.html +13 -13
  16. package/examples/module/game.js +1 -1
  17. package/examples/module/index.html +1 -1
  18. package/examples/particles/index.html +1 -1
  19. package/examples/platformer/game.js +6 -6
  20. package/examples/platformer/gameCharacter.js +293 -0
  21. package/examples/platformer/gameEffects.js +8 -5
  22. package/examples/platformer/gameObjects.js +13 -13
  23. package/examples/platformer/gamePlayer.js +9 -293
  24. package/examples/platformer/index.html +7 -6
  25. package/examples/puzzle/game.js +3 -2
  26. package/examples/puzzle/index.html +2 -2
  27. package/examples/starter/build.js +1 -1
  28. package/examples/starter/game.js +2 -2
  29. package/examples/starter/index.html +13 -13
  30. package/examples/stress/index.html +35 -27
  31. package/examples/typescript/index.html +1 -1
  32. package/index.d.ts +2094 -0
  33. package/package.json +1 -1
  34. package/src/engine.js +28 -28
  35. package/src/engineAudio.js +57 -57
  36. package/src/engineDebug.js +66 -65
  37. package/src/engineDraw.js +64 -73
  38. package/src/engineExport.js +1 -0
  39. package/src/engineInput.js +57 -40
  40. package/src/engineMedals.js +32 -29
  41. package/src/engineObject.js +42 -27
  42. package/src/engineParticles.js +98 -72
  43. package/src/engineRelease.js +1 -1
  44. package/src/engineSettings.js +22 -22
  45. package/src/engineTileLayer.js +66 -60
  46. package/src/engineUtilities.js +49 -49
  47. package/src/engineWebGL.js +112 -135
  48. package/src/jsconfig.json +10 -0
@@ -9,7 +9,7 @@
9
9
  'use strict';
10
10
 
11
11
  // show the LittleJS splash screen
12
- showSplashScreen = 1;
12
+ setShowSplashScreen(true);
13
13
 
14
14
  let levelSize, ball, paddle, score, brickCount;
15
15
 
@@ -71,11 +71,11 @@ function gameRenderPost()
71
71
  {
72
72
  // use built in image font for text
73
73
  const font = new FontImage;
74
- font.drawText('Score: ' + score, cameraPos.add(vec2(0,9.6)), .15, 1);
74
+ font.drawText('Score: ' + score, cameraPos.add(vec2(0,9.6)), .15, true);
75
75
  if (!brickCount)
76
- font.drawText('You Win!', cameraPos.add(vec2(0,-5)), .2, 1);
76
+ font.drawText('You Win!', cameraPos.add(vec2(0,-5)), .2, true);
77
77
  else if (!ball)
78
- font.drawText('Click to Play', cameraPos.add(vec2(0,-5)), .2, 1);
78
+ font.drawText('Click to Play', cameraPos.add(vec2(0,-5)), .2, true);
79
79
  }
80
80
 
81
81
  ///////////////////////////////////////////////////////////////////////////////
@@ -5,6 +5,6 @@
5
5
  <link rel=icon type=image/png href=../favicon.png>
6
6
  </head><body>
7
7
 
8
- <script src=../../build/littlejs.js?188></script>
9
- <script src=gameObjects.js?188></script>
10
- <script src=game.js?188></script>
8
+ <script src=../../build/littlejs.js?1812></script>
9
+ <script src=gameObjects.js?1812></script>
10
+ <script src=game.js?1812></script>
@@ -5,5 +5,5 @@
5
5
  <link rel=icon type=image/png href=../favicon.png>
6
6
  </head><body>
7
7
 
8
- <script src=../../build/littlejs.js?188></script>
9
- <script src=game.js?188></script>
8
+ <script src=../../build/littlejs.js?1812></script>
9
+ <script src=game.js?1812></script>
@@ -17,7 +17,7 @@ medalsInit('Hello World');
17
17
  let particleEmiter;
18
18
 
19
19
  // show the LittleJS splash screen
20
- showSplashScreen = 1;
20
+ setShowSplashScreen(true);
21
21
 
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
  function gameInit()
@@ -6,7 +6,7 @@
6
6
  </head><body>
7
7
 
8
8
  <!-- LittleJS Engine -->
9
- <script src=../../build/littlejs.js?188></script>
9
+ <script src=../../build/littlejs.js?1812></script>
10
10
 
11
11
  <!-- Add your game scripts here -->
12
- <script src=game.js?188></script>
12
+ <script src=game.js?1812></script>
Binary file
@@ -26,7 +26,7 @@ const fs = require('node:fs');
26
26
  const child_process = require('node:child_process');
27
27
 
28
28
  // rebuild engine
29
- child_process.execSync(`npm run build`, { stdio: 'inherit' });
29
+ //child_process.execSync(`npm run build`, { stdio: 'inherit' });
30
30
 
31
31
  // remove old files and setup build folder
32
32
  fs.rmSync(BUILD_FOLDER, { recursive: true, force: true });
@@ -1,18 +1,18 @@
1
1
  <head><title>LittleJS JS13K Project</title></head><body>
2
2
 
3
3
  <!-- LittleJS Engine -->
4
- <script src=../../src/engineDebug.js?188></script>
5
- <script src=../../src/engineUtilities.js?188></script>
6
- <script src=../../src/engineSettings.js?188></script>
7
- <script src=../../src/engineObject.js?188></script>
8
- <script src=../../src/engineDraw.js?188></script>
9
- <script src=../../src/engineInput.js?188></script>
10
- <script src=../../src/engineAudio.js?188></script>
11
- <script src=../../src/engineTileLayer.js?188></script>
12
- <script src=../../src/engineParticles.js?188></script>
13
- <script src=../../src/engineMedals.js?188></script>
14
- <script src=../../src/engineWebGL.js?188></script>
15
- <script src=../../src/engine.js?188></script>
4
+ <script src=../../src/engineDebug.js?1812></script>
5
+ <script src=../../src/engineUtilities.js?1812></script>
6
+ <script src=../../src/engineSettings.js?1812></script>
7
+ <script src=../../src/engineObject.js?1812></script>
8
+ <script src=../../src/engineDraw.js?1812></script>
9
+ <script src=../../src/engineInput.js?1812></script>
10
+ <script src=../../src/engineAudio.js?1812></script>
11
+ <script src=../../src/engineTileLayer.js?1812></script>
12
+ <script src=../../src/engineParticles.js?1812></script>
13
+ <script src=../../src/engineMedals.js?1812></script>
14
+ <script src=../../src/engineWebGL.js?1812></script>
15
+ <script src=../../src/engine.js?1812></script>
16
16
 
17
17
  <!-- Add your game scripts here -->
18
- <script src=game.js?188></script>
18
+ <script src=game.js?1812></script>
@@ -11,7 +11,7 @@ import * as LittleJS from '../../build/littlejs.esm.js';
11
11
  const {Vector2, Color, Timer, vec2, tile} = LittleJS;
12
12
 
13
13
  // show the LittleJS splash screen
14
- LittleJS.setShowSplashScreen(1);
14
+ LittleJS.setShowSplashScreen(true);
15
15
 
16
16
  // sound effects
17
17
  const sound_click = new LittleJS.Sound([1,.5]);
@@ -6,4 +6,4 @@
6
6
  </head><body>
7
7
 
8
8
  <!-- Add your game scripts here -->
9
- <script src=game.js?188 type=module></script>
9
+ <script src=game.js?1812 type=module></script>
@@ -9,7 +9,7 @@ button { margin:1px; }
9
9
  </style>
10
10
  </head><body>
11
11
 
12
- <script src=../../build/littlejs.js?188></script>
12
+ <script src=../../build/littlejs.js?1812></script>
13
13
  <script>
14
14
 
15
15
  'use strict';
@@ -9,7 +9,7 @@
9
9
  'use strict';
10
10
 
11
11
  // show the LittleJS splash screen
12
- showSplashScreen = 1;
12
+ setShowSplashScreen(true);
13
13
 
14
14
  let score, deaths;
15
15
 
@@ -17,7 +17,7 @@ let score, deaths;
17
17
  function gameInit()
18
18
  {
19
19
  // enable touch gamepad on touch devices
20
- touchGamepadEnable = 1;
20
+ touchGamepadEnable = true;
21
21
 
22
22
  // setup game
23
23
  score = deaths = 0;
@@ -44,19 +44,19 @@ function gameUpdate()
44
44
  cameraScale = clamp(cameraScale*(1-mouseWheel/10), 1, 1e3);
45
45
 
46
46
  // T = drop test crate
47
- if (keyWasPressed(84))
47
+ if (keyWasPressed('KeyT'))
48
48
  new Crate(mousePos);
49
49
 
50
50
  // E = drop enemy
51
- if (keyWasPressed(69))
51
+ if (keyWasPressed('KeyE'))
52
52
  new Enemy(mousePos);
53
53
 
54
54
  // X = make explosion
55
- if (keyWasPressed(88))
55
+ if (keyWasPressed('KeyX'))
56
56
  explosion(mousePos);
57
57
 
58
58
  // M = move player to mouse
59
- if (keyWasPressed(77))
59
+ if (keyWasPressed('KeyM'))
60
60
  player.pos = mousePos;
61
61
  }
62
62
 
@@ -0,0 +1,293 @@
1
+ /*
2
+ LittleJS Platformer Example - Character
3
+ - Platform style character
4
+ - Handles animation and sound effects
5
+ - Uses special platforming physics system
6
+ - Characters can jump, shoot, roll, and throw grenades
7
+ - Characters can climb ladders and break blocks
8
+ - Characters also have a damage and can die
9
+ - Has a weapon which can be fired
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ class Character extends GameObject
15
+ {
16
+ constructor(pos)
17
+ {
18
+ super(pos, vec2(.6,.95), tile());
19
+
20
+ this.weapon = new Weapon(pos, this);
21
+ this.lastPos = pos;
22
+ this.groundTimer = new Timer;
23
+ this.jumpTimer = new Timer;
24
+ this.pressedJumpTimer = new Timer;
25
+ this.dodgeTimer = new Timer;
26
+ this.dodgeRechargeTimer = new Timer;
27
+ this.deadTimer = new Timer;
28
+ this.grendeThrowTimer = new Timer;
29
+ this.drawSize = vec2(1);
30
+ this.color = (new Color).setHSLA(rand(),1,.7);
31
+ this.renderOrder = 10;
32
+ this.walkCyclePercent = 0;
33
+ this.health = 1;
34
+ this.setCollision(true,false);
35
+ }
36
+
37
+ update()
38
+ {
39
+ this.gravityScale = 1; // reset to default gravity
40
+
41
+ if (this.isDead())
42
+ return super.update();
43
+
44
+ const moveInput = this.moveInput.copy();
45
+
46
+ // jump
47
+ if (!this.holdingJump)
48
+ this.pressedJumpTimer.unset();
49
+ else if (!this.wasHoldingJump || this.climbingWall)
50
+ this.pressedJumpTimer.set(.3);
51
+ this.wasHoldingJump = this.holdingJump;
52
+
53
+ // wall climb
54
+ this.climbingWall = 0;
55
+ if (moveInput.x && !this.velocity.x && this.velocity.y < 0)
56
+ {
57
+ this.velocity.y *=.8;
58
+ this.climbingWall = 1;
59
+ }
60
+
61
+ if (this.dodgeTimer.active())
62
+ {
63
+ // update roll
64
+ this.angle = this.getMirrorSign()*2*PI*this.dodgeTimer.getPercent();
65
+ if (this.groundObject)
66
+ this.velocity.x += this.getMirrorSign()*.1;
67
+ }
68
+ else
69
+ {
70
+ // not rolling
71
+ this.angle = 0;
72
+ if (this.pressedDodge && !this.dodgeRechargeTimer.active())
73
+ {
74
+ // start dodge
75
+ this.dodgeTimer.set(.4);
76
+ this.dodgeRechargeTimer.set(2);
77
+ this.jumpTimer.unset();
78
+ sound_dodge.play(this.pos);
79
+
80
+ if (!this.groundObject && this.getAliveTime() > .2)
81
+ this.velocity.y += .2;
82
+ }
83
+ if (this.pressingThrow && !this.wasPressingThrow && !this.grendeThrowTimer.active())
84
+ {
85
+ // throw greande
86
+ const grenade = new Grenade(this.pos);
87
+ grenade.velocity = this.velocity.add(vec2(this.getMirrorSign(),rand(.8,.7)).normalize(.2+rand(.02)));
88
+ grenade.angleVelocity = this.getMirrorSign() * rand(.8,.5);
89
+ sound_jump.play(this.pos);
90
+ this.grendeThrowTimer.set(1);
91
+ }
92
+ this.wasPressingThrow = this.pressingThrow;
93
+ }
94
+
95
+ // allow grabbing ladder at head or feet
96
+ let touchingLadder = 0;
97
+ for (let y=2;y--;)
98
+ {
99
+ const testPos = this.pos.add(vec2(0, y + .1*moveInput.y - this.size.y/2));
100
+ const collisionData = getTileCollisionData(testPos);
101
+ touchingLadder ||= collisionData == tileType_ladder;
102
+ }
103
+ if (!touchingLadder)
104
+ this.climbingLadder = 0;
105
+ else if (moveInput.y)
106
+ this.climbingLadder = 1;
107
+
108
+ if (this.weapon) // update weapon trigger
109
+ this.weapon.triggerIsDown = this.holdingShoot && !this.dodgeTimer.active();
110
+
111
+ if (this.climbingLadder)
112
+ {
113
+ // update ladder
114
+ this.gravityScale = this.climbingWall = this.groundObject = 0;
115
+ this.jumpTimer.unset();
116
+ this.groundTimer.unset();
117
+ this.velocity = this.velocity.multiply(vec2(.85)).add(vec2(0,.02*moveInput.y));
118
+
119
+ // pull towards ladder
120
+ const delta = (this.pos.x|0)+.5 - this.pos.x;
121
+ this.velocity.x += .02*delta*abs(moveInput.x ? 0:moveInput.y);
122
+ moveInput.x *= .2;
123
+
124
+ // exit ladder if ground is below
125
+ this.climbingLadder = moveInput.y >= 0 || getTileCollisionData(this.pos.subtract(vec2(0,1))) <= 0;
126
+ }
127
+ else
128
+ {
129
+ // update jumping and ground check
130
+ if (this.groundObject || this.climbingWall)
131
+ {
132
+ if (!this.groundTimer.isSet())
133
+ sound_walk.play(this.pos); // land sound
134
+
135
+ this.groundTimer.set(.1);
136
+ }
137
+
138
+ if (this.groundTimer.active() && !this.dodgeTimer.active())
139
+ {
140
+ // is on ground
141
+ if (this.pressedJumpTimer.active() && !this.jumpTimer.active())
142
+ {
143
+ // start jump
144
+ if (this.climbingWall)
145
+ this.velocity.y = .25;
146
+ else
147
+ {
148
+ this.velocity.y = .15;
149
+ this.jumpTimer.set(.2);
150
+ }
151
+ sound_jump.play(this.pos);
152
+ }
153
+ }
154
+
155
+ if (this.jumpTimer.active() && !this.climbingWall)
156
+ {
157
+ // update variable height jump
158
+ this.groundTimer.unset();
159
+ if (this.holdingJump && this.velocity.y > 0 && this.jumpTimer.active())
160
+ this.velocity.y += .017;
161
+ }
162
+
163
+ if (!this.groundObject)
164
+ {
165
+ // air control
166
+ if (sign(moveInput.x) == sign(this.velocity.x))
167
+ moveInput.x *= .1; // moving with velocity
168
+ else
169
+ moveInput.x *= .2; // moving against velocity (stopping)
170
+
171
+ // slight extra gravity when moving down
172
+ if (this.velocity.y < 0)
173
+ this.velocity.y += gravity*.2;
174
+ }
175
+ }
176
+
177
+ // apply movement acceleration and clamp
178
+ const maxCharacterSpeed = .2;
179
+ this.velocity.x = clamp(this.velocity.x + moveInput.x * .042, -maxCharacterSpeed, maxCharacterSpeed);
180
+
181
+ // track last pos for ladder collision code
182
+ this.lastPos = this.pos.copy();
183
+
184
+ // call parent and update physics
185
+ super.update();
186
+
187
+ // update walk cycle
188
+ const speed = this.velocity.length();
189
+ if (this.climbingLadder || this.groundTimer.active() && !this.dodgeTimer.active())
190
+ {
191
+ this.walkCyclePercent += speed * .5;
192
+ this.walkCyclePercent = speed > .01 ? mod(this.walkCyclePercent) : 0;
193
+ }
194
+ else
195
+ this.walkCyclePercent = 0;
196
+
197
+ // update walk sound
198
+ this.walkSoundTime += speed;
199
+ if (speed > .001 && ((this.climbingLadder || this.groundTimer.active()) && !this.dodgeTimer.active()))
200
+ {
201
+ if (this.walkSoundTime > 1)
202
+ {
203
+ this.walkSoundTime = this.walkSoundTime%1;
204
+ sound_walk.play(this.pos);
205
+ }
206
+ }
207
+ else
208
+ this.walkSoundTime = 0;
209
+
210
+ // update mirror
211
+ if (moveInput.x && !this.dodgeTimer.active())
212
+ this.mirror = moveInput.x < 0;
213
+
214
+ // set tile to use
215
+ const tile = this.isDead() ? 3 :
216
+ this.climbingLadder || this.groundTimer.active() ? 3 + 2*this.walkCyclePercent|0 : 4;
217
+ this.tileInfo.pos.x = tile * 16;
218
+ }
219
+
220
+ render()
221
+ {
222
+ let bodyPos = this.pos;
223
+ if (!this.isDead())
224
+ {
225
+ // bounce pos with walk cycle
226
+ bodyPos = bodyPos.add(vec2(0,.05*Math.sin(this.walkCyclePercent*PI)));
227
+
228
+ // make bottom flush
229
+ bodyPos = bodyPos.add(vec2(0,(this.drawSize.y-this.size.y)/2));
230
+ }
231
+ drawTile(bodyPos, this.drawSize, this.tileInfo, this.color, this.angle, this.mirror);
232
+ }
233
+
234
+ damage(damage, damagingObject)
235
+ {
236
+ if (this.isDead() || this.getAliveTime() < 1 || this.dodgeTimer.active())
237
+ return;
238
+
239
+ makeBlood(damagingObject ? damagingObject.pos : this.pos);
240
+ super.damage(damage, damagingObject);
241
+ }
242
+
243
+ kill(damagingObject)
244
+ {
245
+ if (this.isDead())
246
+ return;
247
+
248
+ makeBlood(this.pos, 300);
249
+ sound_die.play(this.pos);
250
+
251
+ this.health = 0;
252
+ if (this.weapon)
253
+ this.weapon.destroy();
254
+ this.deadTimer.set();
255
+ this.size = this.size.scale(.5);
256
+ const fallDirection = damagingObject ? sign(damagingObject.velocity.x) : randSign();
257
+ this.angleVelocity = fallDirection*rand(.22,.14);
258
+ this.angleDamping = .9;
259
+ this.renderOrder = -1; // move to back layer
260
+ }
261
+
262
+ collideWithTile(data, pos)
263
+ {
264
+ if (!data)
265
+ return;
266
+
267
+ if (data == tileType_ladder)
268
+ {
269
+ // handle ladder collisions
270
+ if (pos.y + 1 > this.lastPos.y - this.size.y/2)
271
+ return;
272
+
273
+ if (getTileCollisionData(pos.add(vec2(0,1))) // above
274
+ && !getTileCollisionData(pos.add(vec2(1,0))) // left
275
+ && !getTileCollisionData(pos.add(vec2(1,0)))) // right
276
+ return; // dont collide if something above it and nothing to left or right
277
+
278
+ // allow standing on top of ladders
279
+ return !this.climbingLadder;
280
+ }
281
+
282
+ const d = pos.y - this.pos.y;
283
+ if (!this.climbingLadder && this.velocity.y > .1 && d > 0 && d < this.size.y/2)
284
+ if (destroyTile(pos))
285
+ {
286
+ // break blocks above
287
+ this.velocity.y = 0;
288
+ return;
289
+ }
290
+
291
+ return 1;
292
+ }
293
+ }
@@ -18,7 +18,7 @@ const sound_destroyObject =new Sound([.5,,1e3,.02,,.2,1,3,.1,,,,,1,-30,.5,,.5]);
18
18
  const sound_die = new Sound([.5,.4,126,.05,,.2,1,2.09,,-4,,,1,1,1,.4,.03]);
19
19
  const sound_jump = new Sound([.4,.2,250,.04,,.04,,,1,,,,,3]);
20
20
  const sound_dodge = new Sound([.4,.2,150,.05,,.05,,,-1,,,,,4,,,,,.02]);
21
- const sound_walk = new Sound([.3,.1,200,,,.01,4,,,,-9,.1,,,,,,.5]);
21
+ const sound_walk = new Sound([.3,.1,50,.005,,.01,4,,,,,,,,10,,,.5]);
22
22
  const sound_explosion = new Sound([2,.2,72,.01,.01,.2,4,,,,,,,1,,.5,.1,.5,.02]);
23
23
  const sound_grenade = new Sound([.5,.01,300,,,.02,3,.22,,,-9,.2,,,,,,.5]);
24
24
  const sound_killEnemy = new Sound([,,783,,.03,.02,1,2,,,940,.03,,,,,.2,.6,,.06]);
@@ -29,7 +29,7 @@ const sound_killEnemy = new Sound([,,783,,.03,.02,1,2,,,940,.03,,,,,.2,.6,,.0
29
29
  const persistentParticleDestroyCallback = (particle)=>
30
30
  {
31
31
  // copy particle to tile layer on death
32
- ASSERT(!particle.tileInfo); // quick draw to tile layer uses canvas 2d so must be untextured
32
+ ASSERT(!particle.tileInfo, 'quick draw to tile layer uses canvas 2d so must be untextured');
33
33
  if (particle.groundObject)
34
34
  tileLayer.drawTile(particle.pos, particle.size, particle.tileInfo, particle.color, particle.angle, particle.mirror);
35
35
  }
@@ -237,8 +237,7 @@ function drawSky()
237
237
  function drawStars()
238
238
  {
239
239
  // draw stars and planets
240
- const random = new RandomGenerator;
241
- random.seed = skySeed;
240
+ const random = new RandomGenerator(skySeed);
242
241
  const largeStarCount = 9;
243
242
  for (let i = 1e3; i--;)
244
243
  {
@@ -263,7 +262,11 @@ function drawStars()
263
262
  if (size < 9)
264
263
  mainContext.fillRect(screenPos.x, screenPos.y, size, size);
265
264
  else
266
- mainContext.beginPath(mainContext.fill(mainContext.arc(screenPos.x, screenPos.y, size, 0, 9)));
265
+ {
266
+ mainContext.arc(screenPos.x, screenPos.y, size, 0, 9);
267
+ mainContext.fill();
268
+ mainContext.beginPath();
269
+ }
267
270
  }
268
271
  }
269
272
 
@@ -1,9 +1,9 @@
1
1
  /*
2
2
  LittleJS Platformer Example - Objects
3
3
  - Base GameObject class for objects with health
4
- - Crate object collides with player, can be destroyed.
5
- - Weapon is held by player and fires bullets with some settings.
6
- - Bullet is the projectile launched by a weapon.
4
+ - Crate object collides with player, can be destroyed
5
+ - Weapon is held and fires bullets with some settings
6
+ - Bullet is the projectile launched by a weapon
7
7
  */
8
8
 
9
9
  'use strict';
@@ -77,7 +77,7 @@ class Crate extends GameObject
77
77
 
78
78
  kill()
79
79
  {
80
- if (this.isDestroyed)
80
+ if (this.destroyed)
81
81
  return;
82
82
 
83
83
  sound_destroyObject.play(this.pos);
@@ -98,7 +98,7 @@ class Enemy extends GameObject
98
98
  this.color = (new Color).setHSLA(rand(), 1, .7);
99
99
  this.health = 5;
100
100
  this.bounceTime = new Timer(rand(1e3));
101
- this.setCollision(1,0);
101
+ this.setCollision(true, false);
102
102
  }
103
103
 
104
104
  update()
@@ -122,7 +122,7 @@ class Enemy extends GameObject
122
122
 
123
123
  kill()
124
124
  {
125
- if (this.isDestroyed)
125
+ if (this.destroyed)
126
126
  return;
127
127
 
128
128
  ++score;
@@ -157,7 +157,7 @@ class Grenade extends GameObject
157
157
  this.friction = .9;
158
158
  this.angleDamping = .96;
159
159
  this.renderOrder = 1e8;
160
- this.setCollision(1,0);
160
+ this.setCollision(true,false);
161
161
  }
162
162
 
163
163
  update()
@@ -181,10 +181,10 @@ class Grenade extends GameObject
181
181
  drawTile(this.pos, vec2(.5), this.tileInfo, this.color, this.angle);
182
182
 
183
183
  // draw additive flash when damaged
184
- setBlendMode(1);
184
+ setBlendMode(true);
185
185
  const flash = Math.cos(this.getAliveTime()*2*PI);
186
186
  drawTile(this.pos, vec2(2), tile(0, 16), new Color(1,0,0,.2-.2*flash));
187
- setBlendMode(0);
187
+ setBlendMode(false);
188
188
  }
189
189
  }
190
190
 
@@ -197,10 +197,10 @@ class Weapon extends EngineObject
197
197
  super(pos, vec2(.6), tile(2,8));
198
198
 
199
199
  // weapon settings
200
- this.fireRate = 8;
201
- this.bulletSpeed = .5;
202
- this.bulletSpread = .1;
203
- this.damage = 1;
200
+ this.fireRate = 8;
201
+ this.bulletSpeed = .5;
202
+ this.bulletSpread = .1;
203
+ this.damage = 1;
204
204
 
205
205
  // prepare to fire
206
206
  this.renderOrder = parent.renderOrder + 1;