littlejsengine 1.12.6 → 1.13.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.
- package/dist/littlejs.d.ts +387 -177
- package/dist/littlejs.esm.js +5934 -5294
- package/dist/littlejs.esm.min.js +4 -1
- package/dist/littlejs.js +5887 -5263
- package/dist/littlejs.min.js +4 -1
- package/dist/littlejs.release.js +5426 -4829
- package/examples/box2d/game.js +1 -1
- package/examples/box2d/gameObjects.js +7 -6
- package/examples/box2d/index.html +1 -1
- package/examples/box2d/scenes.js +7 -7
- package/examples/breakout/game.js +1 -1
- package/examples/breakout/gameObjects.js +2 -2
- package/examples/breakout/index.html +1 -1
- package/examples/breakoutTutorial/README.md +2 -2
- package/examples/breakoutTutorial/game.js +1 -1
- package/examples/breakoutTutorial/index.html +1 -1
- package/examples/empty/index.html +1 -1
- package/examples/htmlMenu/index.html +1 -1
- package/examples/index.html +396 -153
- package/examples/module/game.js +1 -1
- package/examples/module/index.html +1 -1
- package/examples/platformer/game.js +4 -4
- package/examples/platformer/gameCharacter.js +6 -6
- package/examples/platformer/gameEffects.js +74 -57
- package/examples/platformer/gameLevel.js +61 -70
- package/examples/platformer/gameObjects.js +4 -4
- package/examples/platformer/index.html +1 -1
- package/examples/puzzle/index.html +1 -1
- package/examples/shorts/base.html +23 -3
- package/examples/shorts/box2dCar.js +8 -12
- package/examples/shorts/flappyGame.js +52 -0
- package/examples/shorts/helloWorld.js +6 -3
- package/examples/shorts/hillGlideGame.js +56 -0
- package/examples/shorts/landerGame.js +32 -0
- package/examples/shorts/maze.js +47 -0
- package/examples/shorts/medals.js +42 -0
- package/examples/shorts/nineSlice.js +21 -0
- package/examples/shorts/piano.js +52 -0
- package/examples/shorts/platformer.js +24 -20
- package/examples/shorts/{pong.js → pongGame.js} +1 -1
- package/examples/shorts/raycasting.js +71 -0
- package/examples/shorts/slidingPuzzle.js +42 -0
- package/examples/shorts/spaceGame.js +56 -0
- package/examples/shorts/starfield.js +17 -0
- package/examples/shorts/tileLayer.js +3 -5
- package/examples/shorts/tiles.png +0 -0
- package/examples/shorts/tiltedView.js +8 -7
- package/examples/shorts/topDown.js +18 -26
- package/examples/shorts/uiSystem.js +4 -7
- package/examples/starter/build.bat +6 -1
- package/examples/starter/game.js +2 -2
- package/examples/starter/index.html +23 -13
- package/examples/stress/index.html +2 -3
- package/examples/style.css +136 -0
- package/examples/typescript/build.js +1 -2
- package/examples/typescript/game.js +2 -2
- package/examples/typescript/game.ts +1 -1
- package/examples/typescript/index.html +1 -1
- package/examples/uiSystem/game.js +8 -24
- package/examples/uiSystem/index.html +1 -1
- package/package.json +1 -1
- package/plugins/box2d.js +8 -8
- package/plugins/drawUtilities.js +126 -0
- package/plugins/newgrounds.js +1 -1
- package/plugins/pluginExport.js +7 -1
- package/plugins/postProcess.js +2 -2
- package/plugins/uiSystem.js +153 -65
- package/plugins/zzfxm.js +1 -1
- package/reference.md +10 -10
- package/src/engine.js +50 -29
- package/src/engineAudio.js +14 -5
- package/src/engineBuild.bat +6 -1
- package/src/engineBuild.js +20 -5
- package/src/engineDebug.js +53 -26
- package/src/engineDraw.js +108 -57
- package/src/engineExport.js +21 -9
- package/src/engineInput.js +109 -37
- package/src/engineObject.js +68 -67
- package/src/engineParticles.js +26 -9
- package/src/engineSettings.js +15 -16
- package/src/engineTileLayer.js +312 -153
- package/src/engineUtilities.js +182 -130
- package/src/engineWebGL.js +47 -36
package/examples/box2d/game.js
CHANGED
|
@@ -118,7 +118,7 @@ function gameUpdate()
|
|
|
118
118
|
GameObjects.explosion(LJS.mousePos);
|
|
119
119
|
|
|
120
120
|
if (LJS.keyWasPressed('KeyR'))
|
|
121
|
-
setScene(scene); // reset scene
|
|
121
|
+
setScene(Scenes.scene); // reset scene
|
|
122
122
|
if (LJS.keyWasPressed('ArrowUp') || LJS.keyWasPressed('ArrowDown'))
|
|
123
123
|
{
|
|
124
124
|
// change scene
|
|
@@ -63,7 +63,7 @@ export function spawnPyramid(pos, count)
|
|
|
63
63
|
spawnBox(pos.add(vec2(j-i/2+.5,count-i+.5)), 1, LJS.randColor());
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export function spawnDominoes(pos, count, size=vec2(.5,
|
|
66
|
+
export function spawnDominoes(pos, count, size=vec2(.5,3))
|
|
67
67
|
{
|
|
68
68
|
for (let i=count; i--;)
|
|
69
69
|
spawnBox(pos.add(vec2(i*size.y*.9,size.y/2)), size, LJS.randColor());
|
|
@@ -105,7 +105,7 @@ export class CarObject extends LJS.Box2dObject
|
|
|
105
105
|
{
|
|
106
106
|
constructor(pos)
|
|
107
107
|
{
|
|
108
|
-
super(pos, vec2(), 0, 0, LJS.
|
|
108
|
+
super(pos, vec2(), 0, 0, LJS.randColor());
|
|
109
109
|
const carPoints = [
|
|
110
110
|
vec2(-1.5,-.5),
|
|
111
111
|
vec2(1.5, -.5),
|
|
@@ -147,14 +147,14 @@ export class CarObject extends LJS.Box2dObject
|
|
|
147
147
|
}
|
|
148
148
|
update()
|
|
149
149
|
{
|
|
150
|
+
super.update();
|
|
151
|
+
|
|
150
152
|
// car controls
|
|
151
153
|
const maxSpeed = 40;
|
|
152
|
-
const brakeAmount = .8;
|
|
153
154
|
const input = LJS.keyDirection().x;
|
|
154
155
|
let s = this.wheelMotorJoint.getMotorSpeed();
|
|
155
|
-
s = input ? LJS.clamp(s - input, -maxSpeed, maxSpeed) :
|
|
156
|
+
s = input ? LJS.clamp(s - input, -maxSpeed, maxSpeed) : 0;
|
|
156
157
|
this.wheelMotorJoint.setMotorSpeed(s);
|
|
157
|
-
super.update();
|
|
158
158
|
}
|
|
159
159
|
destroy()
|
|
160
160
|
{
|
|
@@ -393,6 +393,8 @@ export class ClothObject extends LJS.Box2dObject
|
|
|
393
393
|
}
|
|
394
394
|
update()
|
|
395
395
|
{
|
|
396
|
+
super.update();
|
|
397
|
+
|
|
396
398
|
for (let y=this.sizeCount.y; y--;)
|
|
397
399
|
for (let x=this.sizeCount.x; x--;)
|
|
398
400
|
{
|
|
@@ -425,7 +427,6 @@ export class ClothObject extends LJS.Box2dObject
|
|
|
425
427
|
this.nodes[y*this.sizeCount.x+x] = 0;
|
|
426
428
|
}
|
|
427
429
|
}
|
|
428
|
-
super.update();
|
|
429
430
|
}
|
|
430
431
|
render()
|
|
431
432
|
{
|
package/examples/box2d/scenes.js
CHANGED
|
@@ -35,7 +35,7 @@ export function loadScene(_scene)
|
|
|
35
35
|
GameObjects.spawnRandomEdges();
|
|
36
36
|
GameObjects.spawnBox(vec2(11,8), 4, LJS.randColor(), LJS.box2d.bodyTypeStatic, false);
|
|
37
37
|
GameObjects.spawnCircle(vec2(20,8), 4, LJS.randColor(), LJS.box2d.bodyTypeStatic, false);
|
|
38
|
-
GameObjects.spawnRandomPoly(vec2(29,8), 4, LJS.randColor(), LJS.box2d.bodyTypeStatic
|
|
38
|
+
GameObjects.spawnRandomPoly(vec2(29,8), 4, LJS.randColor(), LJS.box2d.bodyTypeStatic);
|
|
39
39
|
for (let i=500;i--;)
|
|
40
40
|
GameObjects.spawnRandomObject(vec2(LJS.rand(1,39), LJS.rand(10,50)));
|
|
41
41
|
}
|
|
@@ -49,12 +49,12 @@ export function loadScene(_scene)
|
|
|
49
49
|
if (scene == 2)
|
|
50
50
|
{
|
|
51
51
|
sceneName = 'Dominoes';
|
|
52
|
-
GameObjects.spawnDominoes(vec2(11,
|
|
53
|
-
GameObjects.spawnDominoes(vec2(
|
|
54
|
-
GameObjects.spawnCircle(vec2(10,20),
|
|
55
|
-
GameObjects.spawnCircle(vec2(31.
|
|
56
|
-
GameObjects.spawnBox(vec2(16,
|
|
57
|
-
GameObjects.spawnBox(vec2(24,
|
|
52
|
+
GameObjects.spawnDominoes(vec2(11,13), 8);
|
|
53
|
+
GameObjects.spawnDominoes(vec2(3,0), 10, vec2(1,4));
|
|
54
|
+
GameObjects.spawnCircle(vec2(10.2,20), 1.5, LJS.randColor());
|
|
55
|
+
GameObjects.spawnCircle(vec2(31.9,15), 2.5, LJS.randColor());
|
|
56
|
+
GameObjects.spawnBox(vec2(16,13), vec2(32,1), LJS.randColor(), LJS.box2d.bodyTypeStatic, false);
|
|
57
|
+
GameObjects.spawnBox(vec2(24,8), vec2(34,1), LJS.randColor(), LJS.box2d.bodyTypeStatic, false, -.15);
|
|
58
58
|
}
|
|
59
59
|
if (scene == 3)
|
|
60
60
|
{
|
|
@@ -104,7 +104,7 @@ function gameRenderPost()
|
|
|
104
104
|
{
|
|
105
105
|
// use built in image font for text
|
|
106
106
|
const font = new LJS.FontImage;
|
|
107
|
-
font.drawText('Score: ' + score, LJS.cameraPos.add(vec2(0,
|
|
107
|
+
font.drawText('Score: ' + score, LJS.cameraPos.add(vec2(0,9.7)), .15, true);
|
|
108
108
|
if (!brickCount)
|
|
109
109
|
font.drawText('You Win!', LJS.cameraPos.add(vec2(0,-5)), .2, true);
|
|
110
110
|
else if (!ball)
|
|
@@ -31,7 +31,7 @@ export class Wall extends PhysicsObject
|
|
|
31
31
|
{
|
|
32
32
|
constructor(pos, size)
|
|
33
33
|
{
|
|
34
|
-
super(pos, size, 0, 0, hsl(0,0,0));
|
|
34
|
+
super(pos, size, 0, 0, hsl(0,0,0,0));
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -103,7 +103,7 @@ export class Ball extends PhysicsObject
|
|
|
103
103
|
|
|
104
104
|
// make a bouncy ball
|
|
105
105
|
this.velocity = vec2(0, -.1);
|
|
106
|
-
this.
|
|
106
|
+
this.restitution = 1;
|
|
107
107
|
this.mass = 1;
|
|
108
108
|
|
|
109
109
|
// attach a trail effect
|
|
@@ -189,10 +189,10 @@ Now the ball collides but unfortunately also pushes the paddle away, not quite w
|
|
|
189
189
|
this.mass = 0; // make object have static physics
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
Getting closer, the paddle is not pushed away but the ball doesn’t bounce either. To make it bounce, we need to set the ball’s
|
|
192
|
+
Getting closer, the paddle is not pushed away but the ball doesn’t bounce either. To make it bounce, we need to set the ball’s restitution which controls how much it will bounce.
|
|
193
193
|
|
|
194
194
|
```javascript
|
|
195
|
-
this.
|
|
195
|
+
this.restitution = 1; // make object bounce
|
|
196
196
|
```
|
|
197
197
|
|
|
198
198
|

|
|
@@ -52,7 +52,7 @@ class Ball extends LJS.EngineObject
|
|
|
52
52
|
|
|
53
53
|
this.velocity = vec2(-.1, -.1); // give ball some movement
|
|
54
54
|
this.setCollision(); // make object collide
|
|
55
|
-
this.
|
|
55
|
+
this.restitution = 1; // make object bounce
|
|
56
56
|
}
|
|
57
57
|
collideWithObject(o)
|
|
58
58
|
{
|