littlejsengine 1.11.13 → 1.11.17

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 (51) hide show
  1. package/dist/littlejs.d.ts +1306 -66
  2. package/dist/littlejs.esm.js +3097 -269
  3. package/dist/littlejs.esm.min.js +1 -1
  4. package/dist/littlejs.js +253 -265
  5. package/dist/littlejs.min.js +1 -1
  6. package/dist/littlejs.release.js +155 -260
  7. package/examples/box2d/game.js +7 -10
  8. package/examples/box2d/gameObjects.js +33 -33
  9. package/examples/box2d/index.html +6 -6
  10. package/examples/box2d/scenes.js +28 -28
  11. package/examples/breakout/game.js +1 -4
  12. package/examples/breakout/index.html +4 -4
  13. package/examples/breakoutTutorial/index.html +2 -2
  14. package/examples/htmlMenu/game.js +3 -6
  15. package/examples/htmlMenu/index.html +2 -2
  16. package/examples/module/index.html +1 -1
  17. package/examples/particles/index.html +1 -1
  18. package/examples/platformer/game.js +0 -3
  19. package/examples/platformer/index.html +8 -8
  20. package/examples/puzzle/game.js +0 -3
  21. package/examples/puzzle/index.html +2 -2
  22. package/examples/shorts/base.html +1 -1
  23. package/examples/starter/build.js +4 -4
  24. package/examples/starter/index.html +13 -13
  25. package/examples/stress/index.html +3 -2
  26. package/examples/uiSystem/game.js +1 -7
  27. package/examples/uiSystem/index.html +3 -3
  28. package/package.json +3 -3
  29. package/plugins/box2d.js +1552 -640
  30. package/plugins/{Box2D_v2.3.1_min.wasm.js → box2d.wasm.js} +1 -1
  31. package/plugins/newgrounds.js +7 -8
  32. package/plugins/pluginExport.js +51 -0
  33. package/plugins/postProcess.js +94 -93
  34. package/plugins/uiSystem.js +145 -161
  35. package/plugins/zzfxm.js +163 -0
  36. package/src/engine.js +15 -20
  37. package/src/engineAudio.js +74 -204
  38. package/src/engineBuild.js +21 -3
  39. package/src/engineDebug.js +104 -6
  40. package/src/engineDraw.js +27 -14
  41. package/src/engineExport.js +12 -4
  42. package/src/engineParticles.js +6 -1
  43. package/src/engineRelease.js +6 -1
  44. package/src/engineSettings.js +2 -2
  45. package/src/engineUtilities.js +5 -11
  46. package/src/engineWebGL.js +19 -7
  47. package/examples/starter/build/index.html +0 -2
  48. package/examples/starter/build/index.js +0 -1
  49. package/examples/starter/build/tiles.png +0 -0
  50. package/examples/starter/game.zip +0 -0
  51. /package/plugins/{Box2D_v2.3.1_min.wasm.wasm → box2d.wasm.wasm} +0 -0
@@ -11,8 +11,6 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- // show the LittleJS splash screen
15
- setShowSplashScreen(true);
16
14
  //box2dDebug = 1; // enable box2d debug draw
17
15
 
18
16
  // game variables
@@ -55,9 +53,9 @@ function gameUpdate()
55
53
  {
56
54
  // grab object
57
55
  sound_click.play(mousePos);
58
- const object = box2dPointCast(mousePos);
56
+ const object = box2d.pointCast(mousePos);
59
57
  if (object)
60
- mouseJoint = box2dCreateMouseJoint(object, groundObject, mousePos);
58
+ mouseJoint = new Box2dTargetJoint(object, groundObject, mousePos);
61
59
  }
62
60
  if (mouseWasReleased(0))
63
61
  {
@@ -65,7 +63,7 @@ function gameUpdate()
65
63
  sound_click.play(mousePos, 1, .5);
66
64
  if (mouseJoint)
67
65
  {
68
- box2dDestroyJoint(mouseJoint);
66
+ mouseJoint.destroy();
69
67
  mouseJoint = 0;
70
68
  }
71
69
  }
@@ -84,7 +82,7 @@ function gameUpdate()
84
82
  if (mouseWasPressed(2) || keyWasPressed('KeyX'))
85
83
  explosion(mousePos);
86
84
  if (mouseJoint)
87
- mouseJoint.SetTarget(mousePos.getBox2d());
85
+ mouseJoint.setTarget(mousePos);
88
86
 
89
87
  if (keyWasPressed('KeyR'))
90
88
  loadScene(scene); // reset scene
@@ -95,10 +93,9 @@ function gameUpdate()
95
93
  scene = mod(scene, maxScenes);
96
94
  loadScene(scene);
97
95
  }
98
-
99
96
  if (car)
100
97
  {
101
- // update car control
98
+ // update car controls
102
99
  const input = keyDirection();
103
100
  car.applyMotorInput(-input.x);
104
101
  }
@@ -125,7 +122,7 @@ function gameRender()
125
122
  {
126
123
  const start = mousePos;
127
124
  const end = mousePos.add(vec2(distance,0).rotate(i/count*PI*2));
128
- const result = box2dRaycast(start, end);
125
+ const result = box2d.raycast(start, end);
129
126
  const color = result ? hsl(0,1,.5,.5) : hsl(.5,1,.5,.5);
130
127
  drawLine(start, result ? result.point : end, .1, color);
131
128
  }
@@ -138,7 +135,7 @@ function gameRenderPost()
138
135
  if (mouseJoint)
139
136
  {
140
137
  // draw mouse joint
141
- const ab = vec2(mouseJoint.GetAnchorB());
138
+ const ab = mouseJoint.getAnchorB();
142
139
  drawTile(ab, vec2(.3), spriteAtlas.circle, BLACK);
143
140
  drawLine(mousePos, ab, .1, BLACK);
144
141
  }
@@ -9,7 +9,7 @@
9
9
  ///////////////////////////////////////////////////////////////////////////////
10
10
  // spawn object functions
11
11
 
12
- function spawnBox(pos, size=1, color=WHITE, type=box2dBodyTypeDynamic, applyTexture=true, angle=0)
12
+ function spawnBox(pos, size=1, color=WHITE, type=box2d.bodyTypeDynamic, applyTexture=true, angle=0)
13
13
  {
14
14
  size = typeof size == 'number' ? vec2(size) : size; // square
15
15
  const o = new Box2dObject(pos, size, applyTexture && spriteAtlas.squareOutline, angle, color, type);
@@ -18,7 +18,7 @@ function spawnBox(pos, size=1, color=WHITE, type=box2dBodyTypeDynamic, applyText
18
18
  return o;
19
19
  }
20
20
 
21
- function spawnCircle(pos, diameter=1, color=WHITE, type=box2dBodyTypeDynamic, applyTexture=true, angle=0)
21
+ function spawnCircle(pos, diameter=1, color=WHITE, type=box2d.bodyTypeDynamic, applyTexture=true, angle=0)
22
22
  {
23
23
  const size = vec2(diameter);
24
24
  const o = new Box2dObject(pos, size, applyTexture && spriteAtlas.circleOutline, angle, color, type);
@@ -26,14 +26,14 @@ function spawnCircle(pos, diameter=1, color=WHITE, type=box2dBodyTypeDynamic, ap
26
26
  return o;
27
27
  }
28
28
 
29
- function spawnRandomPoly(pos, diameter=1, color=WHITE, type=box2dBodyTypeDynamic, angle=0)
29
+ function spawnRandomPoly(pos, diameter=1, color=WHITE, type=box2d.bodyTypeDynamic, angle=0)
30
30
  {
31
31
  const o = new Box2dObject(pos, vec2(), 0, angle, color, type);
32
32
  o.addRandomPoly(diameter);
33
33
  return o;
34
34
  }
35
35
 
36
- function spawnRandomObject(pos, scale=1, type=box2dBodyTypeDynamic, angle=0)
36
+ function spawnRandomObject(pos, scale=1, type=box2d.bodyTypeDynamic, angle=0)
37
37
  {
38
38
  if (randInt(2))
39
39
  {
@@ -68,7 +68,7 @@ function spawnRandomEdges()
68
68
  for (let i=40, y=0; i--;)
69
69
  edgePoints.push(vec2(i, y=clamp(y+rand(-2,2),0,5)));
70
70
  edgePoints.push(vec2(0,0));
71
- const o = new Box2dObject(vec2(), vec2(), 0, 0, BLACK, box2dBodyTypeStatic);
71
+ const o = new Box2dObject(vec2(), vec2(), 0, 0, BLACK, box2d.bodyTypeStatic);
72
72
  o.addEdgeList(edgePoints);
73
73
  }
74
74
 
@@ -78,14 +78,14 @@ function spawnRope(startPos, count, angle=PI, color=WHITE, size=vec2(.3,1))
78
78
  for (let i=0; i<count; ++i)
79
79
  {
80
80
  const pos = startPos.add(size.multiply(vec2(0,i+.5)).rotate(-angle));
81
- const o = spawnBox(pos, size, color, box2dBodyTypeDynamic, false, angle);
81
+ const o = spawnBox(pos, size, color, box2d.bodyTypeDynamic, false, angle);
82
82
  o.setFilterData(2, 2);
83
83
  const anchorPos = pos.add(vec2(0,-size.y/2).rotate(-angle));
84
- box2dCreateRevoluteJoint(lastObject, o, anchorPos);
84
+ new Box2dRevoluteJoint(lastObject, o, anchorPos);
85
85
  lastObject = o;
86
86
  }
87
87
  const endPos = lastObject.localToWorld(vec2(0,-size.y/2));
88
- box2dCreateRopeJoint(groundObject, lastObject, startPos, endPos);
88
+ new Box2dRopeJoint(groundObject, lastObject, startPos, endPos);
89
89
  return lastObject;
90
90
  }
91
91
 
@@ -125,13 +125,13 @@ class CarObject extends Box2dObject
125
125
  const wheel = new Box2dObject(pos, vec2(diameter), sprite);
126
126
  wheel.addCircle(diameter, vec2(), density, friction, restitution);
127
127
  this.wheels.push(wheel);
128
- const joint = box2dCreateWheelJoint(this, wheel);
129
- joint.SetSpringDampingRatio(damping);
130
- joint.SetSpringFrequencyHz(frequencyHz);
128
+ const joint = new Box2dWheelJoint(this, wheel);
129
+ joint.setSpringDampingRatio(damping);
130
+ joint.setSpringFrequencyHz(frequencyHz);
131
131
  if (isMotor)
132
132
  {
133
- joint.SetMaxMotorTorque(maxTorque);
134
- joint.EnableMotor(true);
133
+ joint.setMaxMotorTorque(maxTorque);
134
+ joint.enableMotor(true);
135
135
  this.wheelMotorJoint = joint;
136
136
  }
137
137
  }
@@ -144,9 +144,9 @@ class CarObject extends Box2dObject
144
144
  {
145
145
  const maxSpeed = 40;
146
146
  const brakeAmount = .8;
147
- let s = this.wheelMotorJoint.GetMotorSpeed();
147
+ let s = this.wheelMotorJoint.getMotorSpeed();
148
148
  s = input ? clamp(s + input, -maxSpeed, maxSpeed) : s * brakeAmount;
149
- this.wheelMotorJoint.SetMotorSpeed(s);
149
+ this.wheelMotorJoint.setMotorSpeed(s);
150
150
  }
151
151
  destroy()
152
152
  {
@@ -162,7 +162,7 @@ class ContactTester extends Box2dObject
162
162
  {
163
163
  constructor(pos, size, color, contactColor, isCircle=true, isSensor=true)
164
164
  {
165
- super(pos, size, 0, 0, color, box2dBodyTypeStatic);
165
+ super(pos, size, 0, 0, color, box2d.bodyTypeStatic);
166
166
  isCircle ? this.addCircle(size.x) : this.addBox(size);
167
167
  this.setSensor(isSensor);
168
168
  this.contactColor = contactColor;
@@ -190,7 +190,7 @@ class MobileObject extends Box2dObject
190
190
  // spawn smaller mobiles attached to each side
191
191
  const a = anchor.add(vec2( w/(i?2:-2), -h));
192
192
  const o = new MobileObject(a, w/2, h, depth);
193
- box2dCreateRevoluteJoint(this, o, a);
193
+ new Box2dRevoluteJoint(this, o, a);
194
194
  this.childMobiles.push(o);
195
195
  }
196
196
  }
@@ -232,9 +232,9 @@ class MotorJointObject extends Box2dObject
232
232
  super(pos, size, spriteAtlas.wheel, 0, color);
233
233
  this.addCircle(size.x);
234
234
  this.connectionPos = pos;
235
- const joint = box2dCreateMotorJoint(otherObject, this);
236
- joint.SetMaxForce(500);
237
- joint.SetMaxTorque(500);
235
+ const joint = new Box2dMotorJoint(otherObject, this);
236
+ joint.setMaxForce(500);
237
+ joint.setMaxTorque(500);
238
238
  }
239
239
  render()
240
240
  {
@@ -281,7 +281,7 @@ class SoftBodyObject extends Box2dObject
281
281
  const tryAddJoint = (xo, yo) =>
282
282
  {
283
283
  const o2 = this.getNode(x+xo, y+yo);
284
- const joint = o2 ? box2dCreateWeldJoint(o, o2) : 0;
284
+ const joint = o2 ? new Box2dWeldJoint(o, o2) : 0;
285
285
  o.joints.push(joint);
286
286
  }
287
287
 
@@ -300,7 +300,7 @@ class SoftBodyObject extends Box2dObject
300
300
  for (let y = 0; y < sy.y; ++y) poly.push(this.getNode(sx-1, y).pos);
301
301
  for (let x = sx; x--;) poly.push(this.getNode(x, sy-1).pos);
302
302
  for (let y = sy; y--;) poly.push(this.getNode(0, y).pos);
303
- box2dDrawPoly(vec2(), 0, poly, BLACK)
303
+ box2d.drawPoly(vec2(), 0, poly, BLACK)
304
304
  }
305
305
  getNode(x, y)
306
306
  {
@@ -321,7 +321,7 @@ class ClothObject extends Box2dObject
321
321
  {
322
322
  constructor(pos, scale, sizeCount, color, maxJointStress=10)
323
323
  {
324
- super(pos, vec2(), 0, 0, color, box2dBodyTypeStatic);
324
+ super(pos, vec2(), 0, 0, color, box2d.bodyTypeStatic);
325
325
  const nodeSize = sizeCount.subtract(vec2(1));
326
326
  const spacing = scale.divide(nodeSize);
327
327
  const objectDiameter = min(spacing.x, spacing.y);
@@ -357,7 +357,7 @@ class ClothObject extends Box2dObject
357
357
  const tryAddJoint = (xo, yo) =>
358
358
  {
359
359
  const o2 = this.getNode(x2+xo, y+yo);
360
- const joint = o2 ? box2dCreateRopeJoint(o, o2) : 0;
360
+ const joint = o2 ? new Box2dRopeJoint(o, o2) : 0;
361
361
  o.joints.push(joint);
362
362
  }
363
363
 
@@ -374,7 +374,7 @@ class ClothObject extends Box2dObject
374
374
  tryAddJoint( d, 1);
375
375
 
376
376
  // attach pin joint to top row
377
- y || box2dCreatePinJoint(this, this.getNode(x, y));
377
+ y || new Box2dPinJoint(this.getNode(x, y), this);
378
378
  }
379
379
  }
380
380
  }
@@ -398,15 +398,15 @@ class ClothObject extends Box2dObject
398
398
  const j = joints[i];
399
399
  if (!j) continue;
400
400
 
401
- const oA = j.GetBodyA().object;
402
- const oB = j.GetBodyB().object;
401
+ const oA = j.getObjectA();
402
+ const oB = j.getObjectB();
403
403
  const d2 = oA.pos.distanceSquared(oB.pos);
404
- const maxLength2 = j.GetMaxLength()**2;
405
- const stress = vec2(j.GetReactionForce(1)).length();
404
+ const maxLength2 = j.getMaxLength()**2;
405
+ const stress = j.getReactionForce(1).length();
406
406
  if (stress > this.maxJointStress || d2 > maxLength2*4)
407
407
  {
408
408
  // remove stressed joint
409
- box2dDestroyJoint(j);
409
+ j.destroy();
410
410
  joints[i] = 0;
411
411
  }
412
412
  }
@@ -428,8 +428,8 @@ class ClothObject extends Box2dObject
428
428
  for (const joint of o.joints)
429
429
  {
430
430
  if (!joint) continue;
431
- const oA = joint.GetBodyA().object;
432
- const oB = joint.GetBodyB().object;
431
+ const oA = joint.getObjectA();
432
+ const oB = joint.getObjectB();
433
433
  drawLine(oA.pos, oB.pos, this.lineWidth, BLACK);
434
434
  }
435
435
  }
@@ -450,7 +450,7 @@ const sound_explosion = new Sound([.5,.2,72,.01,.01,.2,4,,,,,,,1,,.5,.1,.5,.02])
450
450
  function explosion(pos, radius=3, strength=300)
451
451
  {
452
452
  sound_explosion.play(pos);
453
- const objects = box2dCircleCastAll(pos, (radius*2));
453
+ const objects = box2d.circleCastAll(pos, (radius*2));
454
454
  const newColor = randColor();
455
455
  for (const o of objects)
456
456
  {
@@ -6,9 +6,9 @@
6
6
  <link rel=icon type=image/png href=../favicon.png>
7
7
  </head><body>
8
8
 
9
- <script src=../../dist/littlejs.js></script>
10
- <script src=../../plugins/Box2D_v2.3.1_min.wasm.js?1117></script>
11
- <script src=../../plugins/box2d.js?1117></script>
12
- <script src=scenes.js?1117></script>
13
- <script src=gameObjects.js?1117></script>
14
- <script src=game.js?1117></script>
9
+ <script src=../../dist/littlejs.js?11115></script>
10
+ <script src=../../plugins/box2d.wasm.js?11115></script>
11
+ <script src=../../plugins/box2d.js?11115></script>
12
+ <script src=scenes.js?11115></script>
13
+ <script src=gameObjects.js?11115></script>
14
+ <script src=game.js?11115></script>
@@ -31,18 +31,18 @@ function loadScene(_scene)
31
31
  car = 0;
32
32
 
33
33
  // create walls
34
- groundObject = spawnBox(vec2(0,-4), vec2(1e3,8), hsl(0,0,.2), box2dBodyTypeStatic);
35
- spawnBox(vec2(-4, 0), vec2(8,1e3), BLACK, box2dBodyTypeStatic);
36
- spawnBox(vec2(44, 0), vec2(8,1e3), BLACK, box2dBodyTypeStatic);
37
- spawnBox(vec2(0,100), vec2(1e3,8), BLACK, box2dBodyTypeStatic);
34
+ groundObject = spawnBox(vec2(0,-4), vec2(1e3,8), hsl(0,0,.2), box2d.bodyTypeStatic);
35
+ spawnBox(vec2(-4, 0), vec2(8,1e3), BLACK, box2d.bodyTypeStatic);
36
+ spawnBox(vec2(44, 0), vec2(8,1e3), BLACK, box2d.bodyTypeStatic);
37
+ spawnBox(vec2(0,100), vec2(1e3,8), BLACK, box2d.bodyTypeStatic);
38
38
 
39
39
  if (scene == 0)
40
40
  {
41
41
  sceneName = 'Shapes';
42
42
  spawnRandomEdges();
43
- spawnBox(vec2(11,8), 4, randColor(), box2dBodyTypeStatic, false);
44
- spawnCircle(vec2(20,8), 4, randColor(), box2dBodyTypeStatic, false);
45
- spawnRandomPoly(vec2(29,8), 4, randColor(), box2dBodyTypeStatic, false);
43
+ spawnBox(vec2(11,8), 4, randColor(), box2d.bodyTypeStatic, false);
44
+ spawnCircle(vec2(20,8), 4, randColor(), box2d.bodyTypeStatic, false);
45
+ spawnRandomPoly(vec2(29,8), 4, randColor(), box2d.bodyTypeStatic, false);
46
46
  for (let i=500;i--;)
47
47
  spawnRandomObject(vec2(rand(1,39), rand(10,50)));
48
48
  }
@@ -60,14 +60,14 @@ function loadScene(_scene)
60
60
  spawnDominoes(vec2(2,0), 13, vec2(1,3));
61
61
  spawnCircle(vec2(10,20), 2, randColor());
62
62
  spawnCircle(vec2(31.7,12), 2, randColor());
63
- spawnBox(vec2(16,11), vec2(32,1), randColor(), box2dBodyTypeStatic, false);
64
- spawnBox(vec2(24,6.5), vec2(32,1), randColor(), box2dBodyTypeStatic, false, -.15);
63
+ spawnBox(vec2(16,11), vec2(32,1), randColor(), box2d.bodyTypeStatic, false);
64
+ spawnBox(vec2(24,6.5), vec2(32,1), randColor(), box2d.bodyTypeStatic, false, -.15);
65
65
  }
66
66
  if (scene == 3)
67
67
  {
68
68
  sceneName = 'Car';
69
69
  car = new CarObject(vec2(10,2));
70
- spawnBox(vec2(20,0), vec2(10,2), randColor(), box2dBodyTypeStatic, false, -.2);
70
+ spawnBox(vec2(20,0), vec2(10,2), randColor(), box2d.bodyTypeStatic, false, -.2);
71
71
  spawnPyramid(vec2(32,0), 6);
72
72
  }
73
73
  if (scene == 4)
@@ -84,7 +84,7 @@ function loadScene(_scene)
84
84
  const o = spawnBox(endPos, 3, randColor());
85
85
  o.setAngularDamping(.5);
86
86
  o.setFilterData(2, 2);
87
- box2dCreateRevoluteJoint(endObject, o);
87
+ new Box2dRevoluteJoint(endObject, o);
88
88
  spawnPyramid(vec2(20,0), 7);
89
89
  }
90
90
  if (scene == 5)
@@ -92,7 +92,7 @@ function loadScene(_scene)
92
92
  sceneName = 'Raycasts';
93
93
  spawnRandomEdges();
94
94
  for (let i=100;i--;)
95
- spawnRandomObject(vec2(rand(1,39), rand(20)), 2, box2dBodyTypeStatic, rand(PI*2));
95
+ spawnRandomObject(vec2(rand(1,39), rand(20)), 2, box2d.bodyTypeStatic, rand(PI*2));
96
96
  }
97
97
  if (scene == 6)
98
98
  {
@@ -100,9 +100,9 @@ function loadScene(_scene)
100
100
  {
101
101
  // prismatic joint
102
102
  const o1 = spawnBox(vec2(20,8), vec2(3,2), randColor());
103
- box2dCreatePrismaticJoint(groundObject, o1, o1.pos, vec2(1,0), true);
103
+ new Box2dPrismaticJoint(groundObject, o1, o1.pos, vec2(1,0), true);
104
104
  const o2 = spawnBox(vec2(20,15), vec2(2,3), randColor());
105
- box2dCreatePrismaticJoint(groundObject, o2, o2.pos, vec2(0,1), true);
105
+ new Box2dPrismaticJoint(groundObject, o2, o2.pos, vec2(0,1), true);
106
106
 
107
107
  // lines to make it look line a track
108
108
  const l1 = new EngineObject(vec2(20, 8), vec2(39,.5), 0, 0, GRAY);
@@ -116,11 +116,11 @@ function loadScene(_scene)
116
116
  const anchorB = vec2(26,15);
117
117
  const oA = new PulleyJointObjects(vec2(15,8), vec2(1,2), randColor(), anchorA);
118
118
  const oB = new PulleyJointObjects(vec2(25,8), vec2(1,2), randColor(), anchorB);
119
- const aA = spawnCircle(anchorA, 2, randColor(), box2dBodyTypeStatic);
120
- const aB = spawnCircle(anchorB, 2, randColor(), box2dBodyTypeStatic);
119
+ const aA = spawnCircle(anchorA, 2, randColor(), box2d.bodyTypeStatic);
120
+ const aB = spawnCircle(anchorB, 2, randColor(), box2d.bodyTypeStatic);
121
121
  const oaA = oA.localToWorld(vec2(0,oA.size.y/2));
122
122
  const oaB = oB.localToWorld(vec2(0,oB.size.y/2));
123
- box2dCreatePulleyJoint(oA, oB, aA.pos, aB.pos, oaA, oaB);
123
+ new Box2dPulleyJoint(oA, oB, aA.pos, aB.pos, oaA, oaB);
124
124
 
125
125
  // a line to make it look like connecting rope
126
126
  const line = new EngineObject(vec2(20,15), vec2(10,.2), 0, 0, BLACK);
@@ -130,28 +130,28 @@ function loadScene(_scene)
130
130
  {
131
131
  // gear joint
132
132
  const o1 = spawnCircle(vec2(23.5,3), 3, randColor());
133
- const j1 = box2dCreateRevoluteJoint(groundObject, o1, o1.pos);
133
+ const j1 = new Box2dRevoluteJoint(groundObject, o1, o1.pos);
134
134
  const o2 = spawnCircle(vec2(28,3), 6, randColor());
135
135
  o1.tileInfo = o2.tileInfo = spriteAtlas.gear;
136
- const j2 = box2dCreateRevoluteJoint(groundObject, o2, o2.pos);
137
- box2dCreateGearJoint(o1, o2, j1, j2, 2);
136
+ const j2 = new Box2dRevoluteJoint(groundObject, o2, o2.pos);
137
+ new Box2dGearJoint(o1, o2, j1, j2, 2);
138
138
  }
139
139
  {
140
140
  // weld joint
141
141
  const o1 = spawnBox(vec2(15,2), 4, randColor());
142
142
  const o2 = spawnBox(vec2(17,2), 2, randColor());
143
- box2dCreateWeldJoint(o1, o2);
143
+ new Box2dWeldJoint(o1, o2);
144
144
  }
145
145
  {
146
146
  // distance joint
147
- const o1 = new Box2dObject(vec2(30,11), vec2(4), spriteAtlas.circleOutline, 0, randColor(), box2dBodyTypeStatic);
147
+ const o1 = new Box2dObject(vec2(30,11), vec2(4), spriteAtlas.circleOutline, 0, randColor(), box2d.bodyTypeStatic);
148
148
  o1.renderOrder = -2;
149
149
  const o2 = spawnCircle(vec2(30,8), 2, randColor());
150
- box2dCreateDistanceJoint(o1, o2);
150
+ new Box2dDistanceJoint(o1, o2);
151
151
  }
152
152
  {
153
153
  // motor joint
154
- const o = new Box2dObject(vec2(10,8), vec2(4), spriteAtlas.circleOutline, 0, randColor(), box2dBodyTypeStatic);
154
+ const o = new Box2dObject(vec2(10,8), vec2(4), spriteAtlas.circleOutline, 0, randColor(), box2d.bodyTypeStatic);
155
155
  o.renderOrder = -2;
156
156
  new MotorJointObject(vec2(10,8), vec2(2), randColor(), o);
157
157
  }
@@ -159,9 +159,9 @@ function loadScene(_scene)
159
159
  // friction joint
160
160
  const o = spawnBox(vec2(10,15), 3, randColor());
161
161
  o.tileInfo = spriteAtlas.squareOutline2;
162
- const joint = box2dCreateFrictionJoint(groundObject, o);
163
- joint.SetMaxForce(200);
164
- joint.SetMaxTorque(200);
162
+ const joint = new Box2dFrictionJoint(groundObject, o);
163
+ joint.setMaxForce(200);
164
+ joint.setMaxTorque(200);
165
165
  }
166
166
  }
167
167
  if (scene == 7)
@@ -177,7 +177,7 @@ function loadScene(_scene)
177
177
  sceneName = 'Mobile';
178
178
  const pos = vec2(20, 16);
179
179
  const mobile = new MobileObject(pos, 12, 2, 5);
180
- box2dCreateRevoluteJoint(groundObject, mobile, pos);
180
+ new Box2dRevoluteJoint(groundObject, mobile, pos);
181
181
  }
182
182
  if (scene == 9)
183
183
  {
@@ -8,9 +8,6 @@
8
8
 
9
9
  'use strict';
10
10
 
11
- // show the LittleJS splash screen
12
- setShowSplashScreen(true);
13
-
14
11
  let levelSize, ball, paddle, score, brickCount;
15
12
 
16
13
  // sound effects
@@ -131,7 +128,7 @@ function setupPostProcess()
131
128
  }`;
132
129
 
133
130
  const includeOverlay = true;
134
- initPostProcess(televisionShader, includeOverlay);
131
+ new PostProcessPlugin(televisionShader, includeOverlay);
135
132
  }
136
133
 
137
134
  ///////////////////////////////////////////////////////////////////////////////
@@ -6,7 +6,7 @@
6
6
  <link rel=icon type=image/png href=../favicon.png>
7
7
  </head><body>
8
8
 
9
- <script src=../../dist/littlejs.js?1117></script>
10
- <script src=../../plugins/postProcess.js?1117></script>
11
- <script src=gameObjects.js?1117></script>
12
- <script src=game.js?1117></script>
9
+ <script src=../../dist/littlejs.js?11115></script>
10
+ <script src=../../plugins/postProcess.js?11115></script>
11
+ <script src=gameObjects.js?11115></script>
12
+ <script src=game.js?11115></script>
@@ -6,5 +6,5 @@
6
6
  <link rel=icon type=image/png href=../favicon.png>
7
7
  </head><body>
8
8
 
9
- <script src=../../dist/littlejs.js?1117></script>
10
- <script src=game.js?1117></script>
9
+ <script src=../../dist/littlejs.js?11115></script>
10
+ <script src=game.js?11115></script>
@@ -1,16 +1,13 @@
1
1
  /*
2
2
  Little JS HTML Menu Example Project
3
3
  - Setup a simple html menu system
4
- - Menu can be toggled
4
+ - Menu can be opened and closed
5
5
  - Pauses game when menu is visible
6
6
  - Shows several input types
7
7
  */
8
8
 
9
9
  'use strict';
10
10
 
11
- // show the LittleJS splash screen
12
- setShowSplashScreen(true);
13
-
14
11
  // sound effects
15
12
  const sound_click = new Sound([1,.5]);
16
13
 
@@ -46,7 +43,7 @@ function gameUpdatePost()
46
43
  const menuVisible = getMenuVisible();
47
44
  paused = menuVisible;
48
45
 
49
- // toggle menu visibility
46
+ // open menu visibility
50
47
  if (keyWasPressed('KeyM'))
51
48
  setMenuVisible(true);
52
49
  }
@@ -67,7 +64,7 @@ function gameRender()
67
64
  function gameRenderPost()
68
65
  {
69
66
  // draw to overlay canvas for hud rendering
70
- drawTextScreen('LittleJS HTML Menu Example\nM = Toggle menu',
67
+ drawTextScreen('LittleJS HTML Menu Example\nM = Open menu',
71
68
  vec2(mainCanvasSize.x/2, 70), 60, // position, size
72
69
  hsl(0,0,1), 6, hsl(0,0,0)); // color, outline size and color
73
70
  }
@@ -43,5 +43,5 @@ This is an example menu using html elements.
43
43
  </div>
44
44
 
45
45
  <!-- Add your game scripts here -->
46
- <script src=../../dist/littlejs.js?1117></script>
47
- <script src=game.js?1117></script>
46
+ <script src=../../dist/littlejs.js?11115></script>
47
+ <script src=game.js?11115></script>
@@ -7,4 +7,4 @@
7
7
  </head><body>
8
8
 
9
9
  <!-- Add your game scripts here -->
10
- <script src=game.js?1117 type=module></script>
10
+ <script src=game.js?11115 type=module></script>
@@ -10,7 +10,7 @@ button { margin:1px; }
10
10
  </style>
11
11
  </head><body>
12
12
 
13
- <script src=../../dist/littlejs.js?1117></script>
13
+ <script src=../../dist/littlejs.js?11115></script>
14
14
  <script>
15
15
 
16
16
  'use strict';
@@ -8,9 +8,6 @@
8
8
 
9
9
  'use strict';
10
10
 
11
- // show the LittleJS splash screen
12
- setShowSplashScreen(true);
13
-
14
11
  let spriteAtlas, score, deaths;
15
12
 
16
13
  // enable touch gamepad on touch devices
@@ -7,11 +7,11 @@
7
7
  <link rel=icon type=image/png href=../favicon.png>
8
8
  </head><body>
9
9
 
10
- <script src=../../dist/littlejs.js?1117></script>
11
- <script src=gameObjects.js?1117></script>
12
- <script src=gameCharacter.js?1117></script>
13
- <script src=gamePlayer.js?1117></script>
14
- <script src=gameEffects.js?1117></script>
15
- <script src=gameLevel.js?1117></script>
16
- <script src=gameLevelData.js?1117></script>
17
- <script src=game.js?1117></script>
10
+ <script src=../../dist/littlejs.js?11115></script>
11
+ <script src=gameObjects.js?11115></script>
12
+ <script src=gameCharacter.js?11115></script>
13
+ <script src=gamePlayer.js?11115></script>
14
+ <script src=gameEffects.js?11115></script>
15
+ <script src=gameLevel.js?11115></script>
16
+ <script src=gameLevelData.js?11115></script>
17
+ <script src=game.js?11115></script>
@@ -8,9 +8,6 @@
8
8
 
9
9
  'use strict';
10
10
 
11
- // show the LittleJS splash screen
12
- setShowSplashScreen(true);
13
-
14
11
  // do not use pixelated rendering
15
12
  setCanvasPixelated(false);
16
13
  setTilesPixelated(false);
@@ -6,5 +6,5 @@
6
6
  <link rel=icon type=image/png href=../favicon.png>
7
7
  </head><body>
8
8
 
9
- <script src=../../dist/littlejs.js?1117></script>
10
- <script src=game.js?1117></script>
9
+ <script src=../../dist/littlejs.js?11115></script>
10
+ <script src=game.js?11115></script>
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html><meta charset=utf-8><body>
2
- <script src=../../dist/littlejs.js?1117></script>
2
+ <script src=../../dist/littlejs.js?11115></script>
3
3
  <script>
4
4
 
5
5
  'use strict';
@@ -102,6 +102,7 @@ function htmlBuildStep(filename)
102
102
  let buffer = '<!DOCTYPE html>';
103
103
  buffer += '<head>';
104
104
  buffer += `<title>${PROGRAM_TITLE}</title>`;
105
+ buffer += '<meta charset=utf-8>';
105
106
  buffer += '</head>';
106
107
  buffer += '<body>';
107
108
  buffer += '<script>';
@@ -115,8 +116,7 @@ function htmlBuildStep(filename)
115
116
  function zipBuildStep(filename)
116
117
  {
117
118
  console.log(`Zipping...`);
118
-
119
- // zip the build folder using ect
120
- const args = ['-9', '-strip', '-zip', `../${PROGRAM_NAME}.zip`, 'index.html', ...dataFiles];
121
- child_process.spawnSync('ect', args, {stdio: 'inherit', cwd: BUILD_FOLDER});
119
+ const sources = ['index.html', ...dataFiles];
120
+ const sourceList = sources.join(' ');
121
+ child_process.execSync(`npx bestzip ../${PROGRAM_NAME}.zip ${sourceList}`, {cwd:BUILD_FOLDER, stdio: 'inherit'});
122
122
  };
@@ -7,18 +7,18 @@
7
7
  </head><body>
8
8
 
9
9
  <!-- LittleJS Engine -->
10
- <script src=../../src/engineDebug.js?1117></script>
11
- <script src=../../src/engineUtilities.js?1117></script>
12
- <script src=../../src/engineSettings.js?1117></script>
13
- <script src=../../src/engineObject.js?1117></script>
14
- <script src=../../src/engineDraw.js?1117></script>
15
- <script src=../../src/engineInput.js?1117></script>
16
- <script src=../../src/engineAudio.js?1117></script>
17
- <script src=../../src/engineTileLayer.js?1117></script>
18
- <script src=../../src/engineParticles.js?1117></script>
19
- <script src=../../src/engineMedals.js?1117></script>
20
- <script src=../../src/engineWebGL.js?1117></script>
21
- <script src=../../src/engine.js?1117></script>
10
+ <script src=../../src/engineDebug.js?11115></script>
11
+ <script src=../../src/engineUtilities.js?11115></script>
12
+ <script src=../../src/engineSettings.js?11115></script>
13
+ <script src=../../src/engineObject.js?11115></script>
14
+ <script src=../../src/engineDraw.js?11115></script>
15
+ <script src=../../src/engineInput.js?11115></script>
16
+ <script src=../../src/engineAudio.js?11115></script>
17
+ <script src=../../src/engineTileLayer.js?11115></script>
18
+ <script src=../../src/engineParticles.js?11115></script>
19
+ <script src=../../src/engineMedals.js?11115></script>
20
+ <script src=../../src/engineWebGL.js?11115></script>
21
+ <script src=../../src/engine.js?11115></script>
22
22
 
23
23
  <!-- Add your game scripts here -->
24
- <script src=game.js?1117></script>
24
+ <script src=game.js?11115></script>