littlejsengine 1.10.4 → 1.11.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/LittleJS.zip +0 -0
- package/README.md +8 -78
- package/dist/littlejs.d.ts +60 -25
- package/dist/littlejs.esm.js +164 -63
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +160 -62
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +160 -62
- package/examples/box2d/game.js +15 -4
- package/examples/box2d/gameObjects.js +10 -9
- package/examples/box2d/index.html +5 -5
- package/examples/box2d/scenes.js +4 -4
- package/examples/box2d/tiles.png +0 -0
- package/examples/breakout/index.html +3 -3
- package/examples/breakoutTutorial/index.html +2 -2
- package/examples/electron/game.js +3 -0
- package/examples/electron/index.html +2 -2
- package/examples/htmlMenu/index.html +3 -3
- package/examples/index.html +10 -3
- package/examples/js13k/game.js +3 -0
- package/examples/js13k/index.html +13 -13
- package/examples/module/game.js +4 -1
- package/examples/module/index.html +1 -1
- package/examples/particles/index.html +4 -1
- package/examples/platformer/game.js +19 -15
- package/examples/platformer/gameCharacter.js +3 -3
- package/examples/platformer/gameLevel.js +1 -0
- package/examples/platformer/index.html +8 -8
- package/examples/platformer/tiles.png +0 -0
- package/examples/puzzle/game.js +3 -2
- package/examples/puzzle/index.html +2 -2
- package/examples/starter/game.js +47 -10
- package/examples/starter/index.html +13 -13
- package/examples/starter/tiles.png +0 -0
- package/examples/stress/index.html +1 -1
- package/examples/typescript/game.js +2 -0
- package/examples/typescript/game.ts +3 -0
- package/examples/typescript/index.html +1 -1
- package/examples/uiSystem/game.js +23 -16
- package/examples/uiSystem/index.html +3 -14
- package/package.json +7 -2
- package/plugins/postProcess.js +2 -9
- package/plugins/uiSystem.js +85 -25
- package/reference.md +1 -1
- package/shortExamples/engine.html +71 -0
- package/shortExamples/index.html +47 -0
- package/shortExamples/index.js +0 -0
- package/shortExamples/tiles.png +0 -0
- package/src/engine.js +14 -12
- package/src/engineAudio.js +6 -9
- package/src/engineDraw.js +23 -7
- package/src/engineExport.js +4 -1
- package/src/engineInput.js +7 -3
- package/src/engineMedals.js +19 -5
- package/src/engineObject.js +8 -5
- package/src/engineSettings.js +13 -2
- package/src/engineTileLayer.js +9 -8
- package/src/engineUtilities.js +59 -10
- package/src/engineWebGL.js +1 -1
- package/examples/js13k/build/index.html +0 -1
- package/examples/js13k/build/index.js +0 -1
- package/examples/js13k/build/tiles.png +0 -0
- package/examples/js13k/game - Copy.zip +0 -0
- package/examples/js13k/game.zip +0 -0
- package/examples/starter/build/index.html +0 -2
- package/examples/starter/build/index.js +0 -1
- package/examples/starter/build/tiles.png +0 -0
- package/examples/starter/game.zip +0 -0
- package/examples/typescript/build/build/littlejs.esm.js +0 -4327
- package/examples/typescript/build/dist/littlejs.esm.js +0 -4425
- package/examples/typescript/build/examples/typescript/build.js +0 -24
- package/examples/typescript/build/examples/typescript/game.js +0 -100
- package/examples/typescript/build/examples/typescript/test/build/littlejs.esm.js +0 -3934
- package/examples/typescript/build/examples/typescript/test/examples/typescript/build.js +0 -86
- package/examples/typescript/build/examples/typescript/test/examples/typescript/game.js +0 -92
package/src/engineDraw.js
CHANGED
|
@@ -70,7 +70,7 @@ let drawCount;
|
|
|
70
70
|
* tile(2) // a tile at index 2 using the default tile size of 16
|
|
71
71
|
* tile(5, 8) // a tile at index 5 using a tile size of 8
|
|
72
72
|
* tile(1, 16, 3) // a tile at index 1 of size 16 on texture 3
|
|
73
|
-
* tile(vec2(4,8), vec2(30,10)) // a tile at
|
|
73
|
+
* tile(vec2(4,8), vec2(30,10)) // a tile at index (4,8) with a size of (30,10)
|
|
74
74
|
* @memberof Draw
|
|
75
75
|
*/
|
|
76
76
|
function tile(pos=vec2(), size=tileSizeDefault, textureIndex=0, padding=0)
|
|
@@ -415,6 +415,24 @@ function setBlendMode(additive, useWebGL=glEnable, context)
|
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
+
/** Draw text on main canvas in world space
|
|
419
|
+
* Automatically splits new lines into rows
|
|
420
|
+
* @param {String} text
|
|
421
|
+
* @param {Vector2} pos
|
|
422
|
+
* @param {Number} [size]
|
|
423
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
424
|
+
* @param {Number} [lineWidth]
|
|
425
|
+
* @param {Color} [lineColor=(0,0,0,1)]
|
|
426
|
+
* @param {CanvasTextAlign} [textAlign='center']
|
|
427
|
+
* @param {String} [font=fontDefault]
|
|
428
|
+
* @param {Number} [maxWidth]
|
|
429
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=mainContext]
|
|
430
|
+
* @memberof Draw */
|
|
431
|
+
function drawText(text, pos, size=1, color, lineWidth=0, lineColor, textAlign, font, maxWidth, context=mainContext)
|
|
432
|
+
{
|
|
433
|
+
drawTextScreen(text, worldToScreen(pos), size*cameraScale, color, lineWidth*cameraScale, lineColor, textAlign, font, maxWidth, context);
|
|
434
|
+
}
|
|
435
|
+
|
|
418
436
|
/** Draw text on overlay canvas in world space
|
|
419
437
|
* Automatically splits new lines into rows
|
|
420
438
|
* @param {String} text
|
|
@@ -425,12 +443,11 @@ function setBlendMode(additive, useWebGL=glEnable, context)
|
|
|
425
443
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
426
444
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
427
445
|
* @param {String} [font=fontDefault]
|
|
428
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
|
|
429
446
|
* @param {Number} [maxWidth]
|
|
430
447
|
* @memberof Draw */
|
|
431
|
-
function
|
|
448
|
+
function drawTextOverlay(text, pos, size=1, color, lineWidth=0, lineColor, textAlign, font, maxWidth)
|
|
432
449
|
{
|
|
433
|
-
|
|
450
|
+
drawText(text, pos, size, color, lineWidth, lineColor, textAlign, font, maxWidth, overlayContext);
|
|
434
451
|
}
|
|
435
452
|
|
|
436
453
|
/** Draw text on overlay canvas in screen space
|
|
@@ -443,10 +460,10 @@ function drawText(text, pos, size=1, color, lineWidth=0, lineColor, textAlign, f
|
|
|
443
460
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
444
461
|
* @param {CanvasTextAlign} [textAlign]
|
|
445
462
|
* @param {String} [font=fontDefault]
|
|
446
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
|
|
447
463
|
* @param {Number} [maxWidth]
|
|
464
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
|
|
448
465
|
* @memberof Draw */
|
|
449
|
-
function drawTextScreen(text, pos, size=1, color=new Color, lineWidth=0, lineColor=new Color(0,0,0), textAlign='center', font=fontDefault,
|
|
466
|
+
function drawTextScreen(text, pos, size=1, color=new Color, lineWidth=0, lineColor=new Color(0,0,0), textAlign='center', font=fontDefault, maxWidth=undefined, context=overlayContext)
|
|
450
467
|
{
|
|
451
468
|
context.fillStyle = color.toString();
|
|
452
469
|
context.lineWidth = lineWidth;
|
|
@@ -522,7 +539,6 @@ class FontImage
|
|
|
522
539
|
{
|
|
523
540
|
const context = this.context;
|
|
524
541
|
context.save();
|
|
525
|
-
context.imageSmoothingEnabled = !canvasPixelated;
|
|
526
542
|
|
|
527
543
|
const size = this.tileSize;
|
|
528
544
|
const drawSize = size.add(this.paddingSize).scale(scale);
|
package/src/engineExport.js
CHANGED
|
@@ -48,6 +48,7 @@ export {
|
|
|
48
48
|
canvasMaxSize,
|
|
49
49
|
canvasFixedSize,
|
|
50
50
|
canvasPixelated,
|
|
51
|
+
tilesPixelated,
|
|
51
52
|
fontDefault,
|
|
52
53
|
showSplashScreen,
|
|
53
54
|
headlessMode,
|
|
@@ -87,6 +88,7 @@ export {
|
|
|
87
88
|
setCanvasMaxSize,
|
|
88
89
|
setCanvasFixedSize,
|
|
89
90
|
setCanvasPixelated,
|
|
91
|
+
setTilesPixelated,
|
|
90
92
|
setFontDefault,
|
|
91
93
|
setShowSplashScreen,
|
|
92
94
|
setHeadlessMode,
|
|
@@ -196,8 +198,9 @@ export {
|
|
|
196
198
|
drawCircle,
|
|
197
199
|
drawCanvas2D,
|
|
198
200
|
setBlendMode,
|
|
199
|
-
drawTextScreen,
|
|
200
201
|
drawText,
|
|
202
|
+
drawTextOverlay,
|
|
203
|
+
drawTextScreen,
|
|
201
204
|
engineFontImage,
|
|
202
205
|
FontImage,
|
|
203
206
|
isFullscreen,
|
package/src/engineInput.js
CHANGED
|
@@ -45,7 +45,7 @@ function keyWasReleased(key, device=0)
|
|
|
45
45
|
|
|
46
46
|
/** Clears all input
|
|
47
47
|
* @memberof Input */
|
|
48
|
-
function clearInput() { inputData = [[]]; }
|
|
48
|
+
function clearInput() { inputData = [[]]; touchGamepadButtons = []; }
|
|
49
49
|
|
|
50
50
|
/** Returns true if mouse button is down
|
|
51
51
|
* @function
|
|
@@ -210,6 +210,7 @@ function inputInit()
|
|
|
210
210
|
onmousemove = (e)=> mousePosScreen = mouseToScreen(e);
|
|
211
211
|
onwheel = (e)=> mouseWheel = e.ctrlKey ? 0 : sign(e.deltaY);
|
|
212
212
|
oncontextmenu = (e)=> false; // prevent right click menu
|
|
213
|
+
onblur = (e) => clearInput(); // reset input when focus is lost
|
|
213
214
|
|
|
214
215
|
// init touch input
|
|
215
216
|
if (isTouchDevice && touchInputEnable)
|
|
@@ -408,10 +409,13 @@ function touchInputInit()
|
|
|
408
409
|
if (touching)
|
|
409
410
|
{
|
|
410
411
|
touchGamepadTimer.set();
|
|
411
|
-
if (paused)
|
|
412
|
+
if (paused && !wasTouching)
|
|
412
413
|
{
|
|
413
414
|
// touch anywhere to press start when paused
|
|
414
415
|
touchGamepadButtons[9] = 1;
|
|
416
|
+
|
|
417
|
+
// call default touch handler so normal touch events still work
|
|
418
|
+
handleTouchDefault(e);
|
|
415
419
|
return;
|
|
416
420
|
}
|
|
417
421
|
}
|
|
@@ -436,7 +440,7 @@ function touchInputInit()
|
|
|
436
440
|
const button = touchPos.subtract(buttonCenter).direction();
|
|
437
441
|
touchGamepadButtons[button] = 1;
|
|
438
442
|
}
|
|
439
|
-
else if (touchPos.distance(startCenter) < touchGamepadSize)
|
|
443
|
+
else if (touchPos.distance(startCenter) < touchGamepadSize && !wasTouching)
|
|
440
444
|
{
|
|
441
445
|
// virtual start button in center
|
|
442
446
|
touchGamepadButtons[9] = 1;
|
package/src/engineMedals.js
CHANGED
|
@@ -28,7 +28,7 @@ function medalsInit(saveName)
|
|
|
28
28
|
// check if medals are unlocked
|
|
29
29
|
medalsSaveName = saveName;
|
|
30
30
|
if (!debugMedals)
|
|
31
|
-
medalsForEach(medal=> medal.unlocked =
|
|
31
|
+
medalsForEach(medal=> medal.unlocked = !!localStorage[medal.storageKey()]);
|
|
32
32
|
|
|
33
33
|
// engine automatically renders medals
|
|
34
34
|
engineAddPlugin(undefined, medalsRender);
|
|
@@ -91,14 +91,28 @@ class Medal
|
|
|
91
91
|
constructor(id, name, description='', icon='🏆', src)
|
|
92
92
|
{
|
|
93
93
|
ASSERT(id >= 0 && !medals[id]);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
|
|
95
|
+
/** @property {Number} - The unique identifier of the medal */
|
|
96
|
+
this.id = id;
|
|
97
|
+
|
|
98
|
+
/** @property {String} - Name of the medal */
|
|
97
99
|
this.name = name;
|
|
100
|
+
|
|
101
|
+
/** @property {String} - Description of the medal */
|
|
98
102
|
this.description = description;
|
|
103
|
+
|
|
104
|
+
/** @property {String} - Icon for the medal */
|
|
99
105
|
this.icon = icon;
|
|
106
|
+
|
|
107
|
+
/** @property {Boolean} - Is the medal unlocked? */
|
|
108
|
+
this.unlocked = false;
|
|
109
|
+
|
|
110
|
+
// load the source image if provided
|
|
100
111
|
if (src)
|
|
101
112
|
(this.image = new Image).src = src;
|
|
113
|
+
|
|
114
|
+
// add this to list of medals
|
|
115
|
+
medals[id] = this;
|
|
102
116
|
}
|
|
103
117
|
|
|
104
118
|
/** Unlocks a medal if not already unlocked */
|
|
@@ -109,7 +123,7 @@ class Medal
|
|
|
109
123
|
|
|
110
124
|
// save the medal
|
|
111
125
|
ASSERT(medalsSaveName, 'save name must be set');
|
|
112
|
-
localStorage[this.storageKey()] = this.unlocked =
|
|
126
|
+
localStorage[this.storageKey()] = this.unlocked = true;
|
|
113
127
|
medalsDisplayQueue.push(this);
|
|
114
128
|
}
|
|
115
129
|
|
package/src/engineObject.js
CHANGED
|
@@ -39,7 +39,7 @@ class EngineObject
|
|
|
39
39
|
* @param {Color} [color=(1,1,1,1)] - Color to apply to tile when rendered
|
|
40
40
|
* @param {Number} [renderOrder] - Objects sorted by renderOrder before being rendered
|
|
41
41
|
*/
|
|
42
|
-
constructor(pos=vec2(), size=vec2(1), tileInfo, angle=0, color, renderOrder=0)
|
|
42
|
+
constructor(pos=vec2(), size=vec2(1), tileInfo, angle=0, color=new Color, renderOrder=0)
|
|
43
43
|
{
|
|
44
44
|
// set passed in params
|
|
45
45
|
ASSERT(isVector2(pos) && isVector2(size), 'ensure pos and size are vec2s');
|
|
@@ -153,15 +153,18 @@ class EngineObject
|
|
|
153
153
|
|
|
154
154
|
// apply physics
|
|
155
155
|
const oldPos = this.pos.copy();
|
|
156
|
-
this.
|
|
157
|
-
this.
|
|
158
|
-
|
|
156
|
+
this.velocity.x *= this.damping;
|
|
157
|
+
this.velocity.y *= this.damping;
|
|
158
|
+
if (this.mass) // dont apply gravity to static objects
|
|
159
|
+
this.velocity.y += gravity * this.gravityScale;
|
|
160
|
+
this.pos.x += this.velocity.x;
|
|
161
|
+
this.pos.y += this.velocity.y;
|
|
159
162
|
this.angle += this.angleVelocity *= this.angleDamping;
|
|
160
163
|
|
|
161
164
|
// physics sanity checks
|
|
162
165
|
ASSERT(this.angleDamping >= 0 && this.angleDamping <= 1);
|
|
163
166
|
ASSERT(this.damping >= 0 && this.damping <= 1);
|
|
164
|
-
if (!enablePhysicsSolver || !this.mass) // dont do collision for
|
|
167
|
+
if (!enablePhysicsSolver || !this.mass) // dont do collision for static objects
|
|
165
168
|
return;
|
|
166
169
|
|
|
167
170
|
const wasMovingDown = this.velocity.y < 0;
|
package/src/engineSettings.js
CHANGED
|
@@ -37,12 +37,18 @@ let canvasMaxSize = vec2(1920, 1080);
|
|
|
37
37
|
* @memberof Settings */
|
|
38
38
|
let canvasFixedSize = vec2();
|
|
39
39
|
|
|
40
|
-
/**
|
|
40
|
+
/** Use nearest neighbor scaling algorithm for canvas for more pixelated look
|
|
41
41
|
* @type {Boolean}
|
|
42
42
|
* @default
|
|
43
43
|
* @memberof Settings */
|
|
44
44
|
let canvasPixelated = true;
|
|
45
45
|
|
|
46
|
+
/** Disables texture filtering for crisper pixel art
|
|
47
|
+
* @type {Boolean}
|
|
48
|
+
* @default
|
|
49
|
+
* @memberof Settings */
|
|
50
|
+
let tilesPixelated = true;
|
|
51
|
+
|
|
46
52
|
/** Default font used for text rendering
|
|
47
53
|
* @type {String}
|
|
48
54
|
* @default
|
|
@@ -291,11 +297,16 @@ function setCanvasMaxSize(size) { canvasMaxSize = size; }
|
|
|
291
297
|
* @memberof Settings */
|
|
292
298
|
function setCanvasFixedSize(size) { canvasFixedSize = size; }
|
|
293
299
|
|
|
294
|
-
/**
|
|
300
|
+
/** Use nearest neighbor scaling algorithm for canvas for more pixelated look
|
|
295
301
|
* @param {Boolean} pixelated
|
|
296
302
|
* @memberof Settings */
|
|
297
303
|
function setCanvasPixelated(pixelated) { canvasPixelated = pixelated; }
|
|
298
304
|
|
|
305
|
+
/** Disables texture filtering for crisper pixel art
|
|
306
|
+
* @param {Boolean} pixelated
|
|
307
|
+
* @memberof Settings */
|
|
308
|
+
function setTilesPixelated(pixelated) { tilesPixelated = pixelated; }
|
|
309
|
+
|
|
299
310
|
/** Set default font used for text rendering
|
|
300
311
|
* @param {String} font
|
|
301
312
|
* @memberof Settings */
|
package/src/engineTileLayer.js
CHANGED
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
/** The tile collision layer
|
|
15
|
+
/** The tile collision layer grid, use setTileCollisionData and getTileCollisionData to access
|
|
16
16
|
* @type {Array}
|
|
17
17
|
* @memberof TileCollision */
|
|
18
18
|
let tileCollision = [];
|
|
19
19
|
|
|
20
|
-
/** Size of the tile collision layer
|
|
20
|
+
/** Size of the tile collision layer 2d grid
|
|
21
21
|
* @type {Vector2}
|
|
22
22
|
* @memberof TileCollision */
|
|
23
23
|
let tileCollisionSize = vec2();
|
|
24
24
|
|
|
25
25
|
/** Clear and initialize tile collision
|
|
26
|
-
* @param {Vector2} size
|
|
26
|
+
* @param {Vector2} size - width and height of tile collision 2d grid
|
|
27
27
|
* @memberof TileCollision */
|
|
28
28
|
function initTileCollision(size)
|
|
29
29
|
{
|
|
@@ -33,7 +33,7 @@ function initTileCollision(size)
|
|
|
33
33
|
tileCollision[i] = 0;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
/** Set tile collision data
|
|
36
|
+
/** Set tile collision data for a given cell in the grid
|
|
37
37
|
* @param {Vector2} pos
|
|
38
38
|
* @param {Number} [data]
|
|
39
39
|
* @memberof TileCollision */
|
|
@@ -42,7 +42,7 @@ function setTileCollisionData(pos, data=0)
|
|
|
42
42
|
pos.arrayCheck(tileCollisionSize) && (tileCollision[(pos.y|0)*tileCollisionSize.x+pos.x|0] = data);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
/** Get tile collision data
|
|
45
|
+
/** Get tile collision data for a given cell in the grid
|
|
46
46
|
* @param {Vector2} pos
|
|
47
47
|
* @return {Number}
|
|
48
48
|
* @memberof TileCollision */
|
|
@@ -73,7 +73,8 @@ function tileCollisionTest(pos, size=vec2(), object)
|
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
/** Return the center of first tile hit
|
|
76
|
+
/** Return the center of first tile hit, undefined if nothing was hit.
|
|
77
|
+
* This does not return the exact intersection, but the center of the tile hit.
|
|
77
78
|
* @param {Vector2} posStart
|
|
78
79
|
* @param {Vector2} posEnd
|
|
79
80
|
* @param {EngineObject} [object]
|
|
@@ -281,7 +282,7 @@ class TileLayer extends EngineObject
|
|
|
281
282
|
}
|
|
282
283
|
|
|
283
284
|
// disable smoothing for pixel art
|
|
284
|
-
this.context.imageSmoothingEnabled = !
|
|
285
|
+
this.context.imageSmoothingEnabled = !tilesPixelated;
|
|
285
286
|
|
|
286
287
|
// setup gl rendering if enabled
|
|
287
288
|
glPreRender();
|
|
@@ -318,8 +319,8 @@ class TileLayer extends EngineObject
|
|
|
318
319
|
const d = this.getData(layerPos);
|
|
319
320
|
if (d.tile != undefined)
|
|
320
321
|
{
|
|
321
|
-
const pos = this.pos.add(layerPos).add(vec2(.5));
|
|
322
322
|
ASSERT(mainContext == this.context, 'must call redrawStart() before drawing tiles');
|
|
323
|
+
const pos = layerPos.add(vec2(.5));
|
|
323
324
|
const tileInfo = tile(d.tile, s, this.tileInfo.textureIndex);
|
|
324
325
|
drawTile(pos, vec2(1), tileInfo, d.color, d.direction*PI/2, d.mirror);
|
|
325
326
|
}
|
package/src/engineUtilities.js
CHANGED
|
@@ -201,7 +201,8 @@ function formatTime(t) { return (t/60|0) + ':' + (t%60<10?'0':'') + (t%60|0); }
|
|
|
201
201
|
* @memberof Random */
|
|
202
202
|
function rand(valueA=1, valueB=0) { return valueB + Math.random() * (valueA-valueB); }
|
|
203
203
|
|
|
204
|
-
/** Returns a floored random value the two values passed in
|
|
204
|
+
/** Returns a floored random value between the two values passed in
|
|
205
|
+
* The upper bound is exclusive. (If 2 is passed in, result will be 0 or 1)
|
|
205
206
|
* @param {Number} valueA
|
|
206
207
|
* @param {Number} [valueB]
|
|
207
208
|
* @return {Number}
|
|
@@ -330,18 +331,24 @@ class Vector2
|
|
|
330
331
|
* @param {Number} [y] - Y axis location */
|
|
331
332
|
constructor(x=0, y=0)
|
|
332
333
|
{
|
|
333
|
-
ASSERT(typeof x == 'number' && typeof y == 'number');
|
|
334
334
|
/** @property {Number} - X axis location */
|
|
335
335
|
this.x = x;
|
|
336
336
|
/** @property {Number} - Y axis location */
|
|
337
337
|
this.y = y;
|
|
338
|
+
ASSERT(this.isValid());
|
|
338
339
|
}
|
|
339
340
|
|
|
340
341
|
/** Sets values of this vector and returns self
|
|
341
342
|
* @param {Number} [x] - X axis location
|
|
342
343
|
* @param {Number} [y] - Y axis location
|
|
343
344
|
* @return {Vector2} */
|
|
344
|
-
set(x=0, y=0)
|
|
345
|
+
set(x=0, y=0)
|
|
346
|
+
{
|
|
347
|
+
this.x = x;
|
|
348
|
+
this.y = y;
|
|
349
|
+
ASSERT(this.isValid());
|
|
350
|
+
return this;
|
|
351
|
+
}
|
|
345
352
|
|
|
346
353
|
/** Returns a new vector that is a copy of this
|
|
347
354
|
* @return {Vector2} */
|
|
@@ -533,6 +540,14 @@ class Vector2
|
|
|
533
540
|
if (debug)
|
|
534
541
|
return `(${(this.x<0?'':' ') + this.x.toFixed(digits)},${(this.y<0?'':' ') + this.y.toFixed(digits)} )`;
|
|
535
542
|
}
|
|
543
|
+
|
|
544
|
+
/** Checks if this is a valid vector
|
|
545
|
+
* @return {Boolean} */
|
|
546
|
+
isValid()
|
|
547
|
+
{
|
|
548
|
+
return typeof this.x == 'number' && !isNaN(this.x)
|
|
549
|
+
&& typeof this.y == 'number' && !isNaN(this.y);
|
|
550
|
+
}
|
|
536
551
|
}
|
|
537
552
|
|
|
538
553
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -593,6 +608,7 @@ class Color
|
|
|
593
608
|
this.b = b;
|
|
594
609
|
/** @property {Number} - Alpha */
|
|
595
610
|
this.a = a;
|
|
611
|
+
ASSERT(this.isValid());
|
|
596
612
|
}
|
|
597
613
|
|
|
598
614
|
/** Sets values of this color and returns self
|
|
@@ -602,7 +618,14 @@ class Color
|
|
|
602
618
|
* @param {Number} [a] - alpha
|
|
603
619
|
* @return {Color} */
|
|
604
620
|
set(r=1, g=1, b=1, a=1)
|
|
605
|
-
{
|
|
621
|
+
{
|
|
622
|
+
this.r = r;
|
|
623
|
+
this.g = g;
|
|
624
|
+
this.b = b;
|
|
625
|
+
this.a = a;
|
|
626
|
+
ASSERT(this.isValid());
|
|
627
|
+
return this;
|
|
628
|
+
}
|
|
606
629
|
|
|
607
630
|
/** Returns a new color that is a copy of this
|
|
608
631
|
* @return {Color} */
|
|
@@ -685,6 +708,7 @@ class Color
|
|
|
685
708
|
this.g = f(p, q, h);
|
|
686
709
|
this.b = f(p, q, h - 1/3);
|
|
687
710
|
this.a = a;
|
|
711
|
+
ASSERT(this.isValid());
|
|
688
712
|
return this;
|
|
689
713
|
}
|
|
690
714
|
|
|
@@ -712,7 +736,6 @@ class Color
|
|
|
712
736
|
else if (b == max)
|
|
713
737
|
h = (r - g) / d + 4;
|
|
714
738
|
}
|
|
715
|
-
|
|
716
739
|
return [h / 6, s, l, a];
|
|
717
740
|
}
|
|
718
741
|
|
|
@@ -745,11 +768,27 @@ class Color
|
|
|
745
768
|
* @return {Color} */
|
|
746
769
|
setHex(hex)
|
|
747
770
|
{
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
771
|
+
ASSERT(typeof hex == 'string' && hex[0] == '#');
|
|
772
|
+
ASSERT([4,5,7,9].includes(hex.length), 'Invalid hex');
|
|
773
|
+
|
|
774
|
+
if (hex.length < 6)
|
|
775
|
+
{
|
|
776
|
+
const fromHex = (c)=> clamp(parseInt(hex[c],16)/15);
|
|
777
|
+
this.r = fromHex(1);
|
|
778
|
+
this.g = fromHex(2),
|
|
779
|
+
this.b = fromHex(3);
|
|
780
|
+
this.a = hex.length == 5 ? fromHex(4) : 1;
|
|
781
|
+
}
|
|
782
|
+
else
|
|
783
|
+
{
|
|
784
|
+
const fromHex = (c)=> clamp(parseInt(hex.slice(c,c+2),16)/255);
|
|
785
|
+
this.r = fromHex(1);
|
|
786
|
+
this.g = fromHex(3),
|
|
787
|
+
this.b = fromHex(5);
|
|
788
|
+
this.a = hex.length == 9 ? fromHex(7) : 1;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
ASSERT(this.isValid());
|
|
753
792
|
return this;
|
|
754
793
|
}
|
|
755
794
|
|
|
@@ -763,6 +802,16 @@ class Color
|
|
|
763
802
|
const a = clamp(this.a)*255<<24;
|
|
764
803
|
return r + g + b + a;
|
|
765
804
|
}
|
|
805
|
+
|
|
806
|
+
/** Checks if this is a valid color
|
|
807
|
+
* @return {Boolean} */
|
|
808
|
+
isValid()
|
|
809
|
+
{
|
|
810
|
+
return typeof this.r == 'number' && !isNaN(this.r)
|
|
811
|
+
&& typeof this.g == 'number' && !isNaN(this.g)
|
|
812
|
+
&& typeof this.b == 'number' && !isNaN(this.b)
|
|
813
|
+
&& typeof this.a == 'number' && !isNaN(this.a);
|
|
814
|
+
}
|
|
766
815
|
}
|
|
767
816
|
|
|
768
817
|
///////////////////////////////////////////////////////////////////////////////
|
package/src/engineWebGL.js
CHANGED
|
@@ -207,7 +207,7 @@ function glCreateTexture(image)
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
// use point filtering for pixelated rendering
|
|
210
|
-
const filter =
|
|
210
|
+
const filter = tilesPixelated ? gl_NEAREST : gl_LINEAR;
|
|
211
211
|
glContext.texParameteri(gl_TEXTURE_2D, gl_TEXTURE_MIN_FILTER, filter);
|
|
212
212
|
glContext.texParameteri(gl_TEXTURE_2D, gl_TEXTURE_MAG_FILTER, filter);
|
|
213
213
|
return texture;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<body><script>const g=Math.PI;function n(t,i=0,e=1){return t<i?i:e<t?e:t}function aa(t,i,e){return(e-=i)?n((t-i)/e):0}function ba(t,i,e,a=q()){return 2*Math.abs(t.x-e.x)<i.x+a.x&&2*Math.abs(t.y-e.y)<i.y+a.y}function t(t=1,i=0){return i+Math.random()*(t-i)}function ca(i=1){return da(new v,t(2*g),i)}function ea(i=1){return 0<i?ca(i*t(0/i,1)**.5):new v}function ja(i=new w,e=new w(0,0,0,1),a=!1){return a?i.ma(e,t()):new w(t(i.r,e.r),t(i.j,e.j),t(i.b,e.b),t(i.a,e.a))}function q(t=0,i){return"number"==typeof t?new v(t,null==i?t:i):new v(t.x,t.y)}function da(t,i=0,e=1){return t.x=e*Math.sin(i),t.y=e*Math.cos(i),t}function ka(t){return t.x**2+t.y**2}function la(t,i){return(t.x-i.x)**2+(t.y-i.y)**2}function ma(t){var i=t.length();return 1<i?t.scale(1/i):t}function na(t){return Math.abs(t.x*t.y)}function pa(t,i){return 0<=t.x&&0<=t.y&&t.x<i.x&&t.y<i.y}class v{constructor(t=0,i=0){this.x=t,this.y=i}set(t=0,i=0){return this.x=t,this.y=i,this}v(){return new v(this.x,this.y)}add(t){return new v(this.x+t.x,this.y+t.y)}l(t){return new v(this.x-t.x,this.y-t.y)}multiply(t){return new v(this.x*t.x,this.y*t.y)}U(t){return new v(this.x/t.x,this.y/t.y)}scale(t){return new v(this.x*t,this.y*t)}length(){return ka(this)**.5}normalize(t=1){var i=this.length();return i?this.scale(t/i):new v(0,t)}angle(){return Math.atan2(this.x,this.y)}rotate(t){var i=Math.cos(t);return t=Math.sin(t),new v(this.x*i-this.y*t,this.x*t+this.y*i)}setDirection(t,i=1){return q(t%2?t-1?-i:i:0,t%2?0:t?-i:i)}direction(){return Math.abs(this.x)>Math.abs(this.y)?this.x<0?3:1:this.y<0?2:0}floor(){return new v(Math.floor(this.x),Math.floor(this.y))}ma(t,i){return this.add(t.l(this).scale(n(i)))}toString(){}}function qa(t){return(255*n(t.r)|0)+(255*n(t.j)<<8)+(255*n(t.b)<<16)+(255*n(t.a)<<24)}class w{constructor(t=1,i=1,e=1,a=1){this.r=t,this.j=i,this.b=e,this.a=a}set(t=1,i=1,e=1,a=1){return this.r=t,this.j=i,this.b=e,this.a=a,this}v(){return new w(this.r,this.j,this.b,this.a)}add(t){return new w(this.r+t.r,this.j+t.j,this.b+t.b,this.a+t.a)}l(t){return new w(this.r-t.r,this.j-t.j,this.b-t.b,this.a-t.a)}multiply(t){return new w(this.r*t.r,this.j*t.j,this.b*t.b,this.a*t.a)}U(t){return new w(this.r/t.r,this.j/t.j,this.b/t.b,this.a/t.a)}scale(t,i=t){return new w(this.r*t,this.j*t,this.b*t,this.a*i)}ma(t,i){return this.add(t.l(this).scale(n(i)))}toString(t=!0){var i=t=>((t=255*t|0)<16?"0":"")+t.toString(16);return"#"+i(this.r)+i(this.j)+i(this.b)+(t?i(this.a):"")}}class ra{constructor(){this.setTime=this.time=void 0}set(t=0){this.time=x+t,this.setTime=t}active(){return x<this.time}get(){return null!=this.time?x-this.time:0}toString(){}valueOf(){return this.get()}}function ua(t){var i,e=t.parent;e&&(i=e.o?-1:1,t.i=t.Ca.multiply(q(i,1)).rotate(-e.angle).add(e.i),t.angle=i*t.Ba+e.angle);for(const a of t.children)ua(a)}function va(t){if(!t.A){t.A=1,t.parent&&t.parent.removeChild(t);for(const i of t.children)va(i,i.parent=0)}}class wa{constructor(t=q(),i=q(1),e,a=0,s,h=0){this.i=t.v(),this.size=i,this.xa=void 0,this.s=e,this.angle=a,this.color=s,this.va=void 0,this.o=!1,this.h=xa,this.m=ya,this.K=za,this.u=Aa,this.X=Ba,this.B=1,this.P=h,this.g=q(),this.R=0,this.ua=x,this.children=[],this.ba=!0,this.parent=void 0,this.Ca=q(),this.Ba=0,this.la=this.ca=this.L=!1,y.push(this)}update(){var t;if(!this.parent&&(this.ba?(this.g.x=n(this.g.x,-z,z),this.g.y=n(this.g.y,-z,z)):(t=ka(this.g))>z*z&&(t=z/t**.5,this.g.x*=t,this.g.y*=t),t=this.i.v(),this.g.y+=Ca*this.B,this.i.x+=this.g.x*=this.m,this.i.y+=this.g.y*=this.m,this.angle+=this.R*=this.K,Da&&this.h)){var i,e,a,s,h,r,o=this.g.y<0;if(this.C&&(i=this.C.g?this.C.g.x:0,this.g.x=i+(this.g.x-i)*this.X,this.C=0),this.ca)for(var c of Ea)!this.la&&!c.la||c.A||c.parent||c==this||ba(this.i,this.size,c.i,c.size)&&(ba(t,this.size,c.i,c.size)?(i=(e=(i=t.l(c.i)).length())<.01?ca(.001):i.scale(.001/e),this.g=this.g.add(i),c.h&&(c.g=c.g.l(i))):(e=this.size.add(c.size),a=2*(t.y-c.i.y)>e.y+Ca,s=2*Math.abs(t.y-c.i.y)<e.y,h=2*Math.abs(t.x-c.i.x)<e.x,i=Math.max(this.u,c.u),!a&&!h&&s||(this.i.y=c.i.y+(e.y/2+.001)*Math.sign(t.y-c.i.y),c.C&&o||!c.h?(o&&(this.C=c),this.g.y*=-i):c.h&&(h=(this.h*this.g.y+c.h*c.g.y)/(this.h+c.h),r=c.g.y*(c.h-this.h)/(this.h+c.h)+2*this.g.y*this.h/(this.h+c.h),this.g.y=h+n(i)*(this.g.y*(this.h-c.h)/(this.h+c.h)+2*c.g.y*c.h/(this.h+c.h)-h),c.g.y=h+n(i)*(r-h))),!a&&s&&(this.i.x=c.i.x+(e.x/2+.001)*Math.sign(t.x-c.i.x),c.h?(e=(this.h*this.g.x+c.h*c.g.x)/(this.h+c.h),a=c.g.x*(c.h-this.h)/(this.h+c.h)+2*this.g.x*this.h/(this.h+c.h),this.g.x=e+n(i)*(this.g.x*(this.h-c.h)/(this.h+c.h)+2*c.g.x*c.h/(this.h+c.h)-e),c.g.x=e+n(i)*(a-e)):this.g.x*=-i)));this.L&&Fa(this.i,this.size,this)&&!Fa(t,this.size,this)&&(c=Fa(q(this.i.x,t.y),this.size,this),!Fa(q(t.x,this.i.y),this.size,this)&&c||(this.C=o,this.g.y*=-this.u,(o=(t.y-this.size.y/2|0)-(t.y-this.size.y/2))<0&&o>this.m*this.g.y+Ca*this.B&&(this.g.y=this.m?(o-Ca*this.B)/this.m:0),this.i.y=t.y),c)&&(this.i.x=t.x,this.g.x*=-this.u)}}H(){Ga(this.i,this.xa||this.size,this.s,this.color,this.angle,this.o,this.va)}removeChild(t){t.parent==this&&this.children.includes(t),this.children.splice(this.children.indexOf(t),1),t.parent=0}toString(){}}let B,C,D,Ha,E=q(),Na=[];function Oa(t=q(),i=Pa,e=0){var a;return F?new Qa:("number"==typeof i&&(i=q(i)),"number"==typeof t&&(t=q(t%(a=Na[e].size.x/i.x|0)*i.x,(t/a|0)*i.y)),new Qa(t,i,e))}class Qa{constructor(t=q(),i=Pa,e=0){this.i=t.v(),this.size=i.v(),this.$=e}offset(t){return new Qa(this.i.add(t),this.size,this.$)}frame(t){return this.offset(q(t*this.size.x,0))}}class Ra{constructor(t){var i;this.image=t,this.size=q(t.width,t.height),(i=Sa)&&(i=G.createTexture(),G.bindTexture(3553,i),t&&G.texImage2D(3553,0,6408,6408,5121,t),t=Ta?9728:9729,G.texParameteri(3553,10241,t),G.texParameteri(3553,10240,t)),this.ja=i,this.ya=q(Ua).U(this.size)}}function Va(t){return new v((t.x-I.x)*J+E.x/2-.5,(t.y-I.y)*-J+E.y/2-.5)}function Ga(t,i=q(1),h,n=new w,e=0,a,s=new w(0,0,0,0),r=Sa){const o=h&&Na[h.$];var c,u,l,b;r?o?(r=h.i.x/o.size.x,c=h.i.y/o.size.y,u=h.size.x/o.size.x,l=h.size.y/o.size.y,b=o.ya,Wa(o.ja),Xa(t.x,t.y,a?-i.x:i.x,i.y,e,r+b.x,c+b.y,r-b.x+u,c-b.y+l,qa(n),qa(s))):Xa(t.x,t.y,i.x,i.y,e,0,0,0,0,0,qa(n)):ab(t,i,e,a,t=>{var i,e,a,s;o?(i=h.i.x+Ua,e=h.i.y+Ua,a=h.size.x-2*Ua,s=h.size.y-2*Ua,t.globalAlpha=n.a,t.drawImage(o.image,i,e,a,s,-.5,-.5,1,1),t.globalAlpha=1):(t.fillStyle=n,t.fillRect(-.5,-.5,1,1))})}function ab(t,i,e,a,s){var h=C;t=Va(t),i=i.scale(J),h.save(),h.translate(t.x+.5,t.y+.5),h.rotate(e),h.scale(a?-i.x:i.x,-i.y),s(h),h.restore()}function bb(t){var i;Sa?cb=t:(i||=C).globalCompositeOperation=t?"lighter":"source-over"}function db(){var i=q(E.x/2,70),t=new w(0,0,0),e=eb,a=Ha;a.fillStyle=(new w).toString(),a.lineWidth=0,a.strokeStyle=t.toString(),a.textAlign="center",a.font="80px "+e,a.textBaseline="middle",a.lineJoin="round",i=i.v(),["LittleJS JS13K Demo"].forEach(t=>{a.fillText(t,i.x,i.y),i.y+=80})}function fb(t,i=0){return K[i]&&!!(1&K[i][t])}let gb=q(),hb=q(),ib=!1;function jb(t,i=0){return fb(t,i+1)}let K=[[]];function kb(){var t;F||(N&&lb||document.hasFocus()||(K=[[]]),t=hb,gb=new v((t.x-E.x/2+.5)/J+I.x,(t.y-E.y/2+.5)/-J+I.y),mb&&nb())}function ob(){if(!F)for(const t of K)for(const i in t)t[i]&=1}function pb(){function i(t){return qb?"KeyW"==t?"ArrowUp":"KeyS"==t?"ArrowDown":"KeyA"==t?"ArrowLeft":"KeyD"==t?"ArrowRight":t:t}F||(onkeydown=t=>{t.repeat||(ib=!1,K[0][t.code]=3,qb&&(K[0][i(t.code)]=3))},onkeyup=t=>{K[0][t.code]=4,qb&&(K[0][i(t.code)]=4)},onmousedown=t=>{ib=!1,K[0][t.button]=3,hb=rb(t),t.button&&t.preventDefault()},onmouseup=t=>K[0][t.button]=2&K[0][t.button]|4,onmousemove=t=>hb=rb(t),onwheel=t=>t.ctrlKey?0:Math.sign(t.deltaY),oncontextmenu=()=>!1,lb&&N&&!F&&sb())}function rb(t){var i;return!B||F?q():(i=B.getBoundingClientRect(),q(B.width,B.height).multiply(q(aa(t.x,i.left,i.right),aa(t.y,i.top,i.bottom))))}const tb=[];function nb(){var t=t=>{var i=t=>.3<t?aa(t,.3,.8):t<-.3?-aa(-t,.3,.8):0;return ma(q(i(t.x),i(-t.y)))};if(ub&&lb&&null!=Ab.time){(i=tb[0]||(tb[0]=[]))[0]=q(),Bb?i[0]=t(O):.3<ka(O)&&(i[0].x=Math.round(O.x),i[0].y=-Math.round(O.y),i[0]=ma(i[0]));for(var i=K[1]||(K[1]=[]),e=10;e--;){var a=3==e?2:2==e?3:e,s=jb(a,0);i[a]=Q[e]?s?1:3:s?4:0}}if(mb&&mb&&navigator&&navigator.getGamepads&&document.hasFocus())for(e=(i=navigator.getGamepads()).length;e--;){var s=i[e],h=K[e+1]||(K[e+1]=[]),a=tb[e]||(tb[e]=[]);if(s){for(var n=0;n<s.axes.length-1;n+=2)a[n>>1]=t(q(s.axes[n],s.axes[n+1]));for(n=s.buttons.length;n--;){var r=s.buttons[n],o=jb(n,e);h[n]=r.pressed?o?1:3:o?4:0,ib||=!e&&r.pressed}Cb&&ka(s=q((jb(15,e)&&1)-(jb(14,e)&&1),(jb(12,e)&&1)-(jb(13,e)&&1)))&&(a[0]=ma(s)),ub&&ib&&(Ab.time=void 0)}}}const lb=void 0!==window.ontouchstart;let Ab=new ra,Q,O;function sb(){function n(t){Db&&R&&"running"!=R.state&&new Eb([0]).play();var i=t.touches.length;return i?(hb=rb(q(t.touches[0].clientX,t.touches[0].clientY)),e?ib=!1:K[0][0]=3):e&&(K[0][0]=2&K[0][0]|4),e=i,document.hasFocus()&&t.preventDefault(),!0}let i=n;ub&&(i=function(t){if(O=q(),Q=[],ib=!0,!t.touches.length||(Ab.set(),!Fb)){var i=q(S,E.y-S),e=E.l(q(S,S)),a=E.scale(.5);for(const h of t.touches){var s=rb(q(h.clientX,h.clientY));la(s,i)**.5<S?O=ma(s.l(i).scale(2/S)):la(s,e)**.5<S?(s=s.l(e).direction(),Q[s]=1):la(s,a)**.5<S&&(Q[9]=1)}return n(t),!0}Q[9]=1},Q=[],O=q()),document.addEventListener("touchstart",t=>i(t),{passive:!1}),document.addEventListener("touchmove",t=>i(t),{passive:!1}),document.addEventListener("touchend",t=>i(t),{passive:!1}),onmousedown=onmouseup=()=>0;let e}function Gb(){if(N&&lb&&!F&&ub&&null!=Ab.time){var t=aa(Ab.get(),4,3);if(t&&!Fb){var i=Ha;if(i.save(),i.globalAlpha=t*Hb,i.strokeStyle="#fff",i.lineWidth=3,i.fillStyle=0<ka(O)?"#fff":"#000",i.beginPath(),t=q(S,E.y-S),Bb)i.arc(t.x,t.y,S/2,0,9),i.fill();else for(var e=10;e--;){var a=e*g/4;i.arc(t.x,t.y,.6*S,a+g/8,a+g/8),e%2&&i.arc(t.x,t.y,.33*S,a,a),1==e&&i.fill()}for(i.stroke(),t=q(E.x-S,E.y-S),e=4;e--;)a=t.add(q().setDirection(e,S/2)),i.fillStyle=Q[e]?"#fff":"#000",i.beginPath(),i.arc(a.x,a.y,S/4,0,9),i.fill(),i.stroke();i.restore()}}}let R,Ib;class Eb{constructor(t){var i=Jb,e=Kb;Db&&!F&&(this.Fa=i,this.Ja=e,this.O=0,t)&&(this.O=t[1]||.05,this.ta=[Lb(...t)],this.sampleRate=44100)}play(i,e=1,a=1,s=1,h=!1){if(Db&&!F&&this.ta){var n;if(i){if(n=this.Fa){var r=la(I,i);if(n*n<r)return;e*=aa(r**.5,n,n*this.Ja)}n=2*Va(i).x/B.width-1}return i=a+a*this.O*s*t(-1,1),this.za=R.createGain(),this.source=Mb(this.ta,e,i,n,h,this.sampleRate,this.za)}}stop(){this.source&&this.source.stop(),this.source=void 0}}let Nb=!1;function Mb(t,i=1,e=1,a=0,s=!1,h=44100,r){if(Db&&!F){var o,c=Nb;if(!(Nb="running"!=R.state)||(R.resume(),!c))return o=R.createBuffer(t.length,t[0].length,h),h=R.createBufferSource(),t.forEach((t,i)=>o.getChannelData(i).set(t)),h.buffer=o,h.playbackRate.value=e,h.loop=s,(r=r||R.createGain()).gain.value=i,r.connect(Ib),h.connect(new StereoPannerNode(R,{pan:n(a,-1,1)})).connect(r),h.start(),h}}function Lb(t=1,i,e=220,a=0,s=0,h=.1,r=0,o=1,c=0,u=0,l=0,b=0,f=0,d=0,y=0,x=0,v=0,m=1,w=0,p=0,q=0){let O=c*=500*(i=2*g)/44100/44100,S=e*=i/44100,z=[],G=0,k=0,M=0,B=1,U=0,J=0,D=0;var F=i*Math.abs(q)*2/44100,C=Math.cos(F),E=1+(A=Math.sin(F)/2/2),F=-2*C/E,A=(1-A)/E;let j=(1+Math.sign(q)*C)/2/E,P=-(Math.sign(q)+C)/E,T=0,K=0,I=0,R=0;for(u*=500*i/44100**3,y*=i/44100,l*=i/44100,b*=44100,f=44100*f|0,E=(a=44100*a+9)+(w*=44100)+(s*=44100)+(h*=44100)+(v*=44100)|0;M<E;z[M++]=D*t)++J%(100*x|0)||(D=r?1<r?2<r?3<r?Math.sin(G**3):n(Math.tan(G),1,-1):1-(2*G/i%2+2)%2:1-4*Math.abs(Math.round(G/i)-G/i):Math.sin(G),D=(f?1-p+p*Math.sin(i*M/f):1)*Math.sign(D)*Math.abs(D)**o*(M<a?M/a:M<a+w?1-(M-a)/w*(1-m):M<a+w+s?m:M<E-v?(E-M-v)/h*m:0),D=v?D/2+(v>M?0:(M<E-v?1:(E-M)/v)*z[M-v|0]/2/t):D,q&&(D=R=j*T+P*(T=K)+j*(K=D)-A*I-F*(I=R))),C=(e+=c+=u)*Math.cos(y*k++),G+=C+C*d*Math.sin(M**5),B&&++B>b&&(e+=l,S+=l,B=0),!f||++U%f||(e=S,c=O,B=B||1);return z}let Ob=[],T=q();function Fa(t,i=q(),e){var a=Math.max(t.x-i.x/2|0,0),s=Math.max(t.y-i.y/2|0,0),h=Math.min(t.x+i.x/2,T.x);for(t=Math.min(t.y+i.y/2,T.y);s<t;++s)for(i=a;i<h;++i){var n=Ob[s*T.x+i];if(n&&(!e||0<n))return!0}}class Pb{constructor(t,i=0,e=!1,a=new w){this.aa=t,this.direction=i,this.o=e,this.color=a}clear(){this.aa=this.direction=0,this.o=!1,this.color=new w}}class Qb extends wa{constructor(t,i=T){var e=q(1);for(super(t,i,Oa(),0,void 0,0),this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.scale=e,this.ka=!1,this.data=[],t=na(this.size);t--;)this.data.push(new Pb);F&&(this.qa=()=>{},this.H=()=>{},this.sa=()=>{},this.ra=()=>{},this.V=()=>{})}setData(t,i,e=!1){pa(t,this.size)&&(this.data[(0|t.y)*this.size.x+t.x|0]=i,e)&&this.V(t)}getData(t){return pa(t,this.size)&&this.data[(0|t.y)*this.size.x+t.x|0]}update(){}H(){Rb||this.ka||Sb();var t=Va(this.i.add(q(0,this.size.y*this.scale.y)));(this.ka?Ha:C).drawImage(this.canvas,t.x,t.y,J*this.size.x*this.scale.x,J*this.size.y*this.scale.y)}qa(){this.sa(!0);for(let i=this.size.x;i--;)for(let t=this.size.y;t--;)this.V(q(i,t),!1);this.ra()}sa(t=!1){this.Ga=[B,C,E,I,J],B=this.canvas,C=this.context,E=this.size.multiply(this.s.size),I=this.size.scale(.5),J=this.s.size.x,t&&(B.width=E.x,B.height=E.y),this.context.imageSmoothingEnabled=!Ta,Tb()}ra(){Sb(!0),[B,C,E,I,J]=this.Ga}V(t,i=!0){var e=this.s.size;i&&(i=t.multiply(e),this.context.clearRect(i.x,this.canvas.height-i.y,e.x,-e.y)),null!=(i=this.getData(t)).aa&&Ga(t=this.i.add(t).add(q(.5)),q(1),Oa(i.aa,e,this.s.$),i.color,i.direction*g/2,i.o)}}function Ub(i){var e="number"==typeof i.W?ea(i.W/2):q(t(-.5,.5),t(-.5,.5)).multiply(i.W).rotate(i.angle);let a=t(i.na,-i.na);i.Y||(e=i.i.add(e),a+=i.angle);const s=i.O;var h=(c=i=>i+i*t(s,-s))(i.Ea),n=c(i.Z),r=c(i.Ha),o=c(i.speed),c=c(i.wa)*(2*Math.floor(t(2,0))-1),u=t(i.ga,-i.ga),l=ja(i.S,i.T,i.pa),b=ja(i.da,i.ea,i.pa),u=i.Y?u:i.angle+u;(e=new Vb(e,i.s,a,l,b,h,n,r,i.G,i.J,i.I,i.Y&&i,i.Da)).g=da(q(),u,o),e.R=c,e.G=i.G,e.m=i.m,e.K=i.K,e.u=i.u,e.X=i.X,e.B=i.B,e.L=i.L,e.P=i.P,e.o=!!Math.floor(t(2,0)),i.oa&&i.oa(e)}class Wb extends wa{constructor(t,i,e=0,a=0,s=100,h=g,n,r=new w,o=new w,c=new w(1,1,1,0),u=new w(1,1,1,0),l=.5,b=.1,f=1,d=.1,y=.05,x=1,v=1,m=0,p=g,S=.1,z=.2,G=!1,M=!1,B=!0,D=M?1e9:0,F=!1){super(t,q(),n,i,void 0,D),this.W=e,this.ia=a,this.ha=s,this.ga=h,this.S=r,this.T=o,this.da=c,this.ea=u,this.pa=B,this.Ea=l,this.Z=b,this.Ha=f,this.speed=d,this.wa=y,this.m=x,this.K=v,this.B=m,this.na=p,this.G=S,this.O=z,this.L=G,this.J=M,this.Y=F,this.I=0,this.oa=this.Da=void 0,this.F=0}update(){if(this.parent&&super.update(),!this.ia||x-this.ua<=this.ia){if(this.ha*Xb){var t=1/this.ha/Xb;for(this.F+=Yb;0<this.F;this.F-=t)Ub(this)}}else va(this)}H(){}}class Vb extends wa{constructor(t,i,e,a,s,h,n,r,o,c,u,l,b){super(t,q(),i,e),this.N=a,this.M=s.l(a),this.Aa=h,this.Z=n,this.Ia=r-n,this.G=o,this.J=c,this.I=u,this.D=l,this.fa=b,this.ba=!1}H(){var t=Math.min((x-this.ua)/this.Aa,1),i=q(this.Z+t*this.Ia),e=this.G/2,e=new w(this.N.r+t*this.M.r,this.N.j+t*this.M.j,this.N.b+t*this.M.b,(this.N.a+t*this.M.a)*(t<e?t/e:1-e<t?(1-t)/e:1));this.J&&bb(!0);let a=this.i;var s,h,n=this.angle;this.D&&(a=this.D.i.add(a.rotate(-this.D.angle)),n+=this.D.angle),this.I?(s=this.g,(n=(s=this.D?s.rotate(-this.D.angle):s).length())&&(s=s.scale(1/n),h=n*this.I,i.y=Math.max(i.x,h),n=s.angle(),Ga(a.add(s.multiply(q(0,-h/2))),i,this.s,e,n,this.o))):Ga(a,i,this.s,e,n,this.o),this.J&&bb(),1==t&&(this.color=e,this.size=i,this.fa&&this.fa(this),this.A=1)}}let U,G,Zb,$b,ac,bc,V,cc,W,cb,dc;function ec(){var t;Sa&&!F&&(U=document.createElement("canvas"),G=U.getContext("webgl2"),Rb&&document.body.appendChild(U),t=G.createProgram(),G.attachShader(t,ic("#version 300 es\nprecision highp float;uniform mat4 m;in vec2 g;in vec4 p,u,c,a;in float r;out vec2 v;out vec4 d,e;void main(){vec2 s=(g-.5)*p.zw;gl_Position=m*vec4(p.xy+s*cos(r)-vec2(-s.y,s)*sin(r),1,1);v=mix(u.xw,u.zy,g);d=c;e=a;}",35633)),G.attachShader(t,ic("#version 300 es\nprecision highp float;uniform sampler2D s;in vec2 v;in vec4 d,e;out vec4 c;void main(){c=texture(s,v)*d+e;}",35632)),G.linkProgram(t),Zb=t,t=new ArrayBuffer(44e4),V=new Float32Array(t),cc=new Uint32Array(t),ac=G.createBuffer(),bc=G.createBuffer(),t=new Float32Array([W=0,0,1,0,0,1,1,1]),G.bindBuffer(34962,bc),G.bufferData(34962,t,35044))}function Tb(){var r,t,i;Sa&&!F&&(G.viewport(0,0,U.width=B.width,U.height=B.height),G.clear(16384),G.useProgram(Zb),G.activeTexture(33984),G.bindTexture(3553,$b=Na[0].ja),r=cb=dc=0,t=(t,i,e,a)=>{t=G.getAttribLocation(Zb,t);var s=e&&44,h=e&&1,n=1==e;G.enableVertexAttribArray(t),G.vertexAttribPointer(t,a,i,n,s,r),G.vertexAttribDivisor(t,h),r+=a*e},G.bindBuffer(34962,bc),t("g",5126,0,2),G.bindBuffer(34962,ac),G.bufferData(34962,44e4,35048),t("p",5126,4,4),t("u",5126,4,4),t("c",5121,1,4),t("a",5121,1,4),t("r",5126,4,1),t=q(2*J).U(E),i=q(-1).l(I.multiply(t)),G.uniformMatrix4fv(G.getUniformLocation(Zb,"m"),!1,[t.x,0,0,0,0,t.y,0,0,1,1,1,1,i.x,i.y,0,0]))}function Wa(t){F||t==$b||(jc(),G.bindTexture(3553,$b=t))}function ic(t,i){return i=G.createShader(i),G.shaderSource(i,t),G.compileShader(i),i}function jc(){var t;W&&(t=dc?1:771,G.blendFuncSeparate(770,t,1,t),G.enable(3042),G.bufferSubData(34962,0,V),G.drawArraysInstanced(5,0,4,W),W=0,dc=cb)}function Sb(t=!1){var i=C;Sa&&(W||t)&&(jc(),Rb&&!t||i.drawImage(U,0,0))}function Xa(t,i,e,a,s,h,n,r,o,c,u=0){(1e4<=W||dc!=cb)&&jc();var l=11*W;V[l++]=t,V[l++]=i,V[l++]=e,V[l++]=a,V[l++]=h,V[l++]=n,V[l++]=r,V[l++]=o,cc[l++]=c,cc[l++]=u,V[+l]=s,W++}const Yb=1/60;let y=[],Ea=[],kc=0,x=0,Fb=!1,lc=0,X=0;const mc=[],nc=[];function oc(){Ea=y.filter(t=>t.ca);for(const t of y)t.parent||(function t(i){if(!i.A){i.update();for(const e of i.children)t(e)}}(t),ua(t));y=y.filter(t=>!t.A)}let I=q(),J=32,pc=q(1920,1080),qc=q(),Ta=!0,eb="arial",F=!1,Sa=!0,Rb=!0,Pa=q(16),Ua=.5,Da=!0,xa=1,ya=1,za=1,Aa=0,Ba=.8,z=1,Ca=0,Xb=1,mb=!1,Cb=!(mb=!1),qb=!0,N=!1,ub=N=N=!1,Bb=!0,S=99,Hb=.3,Db=!0,rc=.3,Jb=40,Kb=.7;function sc(){var t=rc;rc=t,Db&&!F&&Ib&&(Ib.gain.value=t)}let Y;qb=N=!1;const tc=new Eb([1,.5]);!function(s,h,n,r,i=["tiles.png"]){function o(t=0){var i=t-lc;if(lc=t,X+=Fb?0:i,X=Math.min(X,50),c(),Fb){for(const e of y)e.parent||ua(e);kb(),h(),ob()}else{for(t=0,X<0&&-9<X&&(t=X,X=0);0<=X;X-=1e3/60)x=kc++/60,kb(),s(),mc.forEach(t=>t()),oc(),h(),ob();X+=t}if(!F){E=q(B.width,B.height),C.imageSmoothingEnabled=!Ta,Tb(),n(),y.sort((t,i)=>t.P-i.P);for(const a of y)a.A||a.H();r(),nc.forEach(t=>t()),Gb(),Sb()}requestAnimationFrame(o)}function c(){var t,i;F||(qc.x?(B.width=qc.x,B.height=qc.y,t=innerWidth/innerHeight,i=B.width/B.height,(U||B).style.width=B.style.width=D.style.width=t<i?"100%":"",(U||B).style.height=B.style.height=D.style.height=t<i?"":"100%"):(B.width=Math.min(innerWidth,pc.x),B.height=Math.min(innerHeight,pc.y)),D.width=B.width,D.height=B.height,E=q(B.width,B.height))}function e(){{T=q(32,16);for(var i=(Ob=[]).length=na(T);i--;)Ob[i]=0;i=q();var e=new Qb(i,T),a=Na[0].image,s=(C.drawImage(a,0,0),C.getImageData(0,0,a.width,a.height).data),h,n,r;for(i.x=T.x;i.x--;)for(i.y=T.y;i.y--;)s[4*(i.x+a.width*(15+T.y-i.y))]&&(h=Math.floor(t(4,0)),n=Math.floor(t(2,0)),r=ja(),e.setData(i,new Pb(1,h,n,r)),pa(i,T))&&(Ob[(0|i.y)*T.x+i.x|0]=1);e.qa(),I=q(16,8),Ca=-.01,(Y=new Wb(q(16,9),0,1,0,500,g,Oa(0,16),new w(1,1,1),new w(0,0,0),new w(0,0,0,0),new w(0,0,0,0),2,.2,.2,.1,.05,.99,1,1,g,.05,.5,1,1)).u=.3,Y.I=2}o()}F?e():(document.body.style.cssText="margin:0;overflow:hidden;background:#000;user-select:none;-webkit-user-select:none;"+(N?"touch-action:none;-webkit-touch-callout:none":""),document.body.appendChild(B=document.createElement("canvas")),C=B.getContext("2d"),pb(),Db&&!F&&(R=new AudioContext,(Ib=R.createGain()).connect(R.destination),sc()),ec(),document.body.appendChild(D=document.createElement("canvas")),Ha=D.getContext("2d"),(U||B).style.cssText=B.style.cssText=D.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)",c(),i=i.map((e,a)=>new Promise(t=>{const i=new Image;i.onerror=i.onload=()=>{Na[a]=new Ra(i),t()},i.src=e})),Promise.all(i).then(e))}(function(){K[0]&&2&K[0][0]&&(tc.play(gb),Y.S=new w,Y.T=ja(),Y.da=Y.S.scale(1,0),Y.ea=Y.T.scale(1,0)),hb.x&&(Y.i=gb)},function(){},function(){Ga(q(16,8),q(20,14),void 0,new w(.6,.6,.6),0,!1,void 0,0)},function(){db()});</script>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const g=Math.PI;function n(t,i=0,e=1){return t<i?i:e<t?e:t}function aa(t,i,e){return(e-=i)?n((t-i)/e):0}function ba(t,i,e,a=q()){return 2*Math.abs(t.x-e.x)<i.x+a.x&&2*Math.abs(t.y-e.y)<i.y+a.y}function t(t=1,i=0){return i+Math.random()*(t-i)}function ca(i=1){return da(new v,t(2*g),i)}function ea(i=1){return 0<i?ca(i*t(0/i,1)**.5):new v}function ja(i=new w,e=new w(0,0,0,1),a=!1){return a?i.ma(e,t()):new w(t(i.r,e.r),t(i.j,e.j),t(i.b,e.b),t(i.a,e.a))}function q(t=0,i){return"number"==typeof t?new v(t,null==i?t:i):new v(t.x,t.y)}function da(t,i=0,e=1){return t.x=e*Math.sin(i),t.y=e*Math.cos(i),t}function ka(t){return t.x**2+t.y**2}function la(t,i){return(t.x-i.x)**2+(t.y-i.y)**2}function ma(t){var i=t.length();return 1<i?t.scale(1/i):t}function na(t){return Math.abs(t.x*t.y)}function pa(t,i){return 0<=t.x&&0<=t.y&&t.x<i.x&&t.y<i.y}class v{constructor(t=0,i=0){this.x=t,this.y=i}set(t=0,i=0){return this.x=t,this.y=i,this}v(){return new v(this.x,this.y)}add(t){return new v(this.x+t.x,this.y+t.y)}l(t){return new v(this.x-t.x,this.y-t.y)}multiply(t){return new v(this.x*t.x,this.y*t.y)}U(t){return new v(this.x/t.x,this.y/t.y)}scale(t){return new v(this.x*t,this.y*t)}length(){return ka(this)**.5}normalize(t=1){var i=this.length();return i?this.scale(t/i):new v(0,t)}angle(){return Math.atan2(this.x,this.y)}rotate(t){var i=Math.cos(t);return t=Math.sin(t),new v(this.x*i-this.y*t,this.x*t+this.y*i)}setDirection(t,i=1){return q(t%2?t-1?-i:i:0,t%2?0:t?-i:i)}direction(){return Math.abs(this.x)>Math.abs(this.y)?this.x<0?3:1:this.y<0?2:0}floor(){return new v(Math.floor(this.x),Math.floor(this.y))}ma(t,i){return this.add(t.l(this).scale(n(i)))}toString(){}}function qa(t){return(255*n(t.r)|0)+(255*n(t.j)<<8)+(255*n(t.b)<<16)+(255*n(t.a)<<24)}class w{constructor(t=1,i=1,e=1,a=1){this.r=t,this.j=i,this.b=e,this.a=a}set(t=1,i=1,e=1,a=1){return this.r=t,this.j=i,this.b=e,this.a=a,this}v(){return new w(this.r,this.j,this.b,this.a)}add(t){return new w(this.r+t.r,this.j+t.j,this.b+t.b,this.a+t.a)}l(t){return new w(this.r-t.r,this.j-t.j,this.b-t.b,this.a-t.a)}multiply(t){return new w(this.r*t.r,this.j*t.j,this.b*t.b,this.a*t.a)}U(t){return new w(this.r/t.r,this.j/t.j,this.b/t.b,this.a/t.a)}scale(t,i=t){return new w(this.r*t,this.j*t,this.b*t,this.a*i)}ma(t,i){return this.add(t.l(this).scale(n(i)))}toString(t=!0){var i=t=>((t=255*t|0)<16?"0":"")+t.toString(16);return"#"+i(this.r)+i(this.j)+i(this.b)+(t?i(this.a):"")}}class ra{constructor(){this.setTime=this.time=void 0}set(t=0){this.time=x+t,this.setTime=t}active(){return x<this.time}get(){return null!=this.time?x-this.time:0}toString(){}valueOf(){return this.get()}}function ua(t){var i,e=t.parent;e&&(i=e.o?-1:1,t.i=t.Ca.multiply(q(i,1)).rotate(-e.angle).add(e.i),t.angle=i*t.Ba+e.angle);for(const a of t.children)ua(a)}function va(t){if(!t.A){t.A=1,t.parent&&t.parent.removeChild(t);for(const i of t.children)va(i,i.parent=0)}}class wa{constructor(t=q(),i=q(1),e,a=0,s,h=0){this.i=t.v(),this.size=i,this.xa=void 0,this.s=e,this.angle=a,this.color=s,this.va=void 0,this.o=!1,this.h=xa,this.m=ya,this.K=za,this.u=Aa,this.X=Ba,this.B=1,this.P=h,this.g=q(),this.R=0,this.ua=x,this.children=[],this.ba=!0,this.parent=void 0,this.Ca=q(),this.Ba=0,this.la=this.ca=this.L=!1,y.push(this)}update(){var t;if(!this.parent&&(this.ba?(this.g.x=n(this.g.x,-z,z),this.g.y=n(this.g.y,-z,z)):(t=ka(this.g))>z*z&&(t=z/t**.5,this.g.x*=t,this.g.y*=t),t=this.i.v(),this.g.y+=Ca*this.B,this.i.x+=this.g.x*=this.m,this.i.y+=this.g.y*=this.m,this.angle+=this.R*=this.K,Da&&this.h)){var i,e,a,s,h,r,o=this.g.y<0;if(this.C&&(i=this.C.g?this.C.g.x:0,this.g.x=i+(this.g.x-i)*this.X,this.C=0),this.ca)for(var c of Ea)!this.la&&!c.la||c.A||c.parent||c==this||ba(this.i,this.size,c.i,c.size)&&(ba(t,this.size,c.i,c.size)?(i=(e=(i=t.l(c.i)).length())<.01?ca(.001):i.scale(.001/e),this.g=this.g.add(i),c.h&&(c.g=c.g.l(i))):(e=this.size.add(c.size),a=2*(t.y-c.i.y)>e.y+Ca,s=2*Math.abs(t.y-c.i.y)<e.y,h=2*Math.abs(t.x-c.i.x)<e.x,i=Math.max(this.u,c.u),!a&&!h&&s||(this.i.y=c.i.y+(e.y/2+.001)*Math.sign(t.y-c.i.y),c.C&&o||!c.h?(o&&(this.C=c),this.g.y*=-i):c.h&&(h=(this.h*this.g.y+c.h*c.g.y)/(this.h+c.h),r=c.g.y*(c.h-this.h)/(this.h+c.h)+2*this.g.y*this.h/(this.h+c.h),this.g.y=h+n(i)*(this.g.y*(this.h-c.h)/(this.h+c.h)+2*c.g.y*c.h/(this.h+c.h)-h),c.g.y=h+n(i)*(r-h))),!a&&s&&(this.i.x=c.i.x+(e.x/2+.001)*Math.sign(t.x-c.i.x),c.h?(e=(this.h*this.g.x+c.h*c.g.x)/(this.h+c.h),a=c.g.x*(c.h-this.h)/(this.h+c.h)+2*this.g.x*this.h/(this.h+c.h),this.g.x=e+n(i)*(this.g.x*(this.h-c.h)/(this.h+c.h)+2*c.g.x*c.h/(this.h+c.h)-e),c.g.x=e+n(i)*(a-e)):this.g.x*=-i)));this.L&&Fa(this.i,this.size,this)&&!Fa(t,this.size,this)&&(c=Fa(q(this.i.x,t.y),this.size,this),!Fa(q(t.x,this.i.y),this.size,this)&&c||(this.C=o,this.g.y*=-this.u,(o=(t.y-this.size.y/2|0)-(t.y-this.size.y/2))<0&&o>this.m*this.g.y+Ca*this.B&&(this.g.y=this.m?(o-Ca*this.B)/this.m:0),this.i.y=t.y),c)&&(this.i.x=t.x,this.g.x*=-this.u)}}H(){Ga(this.i,this.xa||this.size,this.s,this.color,this.angle,this.o,this.va)}removeChild(t){t.parent==this&&this.children.includes(t),this.children.splice(this.children.indexOf(t),1),t.parent=0}toString(){}}let B,C,D,Ha,E=q(),Na=[];function Oa(t=q(),i=Pa,e=0){var a;return F?new Qa:("number"==typeof i&&(i=q(i)),"number"==typeof t&&(t=q(t%(a=Na[e].size.x/i.x|0)*i.x,(t/a|0)*i.y)),new Qa(t,i,e))}class Qa{constructor(t=q(),i=Pa,e=0){this.i=t.v(),this.size=i.v(),this.$=e}offset(t){return new Qa(this.i.add(t),this.size,this.$)}frame(t){return this.offset(q(t*this.size.x,0))}}class Ra{constructor(t){var i;this.image=t,this.size=q(t.width,t.height),(i=Sa)&&(i=G.createTexture(),G.bindTexture(3553,i),t&&G.texImage2D(3553,0,6408,6408,5121,t),t=Ta?9728:9729,G.texParameteri(3553,10241,t),G.texParameteri(3553,10240,t)),this.ja=i,this.ya=q(Ua).U(this.size)}}function Va(t){return new v((t.x-I.x)*J+E.x/2-.5,(t.y-I.y)*-J+E.y/2-.5)}function Ga(t,i=q(1),h,n=new w,e=0,a,s=new w(0,0,0,0),r=Sa){const o=h&&Na[h.$];var c,u,l,b;r?o?(r=h.i.x/o.size.x,c=h.i.y/o.size.y,u=h.size.x/o.size.x,l=h.size.y/o.size.y,b=o.ya,Wa(o.ja),Xa(t.x,t.y,a?-i.x:i.x,i.y,e,r+b.x,c+b.y,r-b.x+u,c-b.y+l,qa(n),qa(s))):Xa(t.x,t.y,i.x,i.y,e,0,0,0,0,0,qa(n)):ab(t,i,e,a,t=>{var i,e,a,s;o?(i=h.i.x+Ua,e=h.i.y+Ua,a=h.size.x-2*Ua,s=h.size.y-2*Ua,t.globalAlpha=n.a,t.drawImage(o.image,i,e,a,s,-.5,-.5,1,1),t.globalAlpha=1):(t.fillStyle=n,t.fillRect(-.5,-.5,1,1))})}function ab(t,i,e,a,s){var h=C;t=Va(t),i=i.scale(J),h.save(),h.translate(t.x+.5,t.y+.5),h.rotate(e),h.scale(a?-i.x:i.x,-i.y),s(h),h.restore()}function bb(t){var i;Sa?cb=t:(i||=C).globalCompositeOperation=t?"lighter":"source-over"}function db(){var i=q(E.x/2,70),t=new w(0,0,0),e=eb,a=Ha;a.fillStyle=(new w).toString(),a.lineWidth=0,a.strokeStyle=t.toString(),a.textAlign="center",a.font="80px "+e,a.textBaseline="middle",a.lineJoin="round",i=i.v(),["LittleJS JS13K Demo"].forEach(t=>{a.fillText(t,i.x,i.y),i.y+=80})}function fb(t,i=0){return K[i]&&!!(1&K[i][t])}let gb=q(),hb=q(),ib=!1;function jb(t,i=0){return fb(t,i+1)}let K=[[]];function kb(){var t;F||(N&&lb||document.hasFocus()||(K=[[]]),t=hb,gb=new v((t.x-E.x/2+.5)/J+I.x,(t.y-E.y/2+.5)/-J+I.y),mb&&nb())}function ob(){if(!F)for(const t of K)for(const i in t)t[i]&=1}function pb(){function i(t){return qb?"KeyW"==t?"ArrowUp":"KeyS"==t?"ArrowDown":"KeyA"==t?"ArrowLeft":"KeyD"==t?"ArrowRight":t:t}F||(onkeydown=t=>{t.repeat||(ib=!1,K[0][t.code]=3,qb&&(K[0][i(t.code)]=3))},onkeyup=t=>{K[0][t.code]=4,qb&&(K[0][i(t.code)]=4)},onmousedown=t=>{ib=!1,K[0][t.button]=3,hb=rb(t),t.button&&t.preventDefault()},onmouseup=t=>K[0][t.button]=2&K[0][t.button]|4,onmousemove=t=>hb=rb(t),onwheel=t=>t.ctrlKey?0:Math.sign(t.deltaY),oncontextmenu=()=>!1,lb&&N&&!F&&sb())}function rb(t){var i;return!B||F?q():(i=B.getBoundingClientRect(),q(B.width,B.height).multiply(q(aa(t.x,i.left,i.right),aa(t.y,i.top,i.bottom))))}const tb=[];function nb(){var t=t=>{var i=t=>.3<t?aa(t,.3,.8):t<-.3?-aa(-t,.3,.8):0;return ma(q(i(t.x),i(-t.y)))};if(ub&&lb&&null!=Ab.time){(i=tb[0]||(tb[0]=[]))[0]=q(),Bb?i[0]=t(O):.3<ka(O)&&(i[0].x=Math.round(O.x),i[0].y=-Math.round(O.y),i[0]=ma(i[0]));for(var i=K[1]||(K[1]=[]),e=10;e--;){var a=3==e?2:2==e?3:e,s=jb(a,0);i[a]=Q[e]?s?1:3:s?4:0}}if(mb&&mb&&navigator&&navigator.getGamepads&&document.hasFocus())for(e=(i=navigator.getGamepads()).length;e--;){var s=i[e],h=K[e+1]||(K[e+1]=[]),a=tb[e]||(tb[e]=[]);if(s){for(var n=0;n<s.axes.length-1;n+=2)a[n>>1]=t(q(s.axes[n],s.axes[n+1]));for(n=s.buttons.length;n--;){var r=s.buttons[n],o=jb(n,e);h[n]=r.pressed?o?1:3:o?4:0,ib||=!e&&r.pressed}Cb&&ka(s=q((jb(15,e)&&1)-(jb(14,e)&&1),(jb(12,e)&&1)-(jb(13,e)&&1)))&&(a[0]=ma(s)),ub&&ib&&(Ab.time=void 0)}}}const lb=void 0!==window.ontouchstart;let Ab=new ra,Q,O;function sb(){function n(t){Db&&R&&"running"!=R.state&&new Eb([0]).play();var i=t.touches.length;return i?(hb=rb(q(t.touches[0].clientX,t.touches[0].clientY)),e?ib=!1:K[0][0]=3):e&&(K[0][0]=2&K[0][0]|4),e=i,document.hasFocus()&&t.preventDefault(),!0}let i=n;ub&&(i=function(t){if(O=q(),Q=[],ib=!0,!t.touches.length||(Ab.set(),!Fb)){var i=q(S,E.y-S),e=E.l(q(S,S)),a=E.scale(.5);for(const h of t.touches){var s=rb(q(h.clientX,h.clientY));la(s,i)**.5<S?O=ma(s.l(i).scale(2/S)):la(s,e)**.5<S?(s=s.l(e).direction(),Q[s]=1):la(s,a)**.5<S&&(Q[9]=1)}return n(t),!0}Q[9]=1},Q=[],O=q()),document.addEventListener("touchstart",t=>i(t),{passive:!1}),document.addEventListener("touchmove",t=>i(t),{passive:!1}),document.addEventListener("touchend",t=>i(t),{passive:!1}),onmousedown=onmouseup=()=>0;let e}function Gb(){if(N&&lb&&!F&&ub&&null!=Ab.time){var t=aa(Ab.get(),4,3);if(t&&!Fb){var i=Ha;if(i.save(),i.globalAlpha=t*Hb,i.strokeStyle="#fff",i.lineWidth=3,i.fillStyle=0<ka(O)?"#fff":"#000",i.beginPath(),t=q(S,E.y-S),Bb)i.arc(t.x,t.y,S/2,0,9),i.fill();else for(var e=10;e--;){var a=e*g/4;i.arc(t.x,t.y,.6*S,a+g/8,a+g/8),e%2&&i.arc(t.x,t.y,.33*S,a,a),1==e&&i.fill()}for(i.stroke(),t=q(E.x-S,E.y-S),e=4;e--;)a=t.add(q().setDirection(e,S/2)),i.fillStyle=Q[e]?"#fff":"#000",i.beginPath(),i.arc(a.x,a.y,S/4,0,9),i.fill(),i.stroke();i.restore()}}}let R,Ib;class Eb{constructor(t){var i=Jb,e=Kb;Db&&!F&&(this.Fa=i,this.Ja=e,this.O=0,t)&&(this.O=t[1]||.05,this.ta=[Lb(...t)],this.sampleRate=44100)}play(i,e=1,a=1,s=1,h=!1){if(Db&&!F&&this.ta){var n;if(i){if(n=this.Fa){var r=la(I,i);if(n*n<r)return;e*=aa(r**.5,n,n*this.Ja)}n=2*Va(i).x/B.width-1}return i=a+a*this.O*s*t(-1,1),this.za=R.createGain(),this.source=Mb(this.ta,e,i,n,h,this.sampleRate,this.za)}}stop(){this.source&&this.source.stop(),this.source=void 0}}let Nb=!1;function Mb(t,i=1,e=1,a=0,s=!1,h=44100,r){if(Db&&!F){var o,c=Nb;if(!(Nb="running"!=R.state)||(R.resume(),!c))return o=R.createBuffer(t.length,t[0].length,h),h=R.createBufferSource(),t.forEach((t,i)=>o.getChannelData(i).set(t)),h.buffer=o,h.playbackRate.value=e,h.loop=s,(r=r||R.createGain()).gain.value=i,r.connect(Ib),h.connect(new StereoPannerNode(R,{pan:n(a,-1,1)})).connect(r),h.start(),h}}function Lb(t=1,i,e=220,a=0,s=0,h=.1,r=0,o=1,c=0,u=0,l=0,b=0,f=0,d=0,y=0,x=0,v=0,m=1,w=0,p=0,q=0){let O=c*=500*(i=2*g)/44100/44100,S=e*=i/44100,z=[],G=0,k=0,M=0,B=1,U=0,J=0,D=0;var F=i*Math.abs(q)*2/44100,C=Math.cos(F),E=1+(A=Math.sin(F)/2/2),F=-2*C/E,A=(1-A)/E;let j=(1+Math.sign(q)*C)/2/E,P=-(Math.sign(q)+C)/E,T=0,K=0,I=0,R=0;for(u*=500*i/44100**3,y*=i/44100,l*=i/44100,b*=44100,f=44100*f|0,E=(a=44100*a+9)+(w*=44100)+(s*=44100)+(h*=44100)+(v*=44100)|0;M<E;z[M++]=D*t)++J%(100*x|0)||(D=r?1<r?2<r?3<r?Math.sin(G**3):n(Math.tan(G),1,-1):1-(2*G/i%2+2)%2:1-4*Math.abs(Math.round(G/i)-G/i):Math.sin(G),D=(f?1-p+p*Math.sin(i*M/f):1)*Math.sign(D)*Math.abs(D)**o*(M<a?M/a:M<a+w?1-(M-a)/w*(1-m):M<a+w+s?m:M<E-v?(E-M-v)/h*m:0),D=v?D/2+(v>M?0:(M<E-v?1:(E-M)/v)*z[M-v|0]/2/t):D,q&&(D=R=j*T+P*(T=K)+j*(K=D)-A*I-F*(I=R))),C=(e+=c+=u)*Math.cos(y*k++),G+=C+C*d*Math.sin(M**5),B&&++B>b&&(e+=l,S+=l,B=0),!f||++U%f||(e=S,c=O,B=B||1);return z}let Ob=[],T=q();function Fa(t,i=q(),e){var a=Math.max(t.x-i.x/2|0,0),s=Math.max(t.y-i.y/2|0,0),h=Math.min(t.x+i.x/2,T.x);for(t=Math.min(t.y+i.y/2,T.y);s<t;++s)for(i=a;i<h;++i){var n=Ob[s*T.x+i];if(n&&(!e||0<n))return!0}}class Pb{constructor(t,i=0,e=!1,a=new w){this.aa=t,this.direction=i,this.o=e,this.color=a}clear(){this.aa=this.direction=0,this.o=!1,this.color=new w}}class Qb extends wa{constructor(t,i=T){var e=q(1);for(super(t,i,Oa(),0,void 0,0),this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.scale=e,this.ka=!1,this.data=[],t=na(this.size);t--;)this.data.push(new Pb);F&&(this.qa=()=>{},this.H=()=>{},this.sa=()=>{},this.ra=()=>{},this.V=()=>{})}setData(t,i,e=!1){pa(t,this.size)&&(this.data[(0|t.y)*this.size.x+t.x|0]=i,e)&&this.V(t)}getData(t){return pa(t,this.size)&&this.data[(0|t.y)*this.size.x+t.x|0]}update(){}H(){Rb||this.ka||Sb();var t=Va(this.i.add(q(0,this.size.y*this.scale.y)));(this.ka?Ha:C).drawImage(this.canvas,t.x,t.y,J*this.size.x*this.scale.x,J*this.size.y*this.scale.y)}qa(){this.sa(!0);for(let i=this.size.x;i--;)for(let t=this.size.y;t--;)this.V(q(i,t),!1);this.ra()}sa(t=!1){this.Ga=[B,C,E,I,J],B=this.canvas,C=this.context,E=this.size.multiply(this.s.size),I=this.size.scale(.5),J=this.s.size.x,t&&(B.width=E.x,B.height=E.y),this.context.imageSmoothingEnabled=!Ta,Tb()}ra(){Sb(!0),[B,C,E,I,J]=this.Ga}V(t,i=!0){var e=this.s.size;i&&(i=t.multiply(e),this.context.clearRect(i.x,this.canvas.height-i.y,e.x,-e.y)),null!=(i=this.getData(t)).aa&&Ga(t=this.i.add(t).add(q(.5)),q(1),Oa(i.aa,e,this.s.$),i.color,i.direction*g/2,i.o)}}function Ub(i){var e="number"==typeof i.W?ea(i.W/2):q(t(-.5,.5),t(-.5,.5)).multiply(i.W).rotate(i.angle);let a=t(i.na,-i.na);i.Y||(e=i.i.add(e),a+=i.angle);const s=i.O;var h=(c=i=>i+i*t(s,-s))(i.Ea),n=c(i.Z),r=c(i.Ha),o=c(i.speed),c=c(i.wa)*(2*Math.floor(t(2,0))-1),u=t(i.ga,-i.ga),l=ja(i.S,i.T,i.pa),b=ja(i.da,i.ea,i.pa),u=i.Y?u:i.angle+u;(e=new Vb(e,i.s,a,l,b,h,n,r,i.G,i.J,i.I,i.Y&&i,i.Da)).g=da(q(),u,o),e.R=c,e.G=i.G,e.m=i.m,e.K=i.K,e.u=i.u,e.X=i.X,e.B=i.B,e.L=i.L,e.P=i.P,e.o=!!Math.floor(t(2,0)),i.oa&&i.oa(e)}class Wb extends wa{constructor(t,i,e=0,a=0,s=100,h=g,n,r=new w,o=new w,c=new w(1,1,1,0),u=new w(1,1,1,0),l=.5,b=.1,f=1,d=.1,y=.05,x=1,v=1,m=0,p=g,S=.1,z=.2,G=!1,M=!1,B=!0,D=M?1e9:0,F=!1){super(t,q(),n,i,void 0,D),this.W=e,this.ia=a,this.ha=s,this.ga=h,this.S=r,this.T=o,this.da=c,this.ea=u,this.pa=B,this.Ea=l,this.Z=b,this.Ha=f,this.speed=d,this.wa=y,this.m=x,this.K=v,this.B=m,this.na=p,this.G=S,this.O=z,this.L=G,this.J=M,this.Y=F,this.I=0,this.oa=this.Da=void 0,this.F=0}update(){if(this.parent&&super.update(),!this.ia||x-this.ua<=this.ia){if(this.ha*Xb){var t=1/this.ha/Xb;for(this.F+=Yb;0<this.F;this.F-=t)Ub(this)}}else va(this)}H(){}}class Vb extends wa{constructor(t,i,e,a,s,h,n,r,o,c,u,l,b){super(t,q(),i,e),this.N=a,this.M=s.l(a),this.Aa=h,this.Z=n,this.Ia=r-n,this.G=o,this.J=c,this.I=u,this.D=l,this.fa=b,this.ba=!1}H(){var t=Math.min((x-this.ua)/this.Aa,1),i=q(this.Z+t*this.Ia),e=this.G/2,e=new w(this.N.r+t*this.M.r,this.N.j+t*this.M.j,this.N.b+t*this.M.b,(this.N.a+t*this.M.a)*(t<e?t/e:1-e<t?(1-t)/e:1));this.J&&bb(!0);let a=this.i;var s,h,n=this.angle;this.D&&(a=this.D.i.add(a.rotate(-this.D.angle)),n+=this.D.angle),this.I?(s=this.g,(n=(s=this.D?s.rotate(-this.D.angle):s).length())&&(s=s.scale(1/n),h=n*this.I,i.y=Math.max(i.x,h),n=s.angle(),Ga(a.add(s.multiply(q(0,-h/2))),i,this.s,e,n,this.o))):Ga(a,i,this.s,e,n,this.o),this.J&&bb(),1==t&&(this.color=e,this.size=i,this.fa&&this.fa(this),this.A=1)}}let U,G,Zb,$b,ac,bc,V,cc,W,cb,dc;function ec(){var t;Sa&&!F&&(U=document.createElement("canvas"),G=U.getContext("webgl2"),Rb&&document.body.appendChild(U),t=G.createProgram(),G.attachShader(t,ic("#version 300 es\nprecision highp float;uniform mat4 m;in vec2 g;in vec4 p,u,c,a;in float r;out vec2 v;out vec4 d,e;void main(){vec2 s=(g-.5)*p.zw;gl_Position=m*vec4(p.xy+s*cos(r)-vec2(-s.y,s)*sin(r),1,1);v=mix(u.xw,u.zy,g);d=c;e=a;}",35633)),G.attachShader(t,ic("#version 300 es\nprecision highp float;uniform sampler2D s;in vec2 v;in vec4 d,e;out vec4 c;void main(){c=texture(s,v)*d+e;}",35632)),G.linkProgram(t),Zb=t,t=new ArrayBuffer(44e4),V=new Float32Array(t),cc=new Uint32Array(t),ac=G.createBuffer(),bc=G.createBuffer(),t=new Float32Array([W=0,0,1,0,0,1,1,1]),G.bindBuffer(34962,bc),G.bufferData(34962,t,35044))}function Tb(){var r,t,i;Sa&&!F&&(G.viewport(0,0,U.width=B.width,U.height=B.height),G.clear(16384),G.useProgram(Zb),G.activeTexture(33984),G.bindTexture(3553,$b=Na[0].ja),r=cb=dc=0,t=(t,i,e,a)=>{t=G.getAttribLocation(Zb,t);var s=e&&44,h=e&&1,n=1==e;G.enableVertexAttribArray(t),G.vertexAttribPointer(t,a,i,n,s,r),G.vertexAttribDivisor(t,h),r+=a*e},G.bindBuffer(34962,bc),t("g",5126,0,2),G.bindBuffer(34962,ac),G.bufferData(34962,44e4,35048),t("p",5126,4,4),t("u",5126,4,4),t("c",5121,1,4),t("a",5121,1,4),t("r",5126,4,1),t=q(2*J).U(E),i=q(-1).l(I.multiply(t)),G.uniformMatrix4fv(G.getUniformLocation(Zb,"m"),!1,[t.x,0,0,0,0,t.y,0,0,1,1,1,1,i.x,i.y,0,0]))}function Wa(t){F||t==$b||(jc(),G.bindTexture(3553,$b=t))}function ic(t,i){return i=G.createShader(i),G.shaderSource(i,t),G.compileShader(i),i}function jc(){var t;W&&(t=dc?1:771,G.blendFuncSeparate(770,t,1,t),G.enable(3042),G.bufferSubData(34962,0,V),G.drawArraysInstanced(5,0,4,W),W=0,dc=cb)}function Sb(t=!1){var i=C;Sa&&(W||t)&&(jc(),Rb&&!t||i.drawImage(U,0,0))}function Xa(t,i,e,a,s,h,n,r,o,c,u=0){(1e4<=W||dc!=cb)&&jc();var l=11*W;V[l++]=t,V[l++]=i,V[l++]=e,V[l++]=a,V[l++]=h,V[l++]=n,V[l++]=r,V[l++]=o,cc[l++]=c,cc[l++]=u,V[+l]=s,W++}const Yb=1/60;let y=[],Ea=[],kc=0,x=0,Fb=!1,lc=0,X=0;const mc=[],nc=[];function oc(){Ea=y.filter(t=>t.ca);for(const t of y)t.parent||(function t(i){if(!i.A){i.update();for(const e of i.children)t(e)}}(t),ua(t));y=y.filter(t=>!t.A)}let I=q(),J=32,pc=q(1920,1080),qc=q(),Ta=!0,eb="arial",F=!1,Sa=!0,Rb=!0,Pa=q(16),Ua=.5,Da=!0,xa=1,ya=1,za=1,Aa=0,Ba=.8,z=1,Ca=0,Xb=1,mb=!1,Cb=!(mb=!1),qb=!0,N=!1,ub=N=N=!1,Bb=!0,S=99,Hb=.3,Db=!0,rc=.3,Jb=40,Kb=.7;function sc(){var t=rc;rc=t,Db&&!F&&Ib&&(Ib.gain.value=t)}let Y;qb=N=!1;const tc=new Eb([1,.5]);!function(s,h,n,r,i=["tiles.png"]){function o(t=0){var i=t-lc;if(lc=t,X+=Fb?0:i,X=Math.min(X,50),c(),Fb){for(const e of y)e.parent||ua(e);kb(),h(),ob()}else{for(t=0,X<0&&-9<X&&(t=X,X=0);0<=X;X-=1e3/60)x=kc++/60,kb(),s(),mc.forEach(t=>t()),oc(),h(),ob();X+=t}if(!F){E=q(B.width,B.height),C.imageSmoothingEnabled=!Ta,Tb(),n(),y.sort((t,i)=>t.P-i.P);for(const a of y)a.A||a.H();r(),nc.forEach(t=>t()),Gb(),Sb()}requestAnimationFrame(o)}function c(){var t,i;F||(qc.x?(B.width=qc.x,B.height=qc.y,t=innerWidth/innerHeight,i=B.width/B.height,(U||B).style.width=B.style.width=D.style.width=t<i?"100%":"",(U||B).style.height=B.style.height=D.style.height=t<i?"":"100%"):(B.width=Math.min(innerWidth,pc.x),B.height=Math.min(innerHeight,pc.y)),D.width=B.width,D.height=B.height,E=q(B.width,B.height))}function e(){{T=q(32,16);for(var i=(Ob=[]).length=na(T);i--;)Ob[i]=0;i=q();var e=new Qb(i,T),a=Na[0].image,s=(C.drawImage(a,0,0),C.getImageData(0,0,a.width,a.height).data),h,n,r;for(i.x=T.x;i.x--;)for(i.y=T.y;i.y--;)s[4*(i.x+a.width*(15+T.y-i.y))]&&(h=Math.floor(t(4,0)),n=Math.floor(t(2,0)),r=ja(),e.setData(i,new Pb(1,h,n,r)),pa(i,T))&&(Ob[(0|i.y)*T.x+i.x|0]=1);e.qa(),I=q(16,8),Ca=-.01,(Y=new Wb(q(16,9),0,1,0,500,g,Oa(0,16),new w(1,1,1),new w(0,0,0),new w(0,0,0,0),new w(0,0,0,0),2,.2,.2,.1,.05,.99,1,1,g,.05,.5,1,1)).u=.3,Y.I=2}o()}F?e():(document.body.style.cssText="margin:0;overflow:hidden;background:#000;user-select:none;-webkit-user-select:none;"+(N?"touch-action:none;-webkit-touch-callout:none":""),document.body.appendChild(B=document.createElement("canvas")),C=B.getContext("2d"),pb(),Db&&!F&&(R=new AudioContext,(Ib=R.createGain()).connect(R.destination),sc()),ec(),document.body.appendChild(D=document.createElement("canvas")),Ha=D.getContext("2d"),(U||B).style.cssText=B.style.cssText=D.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)",c(),i=i.map((e,a)=>new Promise(t=>{const i=new Image;i.onerror=i.onload=()=>{Na[a]=new Ra(i),t()},i.src=e})),Promise.all(i).then(e))}(function(){K[0]&&2&K[0][0]&&(tc.play(gb),Y.S=new w,Y.T=ja(),Y.da=Y.S.scale(1,0),Y.ea=Y.T.scale(1,0)),hb.x&&(Y.i=gb)},function(){},function(){Ga(q(16,8),q(20,14),void 0,new w(.6,.6,.6),0,!1,void 0,0)},function(){db()});
|
|
Binary file
|
|
Binary file
|
package/examples/js13k/game.zip
DELETED
|
Binary file
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><head><title>Little JS Starter Project</title></head><script>const h=Math.PI;function m(t,i=0,a=1){return t<i?i:a<t?a:t}function aa(t,i,a){return a-i?m((t-i)/(a-i)):0}function ba(t,i,a,e){return 2*Math.abs(t.x-a.x)<i.x+e.x&&2*Math.abs(t.y-a.y)<i.y+e.y}function n(t=1,i=0){return i+Math.random()*(t-i)}function ca(t=1){return fa(new p,n(2*h),t)}function ha(t=1){return 0<t?ca(t*n(0/t,1)**.5):new p}function ia(t=new v,i=new v(0,0,0,1),a){return a?t.ha(i,n()):new v(n(t.r,i.r),n(t.j,i.j),n(t.b,i.b),n(t.a,i.a))}function x(t=0,i){return null==t.x?new p(t,null==i?t:i):new p(t.x,t.y)}function fa(t,i=0,a=1){return t.x=a*Math.sin(i),t.y=a*Math.cos(i),t}function ja(t){var i=t.length();return 1<i?t.scale(1/i):t}function ka(t,i){return 0<=t.x&&0<=t.y&&t.x<i.x&&t.y<i.y}class p{constructor(t=0,i=0){this.x=t,this.y=i}M(){return new p(this.x,this.y)}add(t){return new p(this.x+t.x,this.y+t.y)}u(t){return new p(this.x-t.x,this.y-t.y)}multiply(t){return new p(this.x*t.x,this.y*t.y)}ca(t){return new p(this.x/t.x,this.y/t.y)}scale(t){return new p(this.x*t,this.y*t)}length(){return(this.x**2+this.y**2)**.5}normalize(t=1){var i=this.length();return i?this.scale(t/i):new p(0,t)}angle(){return Math.atan2(this.x,this.y)}rotate(t){var i=Math.cos(t);return t=Math.sin(t),new p(this.x*i-this.y*t,this.x*t+this.y*i)}direction(){return Math.abs(this.x)>Math.abs(this.y)?this.x<0?3:1:this.y<0?2:0}floor(){return new p(Math.floor(this.x),Math.floor(this.y))}ha(t,i){return this.add(t.u(this).scale(m(i)))}toString(){}}function la(t=1){var i=new v,a=t<.5?+t:t+0-0*t,e=(t,i,a)=>(a=(a%1+1)%1)<1/6?t+6*(i-t)*a:a<.5?i:a<2/3?t+(i-t)*(2/3-a)*6:t;return i.r=e(t=2*t-a,a,1/3),i.j=e(t,a,0),i.b=e(t,a,-1/3),i.a=1,i}function ma(t){return(255*m(t.r)|0)+((255*m(t.j)|0)<<8)+((255*m(t.b)|0)<<16)+((255*m(t.a)|0)<<24)}class v{constructor(t=1,i=1,a=1,e=1){this.r=t,this.j=i,this.b=a,this.a=e}M(){return new v(this.r,this.j,this.b,this.a)}add(t){return new v(this.r+t.r,this.j+t.j,this.b+t.b,this.a+t.a)}u(t){return new v(this.r-t.r,this.j-t.j,this.b-t.b,this.a-t.a)}multiply(t){return new v(this.r*t.r,this.j*t.j,this.b*t.b,this.a*t.a)}ca(t){return new v(this.r/t.r,this.j/t.j,this.b/t.b,this.a/t.a)}scale(t,i=t){return new v(this.r*t,this.j*t,this.b*t,this.a*i)}ha(t,i){return this.add(t.u(this).scale(m(i)))}toString(t=1){var i=t=>((t=255*t|0)<16?"0":"")+t.toString(16);return"#"+i(this.r)+i(this.j)+i(this.b)+(t?i(this.a):"")}}let y=x(),z=32,na=x(1920,1200),oa=x(),pa=x(16),qa=0,ra=x(640,80);function sa(t){if(!t.v){t.v=1,t.parent&&t.parent.removeChild(t);for(const i of t.children)sa(i,i.parent=0)}}class ta{constructor(t=x(),i=x(1),a,e=0,s,h=0){this.i=t.M(),this.size=i,this.pa,this.l=a,this.angle=e,this.color=s,this.ma,this.I=this.m=this.h=1,this.s=0,this.W=.8,this.A=1,this.O=h,this.g=x(),this.R=0,this.ka=ua,this.children=[],this.J=1,A.push(this)}update(){var t=this.parent;if(t)this.i=this.Ca.multiply(x(t.o?-1:1,1)).rotate(-t.angle).add(t.i),this.angle=(t.o?-1:1)*this.Ba+t.angle;else if(this.g.x=m(this.g.x,-1,1),this.g.y=m(this.g.y,-1,1),t=this.i.M(),this.g.y+=qa*this.A,this.i.x+=this.g.x*=this.m,this.i.y+=this.g.y*=this.m,this.angle+=this.R*=this.I,this.h){var i,a,e,s,h,n,r=this.g.y<0;if(this.B&&(i=this.B.g?this.B.g.x:0,this.g.x=i+(this.g.x-i)*this.W,this.B=0),this.oa)for(var o of va)!this.sa&&!o.sa||o.v||o.parent||o==this||ba(this.i,this.size,o.i,o.size)&&(ba(t,this.size,o.i,o.size)?(i=(a=(i=t.u(o.i)).length())<.01?ca(.001):i.scale(.001/a),this.g=this.g.add(i),o.h&&(o.g=o.g.u(i))):(a=this.size.add(o.size),e=2*(t.y-o.i.y)>a.y+qa,s=2*Math.abs(t.y-o.i.y)<a.y,h=2*Math.abs(t.x-o.i.x)<a.x,i=Math.max(this.s,o.s),!e&&!h&&s||(this.i.y=o.i.y+(a.y/2+.001)*Math.sign(t.y-o.i.y),o.B&&r||!o.h?(r&&(this.B=o),this.g.y*=-i):o.h&&(h=(this.h*this.g.y+o.h*o.g.y)/(this.h+o.h),n=o.g.y*(o.h-this.h)/(this.h+o.h)+2*this.g.y*this.h/(this.h+o.h),this.g.y=h+m(i)*(this.g.y*(this.h-o.h)/(this.h+o.h)+2*o.g.y*o.h/(this.h+o.h)-h),o.g.y=h+m(i)*(n-h))),!e&&s&&(this.i.x=o.i.x+(a.x/2+.001)*Math.sign(t.x-o.i.x),o.h?(a=(this.h*this.g.x+o.h*o.g.x)/(this.h+o.h),e=o.g.x*(o.h-this.h)/(this.h+o.h)+2*this.g.x*this.h/(this.h+o.h),this.g.x=a+m(i)*(this.g.x*(this.h-o.h)/(this.h+o.h)+2*o.g.x*o.h/(this.h+o.h)-a),o.g.x=a+m(i)*(e-a)):this.g.x*=-i)));this.J&&wa(this.i,this.size,this)&&!wa(t,this.size,this)&&(o=wa(x(this.i.x,t.y),this.size,this),!wa(x(t.x,this.i.y),this.size,this)&&o||(this.B=r,this.g.y*=-this.s,(r=(t.y-this.size.y/2|0)-(t.y-this.size.y/2))<0&&r>this.m*this.g.y+qa*this.A&&(this.g.y=this.m?(r-qa*this.A)/this.m:0),this.i.y=t.y),o)&&(this.i.x=t.x,this.g.x*=-this.s)}}D(){B(this.i,this.pa||this.size,this.l,this.color,this.angle,this.o,this.ma)}removeChild(t){t.parent==this&&this.children.includes(t),this.children.splice(this.children.indexOf(t),1),t.parent=0}toString(){}}let D,G,H,xa,J=x(),K=[];function Da(t=x(),i=pa,a=0){var e;return null==i.x&&(i=x(i)),null==t.x&&(t=x(t%(e=K[a].size.x/i.x|0)*i.x,(t/e|0)*i.y)),new Ea(t,i,a)}class Ea{constructor(t=x(),i=pa,a=0){this.i=t,this.size=i,this.P=a}offset(t){return new Ea(this.i.add(t),this.size,this.P)}}class Fa{constructor(t){this.image=t,this.size=x(t.width,t.height);var i=L.createTexture();L.bindTexture(3553,i),t&&t.width&&L.texImage2D(3553,0,6408,6408,5121,t),L.texParameteri(3553,10241,9728),L.texParameteri(3553,10240,9728),L.texParameteri(3553,10242,33071),L.texParameteri(3553,10243,33071),this.ga=i,this.qa=x(.3).ca(this.size)}}function Ga(){var t=Ha;return new p((t.x-J.x/2+.5)/z+y.x,(t.y-J.y/2+.5)/-z+y.y)}function Ia(t){return new p((t.x-y.x)*z+J.x/2-.5,(t.y-y.y)*-z+J.y/2-.5)}function B(t,i=x(1),h,n=new v,a=0,e,s=new v(0,0,0,0),r=1){var o,l,c,u,y;r?h?(r=K[h.P],o=h.size.x/r.size.x,l=h.size.y/r.size.y,c=h.i.x/r.size.x,u=h.i.y/r.size.y,y=r.qa,Ja(r.ga),Ka(t.x,t.y,e?-i.x:i.x,i.y,a,c+y.x,u+y.y,c-y.x+o,u-y.y+l,ma(n),ma(s))):Ka(t.x,t.y,i.x,i.y,a,0,0,0,0,0,ma(n)):La(t,i,a,e,t=>{var i,a,e,s;h?(i=h.i.x+.3,a=h.i.y+.3,e=h.size.x-.6,s=h.size.y-.6,t.globalAlpha=n.a,t.drawImage(K[h.P].image,i,a,e,s,-.5,-.5,1,1)):(t.fillStyle=n,t.fillRect(-.5,-.5,1,1))})}function La(t,i,a,e,s){var h=G;t=Ia(t),i=i.scale(z),h.save(),h.translate(t.x+.5,t.y+.5),h.rotate(a),h.scale(e?-i.x:i.x,i.y),s(h),h.restore()}function Ma(t,i,a=1,e=new v,s=0,h=new v(0,0,0),n="center"){var r=xa;r.fillStyle=e,r.lineWidth=s,r.strokeStyle=h,r.textAlign=n,r.font=a+"px arial",r.textBaseline="middle",r.lineJoin="round",i=i.M(),(t+"").split("\n").forEach(t=>{s&&r.strokeText(t,i.x,i.y),r.fillText(t,i.x,i.y),i.y+=a})}function Na(t,i=0){return M[i]&&1&M[i][t]}let Oa=x(),Ha=x();function N(t,i=0){return Na(t,i+1)}let M=[[]];function Pa(){for(const t of M)for(const i in t)t[i]&=1}function Qa(t){return 87==t?38:83==t?40:65==t?37:68==t?39:t}onkeydown=t=>{t.repeat||(M[0][Qa(t.which)]=3)},onkeyup=t=>{M[0][Qa(t.which)]=4},onmousedown=t=>{M[0][t.button]=3,onmousemove(t),t.button&&t.preventDefault()},onmouseup=t=>M[0][t.button]=2&M[0][t.button]|4,onmousemove=t=>{var i;return t=D?(i=D.getBoundingClientRect(),x(D.width,D.height).multiply(x(aa(t.x,i.left,i.right),aa(t.y,i.top,i.bottom)))):x(),Ha=t},onwheel=t=>t.ctrlKey||Math.sign(t.deltaY),oncontextmenu=()=>!1;const Ra=[];function Sa(){if(navigator&&navigator.getGamepads&&document.hasFocus()){var i=navigator.getGamepads();for(let t=i.length;t--;){var a=i[t],e=M[t+1]||(M[t+1]=[]),s=Ra[t]||(Ra[t]=[]);if(a){var h=t=>.3<t?aa(t,.3,.8):t<-.3?-aa(-t,.3,.8):0;for(let t=0;t<a.axes.length-1;t+=2)s[t>>1]=ja(x(h(a.axes[t]),h(-a.axes[t+1])));for(h=a.buttons.length;h--;)e[h]=a.buttons[h].pressed?1+2*!N(h,t):4*N(h,t);(a=x(N(15,t)-N(14,t),N(12,t)-N(13,t))).x**2+a.y**2&&(s[0]=ja(a))}}}}const Ta=void 0!==window.ontouchstart;if(Ta){let a,e=onmousedown,s=onmouseup;onmousedown=onmouseup=()=>0,ontouchstart=ontouchmove=ontouchend=t=>{t.button=0,O?O.resume():Ua([Va(0)]);var i=t.touches.length;return i?(t.x=t.touches[0].clientX,t.y=t.touches[0].clientY,(a?onmousemove:e)(t)):a&&s(t),a=i,document.hasFocus()&&t.preventDefault(),!0}}class Wa{constructor(){var t=[1,.5];this.wa=40,this.Aa=.7,this.N=0,t&&(this.N=t[1]||(t[1]=0),this.ja=[Va(...t)],this.sampleRate=44100)}play(t,i=1,a=1,e=1,s=0){if(this.ja){var h;if(t){if(h=this.wa){var r=y;if(h*h<(r=(y.x-t.x)**2+(r.y-t.y)**2))return;i*=aa(r**.5,h,h*this.Aa)}h=2*Ia(t).x/D.width-1}return this.source=Ua(this.ja,i,a+a*this.N*e*n(-1,1),h,s,this.sampleRate)}}stop(){this.source&&this.source.stop(),this.source=0}}let O;function Ua(t,i=1,a=1,e=0,s=0,h=44100){var n;if("running"==(O||=new AudioContext).state)return n=O.createBuffer(t.length,t[0].length,h),h=O.createBufferSource(),t.forEach((t,i)=>n.getChannelData(i).set(t)),h.buffer=n,h.playbackRate.value=a,h.loop=s,(t=O.createGain()).gain.value=.5*i,t.connect(O.destination),h.connect(new StereoPannerNode(O,{pan:m(e,-1,1)})).connect(t),h.start(),h;O.resume()}function Va(t=1,i=.05,a=220,e=0,s=0,r=.1,o=0,l=1,c=0,u=0,x=0,y=0,d=0,b=0,g=0,f=0,v=0,m=1,w=0,p=0){var M=2*h,z=c*=500*M/44100/44100,D=[];i=a*=(1+i*n(-1,1))*M/44100;let L=0,S=0,A=0,j=1,B=0,C=0,G=0,k,H;for(u*=500*M/44100**3,g*=M/44100,x*=M/44100,y*=44100,d=44100*d|0,H=(e=44100*e+9)+(w*=44100)+(s*=44100)+(r*=44100)+(v*=44100)|0;A<H;D[A++]=G)++C%(100*f|0)||(G=o?1<o?2<o?3<o?Math.sin((L%M)**3):Math.max(Math.min(Math.tan(L),1),-1):1-(2*L/M%2+2)%2:1-4*Math.abs(Math.round(L/M)-L/M):Math.sin(L),G=(d?1-p+p*Math.sin(M*A/d):1)*Math.sign(G)*Math.abs(G)**l*t*.5*(A<e?A/e:A<e+w?1-(A-e)/w*(1-m):A<e+w+s?m:A<H-v?(H-A-v)/r*m:0),G=v?G/2+(v>A?0:(A<H-v?1:(H-A)/v)*D[A-v|0]/2):G),k=(a+=c+=u)*Math.cos(g*S++),L+=k-k*b*(1-1e9*(Math.sin(A)+1)%2),j&&++j>y&&(a+=x,i+=x,j=0),!d||++B%d||(a=i,c=z,j||=1);return D}let Xa=[],Q=x();function wa(t,i=x(),a){var e=Math.max(t.x-i.x/2|0,0),s=Math.max(t.y-i.y/2|0,0),h=Math.min(t.x+i.x/2,Q.x);for(t=Math.min(t.y+i.y/2,Q.y);s<t;++s)for(i=e;i<h;++i){var n=Xa[s*Q.x+i];if(n&&(!a||0<n))return 1}}class Ya{constructor(t,i=0,a=0,e=new v){this.Z=t,this.direction=i,this.o=a,this.color=e}clear(){this.Z=this.direction=this.o=0,color=new v}}function Za(t,i){var a=i.floor().add(t.i).add(x(.5));$a(t,a,t=>t.clearRect(-.5,-.5,1,1)),null!=(i=t.getData(i)).Z&&B(a,x(1),Da(i.Z,t.l.size,t.l.P),i.color,i.direction*h/2,i.o)}function $a(t,i,a){var e=x(1),s=t.context;s.save(),i=i.u(t.i).multiply(t.l.size),e=e.multiply(t.l.size),s.translate(i.x,t.canvas.height-i.y),s.rotate(0),s.scale(e.x,e.y),a(s),s.restore()}class ab extends ta{constructor(t,i=Q){var a=x(1);for(super(t,i,Da(),0,void 0,0),this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.scale=a,this.ra,this.data=[],t=this.size,t=Math.abs(t.x*t.y);t--;)this.data.push(new Ya)}setData(t,i,a){ka(t,this.size)&&(this.data[(0|t.y)*this.size.x+t.x|0]=i,a)&&Za(this,t)}getData(t){return ka(t,this.size)&&this.data[(0|t.y)*this.size.x+t.x|0]}update(){}D(){var t=Ia(this.i.add(x(0,this.size.y*this.scale.y)));(this.ra?xa:G).drawImage(this.canvas,t.x,t.y,z*this.size.x*this.scale.x,z*this.size.y*this.scale.y)}}function bb(t){var i=null!=t.U.x?x(n(-.5,.5),n(-.5,.5)).multiply(t.U).rotate(t.angle):ha(t.U/2);t.X||(i=t.i.add(i)),i=new cb(i,t.l,t.Ea);const a=t.N;var e=(o=t=>t+t*n(a,-a))(t.va),s=o(t.Y),h=o(t.ya),r=o(t.speed),o=o(t.na)*(2*Math.floor(n(2,0))-1),l=n(t.da,-t.da),c=ia(t.S,t.T,t.ia),u=ia(t.$,t.aa,t.ia),l=t.X?l:t.angle+l;i.L=c,i.K=u.u(c),i.g=fa(x(),l,r),i.R=o,i.ta=e,i.Y=s,i.za=h-s,i.V=t.V,i.m=t.m,i.I=t.I,i.s=t.s,i.W=t.W,i.A=t.A,i.J=t.J,i.H=t.H,i.O=t.O,i.G=t.G,i.o=Math.floor(n(2,0)),i.C=t.X&&t,i.ba=t.Da,t.ua&&t.ua(i)}class db extends ta{constructor(t,i,a=0,e=0,s=100,n=h,r,o=new v,l=new v,c=new v(1,1,1,0),u=new v(1,1,1,0),y=.5,d=.1,b=1,g=.1,f=.05,m=1,w=1,p=0,M,z=.1,D=.2,L,S,A=1,j=S?1e9:0,B){super(t,x(),r,i,void 0,j),this.U=a,this.fa=e,this.ea=s,this.da=n,this.S=o,this.T=l,this.$=c,this.aa=u,this.ia=A,this.va=y,this.Y=d,this.ya=b,this.speed=g,this.na=f,this.m=m,this.I=w,this.A=p,this.V=z,this.N=D,this.J=L,this.H=S,this.X=B,this.F=this.G=0}update(){if(this.parent&&super.update(),!this.fa||ua-this.ka<=this.fa){if(+this.ea){var t=1/this.ea;for(this.F+=eb;0<this.F;this.F-=t)bb(this)}}else sa(this)}D(){}}class cb extends ta{constructor(t,i,a){super(t,x(),i,a)}D(){var t=Math.min((ua-this.ka)/this.ta,1),i=x(this.Y+t*this.za),a=this.V/2,a=new v(this.L.r+t*this.K.r,this.L.j+t*this.K.j,this.L.b+t*this.K.b,(this.L.a+t*this.K.a)*(t<a?t/a:1-a<t?(1-t)/a:1));this.H&&fb(1);let e=this.i;var s,h,n=this.angle;this.C&&(e=this.C.i.add(e.rotate(-this.C.angle)),n+=this.C.angle),this.G?(s=this.g,n=(s=this.C?s.rotate(-this.C.angle):s).length(),s=s.scale(1/n),h=n*this.G,i.y=Math.max(i.x,h),n=s.angle(),B(e.add(s.multiply(x(0,-h/2))),i,this.l,a,n,this.o)):B(e,i,this.l,a,n,this.o),this.H&&fb(),1==t&&(this.color=a,this.size=i,this.ba&&this.ba(this),this.v=1)}}const gb=[];let hb=[],ib,jb;class kb{constructor(){(gb[this.id=0]=this).name="Example Medal",this.description="Welcome to LittleJS!",this.icon="🏆"}unlock(){this.la||(localStorage[ib+"_"+this.id]=this.la=1,hb.push(this),lb&&lb.Fa(this.id))}D(t=0){var i=xa,a=Math.min(ra.x,D.width),e=H.width-a;t*=-ra.y,i.save(),i.beginPath(),i.fillStyle=new v(.9,.9,.9),i.strokeStyle=new v(0,0,0),i.lineWidth=3,i.fill(i.rect(e,t,a,ra.y)),i.stroke(),i.clip(),a=x(e+15+25,t+ra.y/2),this.image?xa.drawImage(this.image,a.x-25,a.y-25,50,50):Ma(this.icon,a,35,new v(0,0,0)),e=x(e+50+30,t+28),Ma(this.name,e,38,new v(0,0,0),0,0,"left"),e.y+=32,Ma(this.description,e,24,new v(0,0,0),0,0,"left"),i.restore()}}function mb(){var t,i;hb.length&&(t=hb[0],i=nb-jb,jb?5<i?hb.shift(jb=0):t.D(i<.5?1-i/.5:4.5<i?(i-4.5)/.5:0):jb=nb)}let lb,S,L,ob,pb,qb,T,tb,U,ub,vb;function wb(){S=document.createElement("canvas"),L=S.getContext("webgl",{antialias:!1}),document.body.appendChild(S);var t=L.createProgram();L.attachShader(t,xb("precision highp float;uniform mat4 m;attribute vec2 p,t;attribute vec4 c,a;varying vec4 v,d,e;void main(){gl_Position=m*vec4(p,1,1);v=vec4(t,p);d=c;e=a;}",35633)),L.attachShader(t,xb("precision highp float;varying vec4 v,d,e;uniform sampler2D s;void main(){gl_FragColor=texture2D(s,v.xy)*d+e;}",35632)),L.linkProgram(t),pb=t,t=new ArrayBuffer(24e5),qb=L.createBuffer(),T=new Float32Array(t),tb=new Uint32Array(t),U=0}function yb(){L.viewport(0,0,S.width=D.width,S.height=D.height),L.clear(16384),L.useProgram(pb),L.activeTexture(33984),L.bindTexture(3553,ob=K[0].ga),L.bindBuffer(34962,qb),L.bufferData(34962,24e5,35048),fb();let h=0;var t=(t,i,a,e,s=0)=>{t=L.getAttribLocation(pb,t),L.enableVertexAttribArray(t),L.vertexAttribPointer(t,e,i,s,24,h),h+=e*a},i=(t("p",5126,4,2),t("t",5126,4,2),t("c",5121,1,4,1),t("a",5121,1,4,1),t=2*z/D.width,2*z/D.height);L.uniformMatrix4fv(L.getUniformLocation(pb,"m"),0,new Float32Array([t,0,0,0,0,i,0,0,1,1,-1,1,-1-t*y.x,-1-i*y.y,0,0]))}function fb(t=0){vb=t}function Ja(t){t!=ob&&(zb(),L.bindTexture(3553,ob=t))}function xb(t,i){return i=L.createShader(i),L.shaderSource(i,t),L.compileShader(i),i}function zb(){var t;U&&(t=ub?1:771,L.blendFuncSeparate(770,t,1,t),L.enable(3042),L.bufferSubData(34962,0,T.subarray(0,6*U)),L.drawArrays(5,0,U),U=0,ub=vb)}function Ab(t){var i=G;(U||t)&&(zb(),t)&&i.drawImage(S,0,0)}function Ka(a,e,t,i,s,h,n,r,o,l,c=0){(99994<=U||ub!=vb)&&zb();var u=Math.cos(s)/2,x=Math.sin(s)/2;s=u*t,u*=i,a=[a-s+(i*=x),e+u+(t*=x),h,n,a-s-i,e-u+t,h,o,a+s+i,e+u-t,r,n,a+s-i,e-u-t,r,o];for(let t=6,i=6*U;t--;)e=4*m(t-1,0,3),T[i++]=a[e++],T[i++]=a[e++],T[i++]=a[e++],T[i++]=a[e++],tb[i++]=l,tb[i++]=c;U+=6}const eb=1/60;let A=[],va=[],Bb=0,ua=0,nb=0,Cb=0,V=0;function Db(){J=x(D.width,D.height),G.imageSmoothingEnabled=!1,yb()}function Eb(){va=A.filter(t=>t.oa);for(const t of A)t.parent||function t(i){if(!i.v){i.update();for(const a of i.children)t(a)}}(t);A=A.filter(t=>!t.v)}const Fb=new Wa,Gb=new kb;ib="Hello World",gb.forEach(t=>t.la=0|localStorage[ib+"_"+t.id]);let Z;!function(e,s,r,o){function l(t=0){var i=t-Cb;for(Cb=t,nb+=i/1e3,V+=i,V=Math.min(V,50),oa.x?(D.width=oa.x,D.height=oa.y,t=innerWidth/innerHeight,i=D.width/D.height,(S||D).style.width=D.style.width=H.style.width=t<i?"100%":"",(S||D).style.height=D.style.height=H.style.height=t<i?"":"100%"):(D.width=Math.min(innerWidth,na.x),D.height=Math.min(innerHeight,na.y)),H.width=D.width,H.height=D.height,J=x(D.width,D.height),t=0,V<0&&-9<V&&(t=V,V=0);0<=V;V-=1e3/60)ua=Bb++/60,Ta||document.hasFocus()||(M=[[]]),Oa=Ga(),Sa(),e(),Eb(),s(),Pa();V+=t,Db(),r(),A.sort((t,i)=>t.O-i.O);for(const a of A)a.v||a.D();o(),mb(),Ab(),requestAnimationFrame(l)}document.body.style="margin:0;overflow:hidden;background:#000;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none",document.body.appendChild(D=document.createElement("canvas")),G=D.getContext("2d"),wb(),document.body.appendChild(H=document.createElement("canvas")),xa=H.getContext("2d"),(S||D).style=D.style=H.style="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);image-rendering:pixelated",Promise.all(["tiles.png","tiles3.png"].map((a,e)=>new Promise(t=>{const i=new Image;i.onerror=i.onload=()=>{K[e]=new Fa(i),t()},i.src=a}))).then(()=>{{Q=x(32,16);for(var t=(Xa=[]).length=Math.abs(Q.x*Q.y);t--;)Xa[t]=0;var i=x(),t=new ab(i,Q),a=K[0].image,e=(G.drawImage(a,0,0),G.getImageData(0,0,a.width,a.height).data),s,r,o;for(i.x=Q.x;i.x--;)for(i.y=Q.y;i.y--;)e[4*(i.x+a.width*(15+Q.y-i.y))]&&(s=Math.floor(n(4,0)),r=Math.floor(n(2,0)),(o=ia()).a=.1,t.setData(i,new Ya(1,s,r,o)),ka(i,Q))&&(Xa[(0|i.y)*Q.x+i.x|0]=1);for(t.xa=[D,G,J,y,z],D=t.canvas,G=t.context,y=t.size.scale(.5),z=t.l.size.x,D.width=t.size.x*t.l.size.x,D.height=t.size.y*t.l.size.y,Db(),i=t.size.x;i--;)for(a=t.size.y;a--;)Za(t,x(i,a));Ab(1),[D,G,J,y,z]=t.xa,y=x(16,8),z=48,qa=-.01,(Z=new db(x(16,15),0,1,0,500,h,Da(0,16),new v(1,1,1),new v(0,0,0),new v(1,1,1,0),new v(0,0,0,0),2,.2,.2,.1,.05,.99,1,1,h,.05,.5,1,1)).s=.3,Z.G=2}l()})}(function(){M[0]&&2&M[0][0]&&(Fb.play(Oa),Z.S=new v,Z.T=ia(),Z.$=Z.S.scale(1,0),Z.aa=Z.T.scale(1,0),Gb.unlock()),Ha.x&&(Z.i=Oa)},function(){},function(){B(x(16,8),x(20,14),void 0,la(.6),0,0,void 0,0),B(x(21,5),x(4.5),Da(2,16,1))},function(){Ma("LittleJS Engine Demo",x(J.x/2,70),80,la(1),6,la(0))});
|
|
2
|
-
</script>
|