littlejsengine 1.2.0 → 1.3.0
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/README.md +5 -9
- package/build.bat +5 -5
- package/buildSetup.bat +7 -0
- package/engine/engine.all.js +193 -125
- package/engine/engine.all.min.js +1 -1
- package/engine/engine.all.release.js +183 -110
- package/engine/engine.js +10 -33
- package/engine/engineBuild.bat +3 -3
- package/engine/engineDebug.js +10 -15
- package/engine/engineDraw.js +38 -17
- package/engine/engineFont.png +0 -0
- package/engine/engineInput.js +22 -6
- package/engine/engineMedals.js +7 -4
- package/engine/engineObject.js +17 -1
- package/engine/engineParticles.js +5 -3
- package/engine/engineSettings.js +5 -0
- package/engine/engineTileLayer.js +11 -10
- package/engine/engineUtilities.js +38 -6
- package/engine/engineWebGL.js +30 -30
- package/engine/index.d.ts +55 -21
- package/examples/breakout/gameObjects.js +2 -2
- package/examples/breakout/index.html +3 -3
- package/examples/particles/index.html +366 -0
- package/examples/particles/tiles.png +0 -0
- package/examples/platformer/game.js +4 -4
- package/examples/platformer/gameEffects.js +9 -9
- package/examples/platformer/gameObjects.js +2 -2
- package/examples/platformer/index.html +6 -6
- package/examples/puzzle/game.js +2 -2
- package/examples/puzzle/index.html +2 -2
- package/examples/screenshot.jpg +0 -0
- package/examples/stress/index.html +2 -2
- package/game.js +4 -4
- package/index.html +13 -13
- package/package.json +1 -1
- package/engine/engineBuildSetup.bat +0 -7
|
@@ -39,7 +39,7 @@ function makeDebris(pos, color = new Color, amount = 100, size=.2, elasticity =
|
|
|
39
39
|
{
|
|
40
40
|
const color2 = color.lerp(new Color, .5);
|
|
41
41
|
const emitter = new ParticleEmitter(
|
|
42
|
-
pos, 1, .1, 100, PI, // pos, emitSize, emitTime, emitRate, emiteCone
|
|
42
|
+
pos, 0, 1, .1, 100, PI, // pos, angle, emitSize, emitTime, emitRate, emiteCone
|
|
43
43
|
undefined, undefined, // tileIndex, tileSize
|
|
44
44
|
color, color2, // colorStartA, colorStartB
|
|
45
45
|
color, color2, // colorEndA, colorEndB
|
|
@@ -100,7 +100,7 @@ function explosion(pos, radius=3)
|
|
|
100
100
|
|
|
101
101
|
// smoke
|
|
102
102
|
new ParticleEmitter(
|
|
103
|
-
pos, radius/2, .2, 50*radius, PI, // pos, emitSize, emitTime, emitRate, emiteCone
|
|
103
|
+
pos, 0, radius/2, .2, 50*radius, PI, // pos, angle, emitSize, emitTime, emitRate, emiteCone
|
|
104
104
|
0, undefined, // tileIndex, tileSize
|
|
105
105
|
new Color(0,0,0), new Color(0,0,0), // colorStartA, colorStartB
|
|
106
106
|
new Color(0,0,0,0), new Color(0,0,0,0), // colorEndA, colorEndB
|
|
@@ -111,7 +111,7 @@ function explosion(pos, radius=3)
|
|
|
111
111
|
|
|
112
112
|
// fire
|
|
113
113
|
new ParticleEmitter(
|
|
114
|
-
pos, radius/2, .1, 100*radius, PI, // pos, emitSize, emitTime, emitRate, emiteCone
|
|
114
|
+
pos, 0, radius/2, .1, 100*radius, PI, // pos, angle, emitSize, emitTime, emitRate, emiteCone
|
|
115
115
|
0, undefined, // tileIndex, tileSize
|
|
116
116
|
new Color(1,.5,.1), new Color(1,.1,.1), // colorStartA, colorStartB
|
|
117
117
|
new Color(1,.5,.1,0), new Color(1,.1,.1,0), // colorEndA, colorEndB
|
|
@@ -203,7 +203,7 @@ function decorateTile(pos)
|
|
|
203
203
|
|
|
204
204
|
// make pixel perfect outlines
|
|
205
205
|
const size = i&1 ? vec2(2, 16) : vec2(16, 2);
|
|
206
|
-
tileLayer.context.fillStyle = levelGroundColor.mutate(.1)
|
|
206
|
+
tileLayer.context.fillStyle = levelGroundColor.mutate(.1);
|
|
207
207
|
const drawPos = pos.scale(16)
|
|
208
208
|
.add(vec2(i==1?14:0,(i==0?14:0)))
|
|
209
209
|
.subtract((i&1? vec2(0,8-size.y/2) : vec2(8-size.x/2,0)));
|
|
@@ -228,8 +228,8 @@ function drawSky()
|
|
|
228
228
|
{
|
|
229
229
|
// fill background with a gradient
|
|
230
230
|
const gradient = mainContext.fillStyle = mainContext.createLinearGradient(0, 0, 0, mainCanvas.height);
|
|
231
|
-
gradient.addColorStop(0, skyColor
|
|
232
|
-
gradient.addColorStop(1, horizonColor
|
|
231
|
+
gradient.addColorStop(0, skyColor);
|
|
232
|
+
gradient.addColorStop(1, horizonColor);
|
|
233
233
|
mainContext.fillRect(0, 0, mainCanvas.width, mainCanvas.height);
|
|
234
234
|
}
|
|
235
235
|
|
|
@@ -257,7 +257,7 @@ function drawStars()
|
|
|
257
257
|
(randSeeded(w)+time*speed)%w-extraSpace,
|
|
258
258
|
(randSeeded(h)+time*speed*randSeeded())%h-extraSpace);
|
|
259
259
|
|
|
260
|
-
mainContext.fillStyle = color
|
|
260
|
+
mainContext.fillStyle = color;
|
|
261
261
|
if (size < 9)
|
|
262
262
|
mainContext.fillRect(screenPos.x, screenPos.y, size, size);
|
|
263
263
|
else
|
|
@@ -285,8 +285,8 @@ function initParallaxLayers()
|
|
|
285
285
|
const layerColor = levelColor.mutate(.2).lerp(skyColor,.95-i*.15);
|
|
286
286
|
const gradient = tileParallaxLayer.context.fillStyle =
|
|
287
287
|
tileParallaxLayer.context.createLinearGradient(0,0,0,tileParallaxLayer.canvas.height = parallaxSize.y);
|
|
288
|
-
gradient.addColorStop(0,layerColor
|
|
289
|
-
gradient.addColorStop(1,layerColor.subtract(new Color(1,1,1,0)).mutate(.1).clamp()
|
|
288
|
+
gradient.addColorStop(0,layerColor);
|
|
289
|
+
gradient.addColorStop(1,layerColor.subtract(new Color(1,1,1,0)).mutate(.1).clamp());
|
|
290
290
|
|
|
291
291
|
// draw mountains ranges
|
|
292
292
|
let groundLevel = startGroundLevel, groundSlope = rand(-1,1);
|
|
@@ -210,7 +210,7 @@ class Weapon extends EngineObject
|
|
|
210
210
|
|
|
211
211
|
// shell effect
|
|
212
212
|
this.addChild(this.shellEmitter = new ParticleEmitter(
|
|
213
|
-
vec2(), 0, 0, 0, .1, // pos, emitSize, emitTime, emitRate, emiteCone
|
|
213
|
+
vec2(), 0, 0, 0, 0, .1, // pos, angle, emitSize, emitTime, emitRate, emiteCone
|
|
214
214
|
undefined, undefined, // tileIndex, tileSize
|
|
215
215
|
new Color(1,.8,.5), new Color(.9,.7,.5), // colorStartA, colorStartB
|
|
216
216
|
new Color(1,.8,.5), new Color(.9,.7,.5), // colorEndA, colorEndB
|
|
@@ -321,7 +321,7 @@ class Bullet extends EngineObject
|
|
|
321
321
|
|
|
322
322
|
// spark effects
|
|
323
323
|
const emitter = new ParticleEmitter(
|
|
324
|
-
this.pos, 0, .1, 100, .5, // pos, emitSize, emitTime, emitRate, emiteCone
|
|
324
|
+
this.pos, 0, 0, .1, 100, .5, // pos, angle, emitSize, emitTime, emitRate, emiteCone
|
|
325
325
|
undefined, undefined, // tileIndex, tileSize
|
|
326
326
|
new Color(1,1,0), new Color(1,0,0), // colorStartA, colorStartB
|
|
327
327
|
new Color(1,1,0), new Color(1,0,0), // colorEndA, colorEndB
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
<link rel=icon type=image/png href=../../favicon.png>
|
|
6
6
|
</head><body>
|
|
7
7
|
|
|
8
|
-
<script src=../../engine/engine.all.js?
|
|
9
|
-
<script src=gameObjects.js?
|
|
10
|
-
<script src=gamePlayer.js?
|
|
11
|
-
<script src=gameEffects.js?
|
|
12
|
-
<script src=gameLevel.js?
|
|
13
|
-
<script src=game.js?
|
|
8
|
+
<script src=../../engine/engine.all.js?104></script>
|
|
9
|
+
<script src=gameObjects.js?104></script>
|
|
10
|
+
<script src=gamePlayer.js?104></script>
|
|
11
|
+
<script src=gameEffects.js?104></script>
|
|
12
|
+
<script src=gameLevel.js?104></script>
|
|
13
|
+
<script src=game.js?103></script>
|
package/examples/puzzle/game.js
CHANGED
|
@@ -43,7 +43,7 @@ function gameInit()
|
|
|
43
43
|
{
|
|
44
44
|
// setup canvas
|
|
45
45
|
canvasFixedSize = vec2(1920, 1080); // 1080p
|
|
46
|
-
mainCanvas.style.background = backgroundColor
|
|
46
|
+
mainCanvas.style.background = backgroundColor;
|
|
47
47
|
|
|
48
48
|
// load high score
|
|
49
49
|
bestScore = localStorage[highScoreKey] || 0;
|
|
@@ -284,7 +284,7 @@ function clearMatches()
|
|
|
284
284
|
const color1 = tileColors[data];
|
|
285
285
|
const color2 = color1.lerp(new Color, .5);
|
|
286
286
|
new ParticleEmitter(
|
|
287
|
-
pos.add(vec2(.5)), 1, .1, 100, PI
|
|
287
|
+
pos.add(vec2(.5)), 0, 1, .1, 100, PI,// pos, angle, emitSize, emitTime, emitRate, emiteCone
|
|
288
288
|
undefined, undefined, // tileIndex, tileSize
|
|
289
289
|
color1, color2, // colorStartA, colorStartB
|
|
290
290
|
color1.scale(1,0), color2.scale(1,0),// colorEndA, colorEndB
|
package/examples/screenshot.jpg
CHANGED
|
Binary file
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel=icon type=image/png href=../../favicon.png>
|
|
6
6
|
</head><body>
|
|
7
7
|
|
|
8
|
-
<script src=../../engine/engine.all.min.js?
|
|
8
|
+
<script src=../../engine/engine.all.min.js?104></script>
|
|
9
9
|
<script>
|
|
10
10
|
|
|
11
11
|
/*
|
|
@@ -54,7 +54,7 @@ function gameInit()
|
|
|
54
54
|
|
|
55
55
|
// display stats using a div so when using glOverlay it still appears on top
|
|
56
56
|
document.body.appendChild(statsDisplay = document.createElement('div'));
|
|
57
|
-
statsDisplay.style = 'position:absolute;width:100%;top:50%;left:50%;transform:translate(-50%,-50%);font-size:
|
|
57
|
+
statsDisplay.style = 'position:absolute;width:100%;top:50%;left:50%;transform:translate(-50%,-50%);font-size:6em;text-align:center;font-family:arial;user-select:none';
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
///////////////////////////////////////////////////////////////////////////////
|
package/game.js
CHANGED
|
@@ -57,12 +57,12 @@ function gameInit()
|
|
|
57
57
|
// create particle emitter
|
|
58
58
|
const center = tileCollisionSize.scale(.5).add(vec2(0,9));
|
|
59
59
|
particleEmiter = new ParticleEmitter(
|
|
60
|
-
center, 1, 0, 500, PI, // pos, emitSize, emitTime, emitRate, emiteCone
|
|
60
|
+
center, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emiteCone
|
|
61
61
|
0, vec2(16), // tileIndex, tileSize
|
|
62
|
-
new Color,
|
|
62
|
+
new Color(1,1,1), new Color(0,0,0), // colorStartA, colorStartB
|
|
63
63
|
new Color(1,1,1,0), new Color(0,0,0,0), // colorEndA, colorEndB
|
|
64
|
-
2, .2, .2, .1, .05,
|
|
65
|
-
.99, 1, 1, PI, .05,
|
|
64
|
+
2, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
|
|
65
|
+
.99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate,
|
|
66
66
|
.5, 1, 1 // randomness, collide, additive, randomColorLinear, renderOrder
|
|
67
67
|
);
|
|
68
68
|
particleEmiter.elasticity = .3;
|
package/index.html
CHANGED
|
@@ -6,21 +6,21 @@
|
|
|
6
6
|
</head><body>
|
|
7
7
|
|
|
8
8
|
<!-- LittleJS engine scripts -->
|
|
9
|
-
<script src=engine/engineDebug.js?
|
|
10
|
-
<script src=engine/engineUtilities.js?
|
|
11
|
-
<script src=engine/engineSettings.js?
|
|
12
|
-
<script src=engine/engineObject.js?
|
|
13
|
-
<script src=engine/engineDraw.js?
|
|
14
|
-
<script src=engine/engineInput.js?
|
|
15
|
-
<script src=engine/engineAudio.js?
|
|
16
|
-
<script src=engine/engineTileLayer.js?
|
|
17
|
-
<script src=engine/engineParticles.js?
|
|
18
|
-
<script src=engine/engineMedals.js?
|
|
19
|
-
<script src=engine/engineWebGL.js?
|
|
20
|
-
<script src=engine/engine.js?
|
|
9
|
+
<script src=engine/engineDebug.js?105></script>
|
|
10
|
+
<script src=engine/engineUtilities.js?105></script>
|
|
11
|
+
<script src=engine/engineSettings.js?105></script>
|
|
12
|
+
<script src=engine/engineObject.js?105></script>
|
|
13
|
+
<script src=engine/engineDraw.js?105></script>
|
|
14
|
+
<script src=engine/engineInput.js?105></script>
|
|
15
|
+
<script src=engine/engineAudio.js?105></script>
|
|
16
|
+
<script src=engine/engineTileLayer.js?105></script>
|
|
17
|
+
<script src=engine/engineParticles.js?105></script>
|
|
18
|
+
<script src=engine/engineMedals.js?105></script>
|
|
19
|
+
<script src=engine/engineWebGL.js?105></script>
|
|
20
|
+
<script src=engine/engine.js?105></script>
|
|
21
21
|
|
|
22
22
|
<!-- You can also include all engine scripts like this... -->
|
|
23
23
|
<!-- <script src=engine/engine.all.js></script> -->
|
|
24
24
|
|
|
25
25
|
<!-- Add your game scripts here -->
|
|
26
|
-
<script src=game.js?
|
|
26
|
+
<script src=game.js?105></script>
|
package/package.json
CHANGED