littlejsengine 1.1.18 → 1.2.3
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 +17 -11
- package/build.bat +1 -0
- package/engine/engine.all.js +495 -504
- package/engine/engine.all.min.js +1 -1
- package/engine/engine.all.release.js +418 -259
- package/engine/engine.js +31 -23
- package/engine/engineAudio.js +21 -7
- package/engine/engineBuild.bat +9 -1
- package/engine/engineBuildSetup.bat +2 -1
- package/engine/engineDebug.js +81 -247
- package/engine/engineDraw.js +109 -21
- package/engine/engineFont.png +0 -0
- package/engine/engineInput.js +103 -50
- package/engine/engineMedals.js +17 -20
- package/engine/engineObject.js +14 -23
- package/engine/engineParticles.js +8 -6
- package/engine/engineRelease.js +3 -1
- package/engine/engineSettings.js +20 -10
- package/engine/engineTileLayer.js +19 -18
- package/engine/engineUtilities.js +14 -12
- package/engine/engineWebGL.js +59 -68
- package/engine/index.d.ts +1617 -0
- package/examples/breakout/game.js +9 -7
- package/examples/breakout/gameObjects.js +3 -3
- package/examples/breakout/index.html +6 -4
- package/examples/platformer/game.js +5 -5
- package/examples/platformer/gameEffects.js +11 -14
- package/examples/platformer/gameLevel.js +14 -7
- package/examples/platformer/gameObjects.js +3 -3
- package/examples/platformer/gamePlayer.js +13 -8
- package/examples/platformer/index.html +9 -7
- package/examples/platformer/tiles.png +0 -0
- package/examples/puzzle/game.js +2 -2
- package/examples/puzzle/index.html +5 -3
- package/examples/screenshot.jpg +0 -0
- package/examples/stress/index.html +7 -5
- package/game.js +9 -8
- package/index.html +16 -14
- package/package.json +1 -1
|
@@ -47,21 +47,23 @@ function gameUpdatePost()
|
|
|
47
47
|
///////////////////////////////////////////////////////////////////////////////
|
|
48
48
|
function gameRender()
|
|
49
49
|
{
|
|
50
|
-
// draw a
|
|
51
|
-
drawRect(cameraPos, levelSize, new Color(.
|
|
50
|
+
// draw a the background
|
|
51
|
+
drawRect(cameraPos, levelSize.scale(2), new Color(.4,.4,.4));
|
|
52
|
+
drawRect(cameraPos, levelSize, new Color(.1,.1,.1));
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
///////////////////////////////////////////////////////////////////////////////
|
|
55
56
|
function gameRenderPost()
|
|
56
57
|
{
|
|
57
|
-
//
|
|
58
|
-
|
|
58
|
+
// use built in image font for text
|
|
59
|
+
const font = new FontImage;
|
|
60
|
+
font.drawText('Score: ' + score, cameraPos.add(vec2(0,22)), .2, 1);
|
|
59
61
|
if (!blockCount)
|
|
60
|
-
drawText('You Win!', cameraPos.add(vec2(0,-5)),
|
|
62
|
+
font.drawText('You Win!', cameraPos.add(vec2(0,-5)), .25, 1);
|
|
61
63
|
else if (!ball)
|
|
62
|
-
drawText('Click to Play', cameraPos.add(vec2(0,-5)),
|
|
64
|
+
font.drawText('Click to Play', cameraPos.add(vec2(0,-5)), .25, 1);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
///////////////////////////////////////////////////////////////////////////////
|
|
66
68
|
// Startup LittleJS Engine
|
|
67
|
-
engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, 'tiles.png');
|
|
69
|
+
engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, 'tiles.png?1');
|
|
@@ -28,7 +28,7 @@ class Paddle extends EngineObject
|
|
|
28
28
|
// move to mouse
|
|
29
29
|
this.pos.x = mousePos.x;
|
|
30
30
|
}
|
|
31
|
-
this.pos.x = clamp(this.pos.x,
|
|
31
|
+
this.pos.x = clamp(this.pos.x, this.size.x/2, levelSize.x - this.size.x/2);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -56,11 +56,11 @@ class Block extends EngineObject
|
|
|
56
56
|
const color1 = this.color;
|
|
57
57
|
const color2 = color1.lerp(new Color, .5);
|
|
58
58
|
new ParticleEmitter(
|
|
59
|
-
this.pos, this.size, .1, 200, PI,
|
|
59
|
+
this.pos, 0, this.size, .1, 200, PI, // pos, angle, emitSize, emitTime, emitRate, emiteCone
|
|
60
60
|
0, vec2(16), // tileIndex, tileSize
|
|
61
61
|
color1, color2, // colorStartA, colorStartB
|
|
62
62
|
color1.scale(1,0), color2.scale(1,0), // colorEndA, colorEndB
|
|
63
|
-
.2, 1, 1, .1, .05,
|
|
63
|
+
.2, 1, 1, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
|
|
64
64
|
.99, .95, .4, PI, .1, // damping, angleDamping, gravityScale, particleCone, fadeRate,
|
|
65
65
|
1, 0, 1 // randomness, collide, additive, randomColorLinear, renderOrder
|
|
66
66
|
);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
<html><head><
|
|
1
|
+
<html><head><meta charset=utf-8>
|
|
2
2
|
<meta name=viewport content=width=device-width,height=device-height,initial-scale=1,maximum-scale=1>
|
|
3
|
+
<meta name=apple-mobile-web-app-capable content=yes>
|
|
4
|
+
<meta name=mobile-web-app-capable content=yes>
|
|
3
5
|
<link rel=icon type=image/png href=../../favicon.png>
|
|
4
6
|
</head><body>
|
|
5
7
|
|
|
6
|
-
<script src=../../engine/engine.all.
|
|
7
|
-
<script src=game.js?
|
|
8
|
-
<script src=gameObjects.js?
|
|
8
|
+
<script src=../../engine/engine.all.js?102></script>
|
|
9
|
+
<script src=game.js?102></script>
|
|
10
|
+
<script src=gameObjects.js?102></script>
|
|
@@ -33,7 +33,7 @@ function gameUpdate()
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// mouse wheel = zoom
|
|
36
|
-
cameraScale = clamp(cameraScale*(1-mouseWheel/10),
|
|
36
|
+
cameraScale = clamp(cameraScale*(1-mouseWheel/10), 1, 1e3);
|
|
37
37
|
|
|
38
38
|
// T = drop test crate
|
|
39
39
|
if (keyWasPressed(84))
|
|
@@ -73,18 +73,18 @@ function gameRender()
|
|
|
73
73
|
function gameRenderPost()
|
|
74
74
|
{
|
|
75
75
|
// draw to overlay canvas for hud rendering
|
|
76
|
-
const drawText = (text, x, y, size=
|
|
76
|
+
const drawText = (text, x, y, size=50) =>
|
|
77
77
|
{
|
|
78
78
|
overlayContext.textAlign = 'center';
|
|
79
79
|
overlayContext.textBaseline = 'top';
|
|
80
80
|
overlayContext.font = size + 'px arial';
|
|
81
81
|
overlayContext.fillStyle = '#fff';
|
|
82
|
-
overlayContext.lineWidth =
|
|
82
|
+
overlayContext.lineWidth = 2;
|
|
83
83
|
overlayContext.strokeText(text, x, y);
|
|
84
84
|
overlayContext.fillText(text, x, y);
|
|
85
85
|
}
|
|
86
|
-
drawText('Score: ' + score, overlayCanvas.width*1/
|
|
87
|
-
drawText('Deaths: ' + deaths, overlayCanvas.width*
|
|
86
|
+
drawText('Score: ' + score, overlayCanvas.width*1/4, 20);
|
|
87
|
+
drawText('Deaths: ' + deaths, overlayCanvas.width*3/4, 20);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -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
|
|
@@ -89,7 +89,7 @@ function explosion(pos, radius=3)
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// push
|
|
92
|
-
const p = percent(d, radius,
|
|
92
|
+
const p = percent(d, 2*radius, radius);
|
|
93
93
|
const force = o.pos.subtract(pos).normalize(p*radius*.2);
|
|
94
94
|
o.applyForce(force);
|
|
95
95
|
if (o.isDead && o.isDead())
|
|
@@ -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
|
|
@@ -157,6 +157,9 @@ function destroyTile(pos, makeSound = 1, cleanNeighbors = 1)
|
|
|
157
157
|
|
|
158
158
|
function decorateBackgroundTile(pos)
|
|
159
159
|
{
|
|
160
|
+
if (!tileBackgroundLayer)
|
|
161
|
+
return;
|
|
162
|
+
|
|
160
163
|
const tileData = getTileBackgroundData(pos);
|
|
161
164
|
if (tileData <= 0)
|
|
162
165
|
return;
|
|
@@ -254,17 +257,11 @@ function drawStars()
|
|
|
254
257
|
(randSeeded(w)+time*speed)%w-extraSpace,
|
|
255
258
|
(randSeeded(h)+time*speed*randSeeded())%h-extraSpace);
|
|
256
259
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
mainContext.fillStyle = color.rgba();
|
|
261
|
-
if (size < 9)
|
|
262
|
-
mainContext.fillRect(screenPos.x, screenPos.y, size, size);
|
|
263
|
-
else
|
|
264
|
-
mainContext.beginPath(mainContext.fill(mainContext.arc(screenPos.x, screenPos.y, size, 0, 9)));
|
|
265
|
-
}
|
|
260
|
+
mainContext.fillStyle = color.rgba();
|
|
261
|
+
if (size < 9)
|
|
262
|
+
mainContext.fillRect(screenPos.x, screenPos.y, size, size);
|
|
266
263
|
else
|
|
267
|
-
|
|
264
|
+
mainContext.beginPath(mainContext.fill(mainContext.arc(screenPos.x, screenPos.y, size, 0, 9)));
|
|
268
265
|
}
|
|
269
266
|
}
|
|
270
267
|
|
|
@@ -28,7 +28,7 @@ function buildTerrain(size)
|
|
|
28
28
|
{
|
|
29
29
|
tileBackground = [];
|
|
30
30
|
initTileCollision(size);
|
|
31
|
-
let startGroundLevel =
|
|
31
|
+
let startGroundLevel = 40;
|
|
32
32
|
let groundLevel = startGroundLevel;
|
|
33
33
|
let groundSlope = rand(-1,1);
|
|
34
34
|
let backgroundDelta = 0, backgroundDeltaSlope = 0;
|
|
@@ -46,7 +46,7 @@ function buildTerrain(size)
|
|
|
46
46
|
{
|
|
47
47
|
// big jump
|
|
48
48
|
const jumpDelta = rand(19,-19);
|
|
49
|
-
startGroundLevel = clamp(startGroundLevel + jumpDelta,
|
|
49
|
+
startGroundLevel = clamp(startGroundLevel + jumpDelta, 20, 80);
|
|
50
50
|
groundLevel += jumpDelta;
|
|
51
51
|
groundSlope = rand(-1,1);
|
|
52
52
|
}
|
|
@@ -58,9 +58,9 @@ function buildTerrain(size)
|
|
|
58
58
|
backgroundDelta = 0;
|
|
59
59
|
if (rand() < .1)
|
|
60
60
|
backgroundDeltaSlope = rand(-1,1);
|
|
61
|
-
backgroundDelta = clamp(backgroundDelta,
|
|
61
|
+
backgroundDelta = clamp(backgroundDelta, -1, 3)
|
|
62
62
|
|
|
63
|
-
groundLevel = clamp(groundLevel,
|
|
63
|
+
groundLevel = clamp(groundLevel, 20, levelSize.y-20);
|
|
64
64
|
for (let y=0; y < size.y; y++)
|
|
65
65
|
{
|
|
66
66
|
const pos = vec2(x,y);
|
|
@@ -90,7 +90,7 @@ function buildTerrain(size)
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
// add ladders
|
|
93
|
-
for (let ladderCount=
|
|
93
|
+
for (let ladderCount = 40; ladderCount--;)
|
|
94
94
|
{
|
|
95
95
|
// pick random pos
|
|
96
96
|
const pos = vec2(randInt(levelSize.x), randInt(levelSize.y))
|
|
@@ -122,7 +122,7 @@ function buildTerrain(size)
|
|
|
122
122
|
new Crate(vec2((randInt(levelSize.x))+.5, randInt(levelSize.y)));
|
|
123
123
|
|
|
124
124
|
// spawn enemies
|
|
125
|
-
for (let enemyCount=
|
|
125
|
+
for (let enemyCount=10; enemyCount--;)
|
|
126
126
|
new Enemy(vec2(rand(levelSize.x), rand(levelSize.y)));
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -181,11 +181,18 @@ function makeTileLayers()
|
|
|
181
181
|
}
|
|
182
182
|
tileLayer.redraw();
|
|
183
183
|
tileBackgroundLayer.redraw();
|
|
184
|
+
|
|
185
|
+
if (!glEnable)
|
|
186
|
+
{
|
|
187
|
+
// get rid of background if webgl is not enabled
|
|
188
|
+
tileBackgroundLayer.destroy();
|
|
189
|
+
tileBackgroundLayer = 0;
|
|
190
|
+
}
|
|
184
191
|
}
|
|
185
192
|
|
|
186
193
|
function buildLevel()
|
|
187
194
|
{
|
|
188
|
-
levelSize = vec2(
|
|
195
|
+
levelSize = vec2(256);
|
|
189
196
|
levelColor = randColor(new Color(.2,.2,.2), new Color(.8,.8,.8));
|
|
190
197
|
levelGroundColor = levelColor.mutate().add(new Color(.4,.4,.4)).clamp();
|
|
191
198
|
|
|
@@ -25,7 +25,7 @@ class GameObject extends EngineObject
|
|
|
25
25
|
// flash white when damaged
|
|
26
26
|
if (!this.isDead() && this.damageTimer.isSet())
|
|
27
27
|
{
|
|
28
|
-
const a = .5*percent(this.damageTimer.get(),
|
|
28
|
+
const a = .5*percent(this.damageTimer.get(), .15, 0);
|
|
29
29
|
this.additiveColor = new Color(a,a,a,0);
|
|
30
30
|
}
|
|
31
31
|
else
|
|
@@ -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
|
|
@@ -24,7 +24,7 @@ class Character extends GameObject
|
|
|
24
24
|
this.deadTimer = new Timer;
|
|
25
25
|
this.grendeThrowTimer = new Timer;
|
|
26
26
|
this.drawSize = vec2(1);
|
|
27
|
-
this.color = (new Color).setHSLA(rand(),1,.
|
|
27
|
+
this.color = (new Color).setHSLA(rand(),1,.7);
|
|
28
28
|
this.renderOrder = 10;
|
|
29
29
|
this.walkCyclePercent = 0;
|
|
30
30
|
this.health = 1;
|
|
@@ -126,7 +126,12 @@ class Character extends GameObject
|
|
|
126
126
|
{
|
|
127
127
|
// update jumping and ground check
|
|
128
128
|
if (this.groundObject || this.climbingWall)
|
|
129
|
+
{
|
|
130
|
+
if (!this.groundTimer.isSet())
|
|
131
|
+
sound_walk.play(this.pos); // land sound
|
|
132
|
+
|
|
129
133
|
this.groundTimer.set(.1);
|
|
134
|
+
}
|
|
130
135
|
|
|
131
136
|
if (this.groundTimer.active() && !this.dodgeTimer.active())
|
|
132
137
|
{
|
|
@@ -169,7 +174,7 @@ class Character extends GameObject
|
|
|
169
174
|
|
|
170
175
|
// apply movement acceleration and clamp
|
|
171
176
|
const maxCharacterSpeed = .2;
|
|
172
|
-
this.velocity.x = clamp(this.velocity.x + moveInput.x * .042, maxCharacterSpeed,
|
|
177
|
+
this.velocity.x = clamp(this.velocity.x + moveInput.x * .042, -maxCharacterSpeed, maxCharacterSpeed);
|
|
173
178
|
|
|
174
179
|
// track last pos for ladder collision code
|
|
175
180
|
this.lastPos = this.pos.copy();
|
|
@@ -182,23 +187,23 @@ class Character extends GameObject
|
|
|
182
187
|
if (this.climbingLadder || this.groundTimer.active() && !this.dodgeTimer.active())
|
|
183
188
|
{
|
|
184
189
|
this.walkCyclePercent += speed * .5;
|
|
185
|
-
this.walkCyclePercent = speed > .01 ? mod(this.walkCyclePercent
|
|
190
|
+
this.walkCyclePercent = speed > .01 ? mod(this.walkCyclePercent) : 0;
|
|
186
191
|
}
|
|
187
192
|
else
|
|
188
193
|
this.walkCyclePercent = 0;
|
|
189
194
|
|
|
190
195
|
// update walk sound
|
|
191
196
|
this.walkSoundTime += speed;
|
|
192
|
-
if (speed > .
|
|
197
|
+
if (speed > .001 && ((this.climbingLadder || this.groundTimer.active()) && !this.dodgeTimer.active()))
|
|
193
198
|
{
|
|
194
199
|
if (this.walkSoundTime > 1)
|
|
195
200
|
{
|
|
196
|
-
this.walkSoundTime =
|
|
201
|
+
this.walkSoundTime = this.walkSoundTime%1;
|
|
197
202
|
sound_walk.play(this.pos);
|
|
198
203
|
}
|
|
199
204
|
}
|
|
200
205
|
else
|
|
201
|
-
this.walkSoundTime =
|
|
206
|
+
this.walkSoundTime = 0;
|
|
202
207
|
|
|
203
208
|
// update mirror
|
|
204
209
|
if (moveInput.x && !this.dodgeTimer.active())
|
|
@@ -292,8 +297,8 @@ class Player extends Character
|
|
|
292
297
|
// player controls
|
|
293
298
|
this.holdingJump = keyIsDown(38) || gamepadIsDown(0);
|
|
294
299
|
this.holdingShoot = mouseIsDown(0) || keyIsDown(90) || gamepadIsDown(2);
|
|
295
|
-
this.
|
|
296
|
-
this.
|
|
300
|
+
this.pressingThrow = mouseIsDown(1) || keyIsDown(67) || gamepadIsDown(1);
|
|
301
|
+
this.pressedDodge = mouseIsDown(2) || keyIsDown(88) || gamepadIsDown(3);
|
|
297
302
|
|
|
298
303
|
// movement control
|
|
299
304
|
this.moveInput = isUsingGamepad ? gamepadStick(0) :
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
<html><head><
|
|
1
|
+
<html><head><meta charset=utf-8>
|
|
2
2
|
<meta name=viewport content=width=device-width,height=device-height,initial-scale=1,maximum-scale=1>
|
|
3
|
+
<meta name=apple-mobile-web-app-capable content=yes>
|
|
4
|
+
<meta name=mobile-web-app-capable content=yes>
|
|
3
5
|
<link rel=icon type=image/png href=../../favicon.png>
|
|
4
6
|
</head><body>
|
|
5
7
|
|
|
6
|
-
<script src=../../engine/engine.all.js?
|
|
7
|
-
<script src=gameObjects.js?
|
|
8
|
-
<script src=gamePlayer.js?
|
|
9
|
-
<script src=gameEffects.js?
|
|
10
|
-
<script src=gameLevel.js?
|
|
11
|
-
<script src=game.js?
|
|
8
|
+
<script src=../../engine/engine.all.js?102></script>
|
|
9
|
+
<script src=gameObjects.js?102></script>
|
|
10
|
+
<script src=gamePlayer.js?102></script>
|
|
11
|
+
<script src=gameEffects.js?102></script>
|
|
12
|
+
<script src=gameLevel.js?102></script>
|
|
13
|
+
<script src=game.js?102></script>
|
|
Binary file
|
package/examples/puzzle/game.js
CHANGED
|
@@ -100,7 +100,7 @@ function gameUpdate()
|
|
|
100
100
|
|
|
101
101
|
if (keepFalling)
|
|
102
102
|
{
|
|
103
|
-
const p = percent(comboCount,
|
|
103
|
+
const p = percent(comboCount, 9, 0);
|
|
104
104
|
fallTimer.set(fallTime*p);
|
|
105
105
|
sound_fall.play();
|
|
106
106
|
}
|
|
@@ -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
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
<html><head><
|
|
1
|
+
<html><head><meta charset=utf-8>
|
|
2
2
|
<meta name=viewport content=width=device-width,height=device-height,initial-scale=1,maximum-scale=1>
|
|
3
|
+
<meta name=apple-mobile-web-app-capable content=yes>
|
|
4
|
+
<meta name=mobile-web-app-capable content=yes>
|
|
3
5
|
<link rel=icon type=image/png href=../../favicon.png>
|
|
4
6
|
</head><body>
|
|
5
7
|
|
|
6
|
-
<script src=../../engine/engine.all.
|
|
7
|
-
<script src=game.js?
|
|
8
|
+
<script src=../../engine/engine.all.js?102></script>
|
|
9
|
+
<script src=game.js?102></script>
|
package/examples/screenshot.jpg
CHANGED
|
Binary file
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
<html><head><
|
|
1
|
+
<html><head><meta charset=utf-8>
|
|
2
2
|
<meta name=viewport content=width=device-width,height=device-height,initial-scale=1,maximum-scale=1>
|
|
3
|
+
<meta name=apple-mobile-web-app-capable content=yes>
|
|
4
|
+
<meta name=mobile-web-app-capable content=yes>
|
|
3
5
|
<link rel=icon type=image/png href=../../favicon.png>
|
|
4
6
|
</head><body>
|
|
5
7
|
|
|
6
|
-
<script src=../../engine/engine.all.min.js?
|
|
8
|
+
<script src=../../engine/engine.all.min.js?102></script>
|
|
7
9
|
<script>
|
|
8
10
|
|
|
9
11
|
/*
|
|
@@ -52,7 +54,7 @@ function gameInit()
|
|
|
52
54
|
|
|
53
55
|
// display stats using a div so when using glOverlay it still appears on top
|
|
54
56
|
document.body.appendChild(statsDisplay = document.createElement('div'));
|
|
55
|
-
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';
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -81,7 +83,7 @@ function gameUpdate()
|
|
|
81
83
|
});
|
|
82
84
|
|
|
83
85
|
// mouse wheel = zoom
|
|
84
|
-
cameraScale = clamp(cameraScale*(1-mouseWheel/10),
|
|
86
|
+
cameraScale = clamp(cameraScale*(1-mouseWheel/10), 1, 1e3);
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -94,7 +96,7 @@ function gameRender()
|
|
|
94
96
|
{
|
|
95
97
|
// track fps and update stats
|
|
96
98
|
const frameTimeMS = Date.now();
|
|
97
|
-
showFPS = lerp(.05, 1e3/(frameTimeMS - timeMS||1)
|
|
99
|
+
showFPS = lerp(.05, showFPS, 1e3/(frameTimeMS - timeMS||1));
|
|
98
100
|
timeMS = frameTimeMS;
|
|
99
101
|
|
|
100
102
|
const spriteCount = sprites.length
|
package/game.js
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
|
+
// popup errors if there are any (help diagnose issues on mobile devices)
|
|
8
|
+
if (debug)
|
|
9
|
+
onerror = (...parameters)=> alert(parameters);
|
|
10
|
+
|
|
7
11
|
// game variables
|
|
8
12
|
let particleEmiter, clickCount = 0;
|
|
9
13
|
|
|
@@ -11,8 +15,7 @@ let particleEmiter, clickCount = 0;
|
|
|
11
15
|
const sound_click = new Sound([.5,.5]);
|
|
12
16
|
|
|
13
17
|
// medals
|
|
14
|
-
const medal_example = new Medal(0, 'Example Medal', '
|
|
15
|
-
const medal_tenClicks = new Medal(1, 'Ten Clicks!', 'You have clicked 10 times.', '🖱️');
|
|
18
|
+
const medal_example = new Medal(0, 'Example Medal', 'Medal description goes here.');
|
|
16
19
|
medalsInit('Hello World');
|
|
17
20
|
|
|
18
21
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -54,12 +57,12 @@ function gameInit()
|
|
|
54
57
|
// create particle emitter
|
|
55
58
|
const center = tileCollisionSize.scale(.5).add(vec2(0,9));
|
|
56
59
|
particleEmiter = new ParticleEmitter(
|
|
57
|
-
center, 1, 0, 500, PI, // pos, emitSize, emitTime, emitRate, emiteCone
|
|
60
|
+
center, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emiteCone
|
|
58
61
|
0, vec2(16), // tileIndex, tileSize
|
|
59
|
-
new Color,
|
|
62
|
+
new Color(1,1,1), new Color(0,0,0), // colorStartA, colorStartB
|
|
60
63
|
new Color(1,1,1,0), new Color(0,0,0,0), // colorEndA, colorEndB
|
|
61
|
-
2, .2, .2, .1, .05,
|
|
62
|
-
.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,
|
|
63
66
|
.5, 1, 1 // randomness, collide, additive, randomColorLinear, renderOrder
|
|
64
67
|
);
|
|
65
68
|
particleEmiter.elasticity = .3;
|
|
@@ -82,8 +85,6 @@ function gameUpdate()
|
|
|
82
85
|
|
|
83
86
|
// unlock medals
|
|
84
87
|
medal_example.unlock();
|
|
85
|
-
if (++clickCount == 10)
|
|
86
|
-
medal_tenClicks.unlock();
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
// move particles to mouse location if on screen
|
package/index.html
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
<html><head><
|
|
1
|
+
<html><head><meta charset=utf-8>
|
|
2
2
|
<meta name=viewport content=width=device-width,height=device-height,initial-scale=1,maximum-scale=1>
|
|
3
|
+
<meta name=apple-mobile-web-app-capable content=yes>
|
|
4
|
+
<meta name=mobile-web-app-capable content=yes>
|
|
3
5
|
<link rel=icon type=image/png href=favicon.png>
|
|
4
6
|
</head><body>
|
|
5
7
|
|
|
6
8
|
<!-- LittleJS engine scripts -->
|
|
7
|
-
<script src=engine/engineDebug.js?
|
|
8
|
-
<script src=engine/engineUtilities.js?
|
|
9
|
-
<script src=engine/engineSettings.js?
|
|
10
|
-
<script src=engine/engineObject.js?
|
|
11
|
-
<script src=engine/engineDraw.js?
|
|
12
|
-
<script src=engine/engineInput.js?
|
|
13
|
-
<script src=engine/engineAudio.js?
|
|
14
|
-
<script src=engine/engineTileLayer.js?
|
|
15
|
-
<script src=engine/engineParticles.js?
|
|
16
|
-
<script src=engine/engineMedals.js?
|
|
17
|
-
<script src=engine/engineWebGL.js?
|
|
18
|
-
<script src=engine/engine.js?
|
|
9
|
+
<script src=engine/engineDebug.js?102></script>
|
|
10
|
+
<script src=engine/engineUtilities.js?102></script>
|
|
11
|
+
<script src=engine/engineSettings.js?102></script>
|
|
12
|
+
<script src=engine/engineObject.js?102></script>
|
|
13
|
+
<script src=engine/engineDraw.js?102></script>
|
|
14
|
+
<script src=engine/engineInput.js?102></script>
|
|
15
|
+
<script src=engine/engineAudio.js?102></script>
|
|
16
|
+
<script src=engine/engineTileLayer.js?102></script>
|
|
17
|
+
<script src=engine/engineParticles.js?102></script>
|
|
18
|
+
<script src=engine/engineMedals.js?102></script>
|
|
19
|
+
<script src=engine/engineWebGL.js?102></script>
|
|
20
|
+
<script src=engine/engine.js?102></script>
|
|
19
21
|
|
|
20
22
|
<!-- You can also include all engine scripts like this... -->
|
|
21
23
|
<!-- <script src=engine/engine.all.js></script> -->
|
|
22
24
|
|
|
23
25
|
<!-- Add your game scripts here -->
|
|
24
|
-
<script src=game.js?
|
|
26
|
+
<script src=game.js?102></script>
|