littlejsengine 1.9.11 → 1.10.2
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 +4 -0
- package/dist/littlejs.d.ts +80 -9
- package/dist/littlejs.esm.js +193 -71
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +175 -69
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +174 -68
- package/examples/box2d/game.js +1 -1
- package/examples/box2d/index.html +7 -6
- package/examples/breakout/game.js +1 -1
- package/examples/breakout/index.html +5 -4
- package/examples/breakoutTutorial/index.html +4 -3
- package/examples/electron/game.js +1 -1
- package/examples/electron/index.html +4 -3
- package/examples/empty/game.js +1 -1
- package/examples/empty/index.html +2 -1
- package/examples/htmlMenu/game.js +67 -0
- package/examples/htmlMenu/index.html +56 -0
- package/examples/htmlMenu/tiles.png +0 -0
- package/examples/index.html +33 -0
- package/examples/js13k/game.js +1 -1
- package/examples/js13k/index.html +17 -14
- package/examples/module/game.js +1 -1
- package/examples/module/index.html +3 -2
- package/examples/particles/index.html +4 -3
- package/examples/platformer/game.js +1 -1
- package/examples/platformer/gameLevel.js +2 -2
- package/examples/platformer/gameObjects.js +0 -1
- package/examples/platformer/index.html +10 -9
- package/examples/puzzle/game.js +1 -1
- package/examples/puzzle/index.html +4 -3
- package/examples/starter/game.js +4 -4
- package/examples/starter/index.html +15 -14
- package/examples/stress/index.html +3 -2
- package/examples/typescript/game.js +1 -1
- package/examples/typescript/index.html +3 -2
- package/examples/uiSystem/game.js +134 -0
- package/examples/uiSystem/index.html +25 -0
- package/examples/uiSystem/tiles.png +0 -0
- package/jsconfig.json +11 -0
- package/package.json +1 -1
- package/plugins/box2d.js +2 -1
- package/plugins/postProcess.js +6 -7
- package/plugins/uiSystem.js +243 -0
- package/src/engine.js +48 -20
- package/src/engineAudio.js +10 -13
- package/src/engineDebug.js +1 -1
- package/src/engineDraw.js +101 -27
- package/src/engineExport.js +18 -2
- package/src/engineInput.js +2 -2
- package/src/engineSettings.js +1 -1
- package/src/engineUtilities.js +1 -1
- package/src/engineWebGL.js +11 -4
package/src/engineExport.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
2
|
* LittleJS Module Export
|
|
3
3
|
* - Export engine as a module
|
|
4
4
|
*/
|
|
@@ -20,8 +20,9 @@ export {
|
|
|
20
20
|
engineObjectsUpdate,
|
|
21
21
|
engineObjectsDestroy,
|
|
22
22
|
engineObjectsCallback,
|
|
23
|
+
engineObjectsRaycast,
|
|
23
24
|
engineAddPlugin,
|
|
24
|
-
|
|
25
|
+
|
|
25
26
|
// Globals
|
|
26
27
|
debug,
|
|
27
28
|
debugOverlay,
|
|
@@ -140,6 +141,7 @@ export {
|
|
|
140
141
|
smoothStep,
|
|
141
142
|
nearestPowerOfTwo,
|
|
142
143
|
isOverlapping,
|
|
144
|
+
isIntersecting,
|
|
143
145
|
wave,
|
|
144
146
|
formatTime,
|
|
145
147
|
|
|
@@ -159,6 +161,20 @@ export {
|
|
|
159
161
|
vec2,
|
|
160
162
|
rgb,
|
|
161
163
|
hsl,
|
|
164
|
+
isColor,
|
|
165
|
+
|
|
166
|
+
// Default Colors
|
|
167
|
+
WHITE,
|
|
168
|
+
BLACK,
|
|
169
|
+
GRAY,
|
|
170
|
+
RED,
|
|
171
|
+
ORANGE,
|
|
172
|
+
YELLOW,
|
|
173
|
+
GREEN,
|
|
174
|
+
CYAN,
|
|
175
|
+
BLUE,
|
|
176
|
+
PURPLE,
|
|
177
|
+
MAGENTA,
|
|
162
178
|
|
|
163
179
|
// Draw
|
|
164
180
|
textureInfos,
|
package/src/engineInput.js
CHANGED
|
@@ -167,7 +167,7 @@ function inputInit()
|
|
|
167
167
|
|
|
168
168
|
onkeydown = (e)=>
|
|
169
169
|
{
|
|
170
|
-
if (debug && e.target !=
|
|
170
|
+
if (debug && e.target != engineRoot) return;
|
|
171
171
|
if (!e.repeat)
|
|
172
172
|
{
|
|
173
173
|
isUsingGamepad = false;
|
|
@@ -180,7 +180,7 @@ function inputInit()
|
|
|
180
180
|
|
|
181
181
|
onkeyup = (e)=>
|
|
182
182
|
{
|
|
183
|
-
if (debug && e.target !=
|
|
183
|
+
if (debug && e.target != engineRoot) return;
|
|
184
184
|
inputData[0][e.code] = 4;
|
|
185
185
|
if (inputWASDEmulateDirection)
|
|
186
186
|
inputData[0][remapKey(e.code)] = 4;
|
package/src/engineSettings.js
CHANGED
|
@@ -89,7 +89,7 @@ let tileSizeDefault = vec2(16);
|
|
|
89
89
|
* @type {Number}
|
|
90
90
|
* @default
|
|
91
91
|
* @memberof Settings */
|
|
92
|
-
let tileFixBleedScale =
|
|
92
|
+
let tileFixBleedScale = 0;
|
|
93
93
|
|
|
94
94
|
///////////////////////////////////////////////////////////////////////////////
|
|
95
95
|
// Object settings
|
package/src/engineUtilities.js
CHANGED
|
@@ -735,7 +735,7 @@ class Color
|
|
|
735
735
|
* @return {String} */
|
|
736
736
|
toString(useAlpha = true)
|
|
737
737
|
{
|
|
738
|
-
const toHex = (c)=> ((c=c*255|0)<16 ? '0' : '') + c.toString(16);
|
|
738
|
+
const toHex = (c)=> ((c=clamp(c)*255|0)<16 ? '0' : '') + c.toString(16);
|
|
739
739
|
return '#' + toHex(this.r) + toHex(this.g) + toHex(this.b) + (useAlpha ? toHex(this.a) : '');
|
|
740
740
|
}
|
|
741
741
|
|
package/src/engineWebGL.js
CHANGED
|
@@ -34,10 +34,10 @@ function glInit()
|
|
|
34
34
|
|
|
35
35
|
// create the canvas and textures
|
|
36
36
|
glCanvas = document.createElement('canvas');
|
|
37
|
-
glContext = glCanvas.getContext('webgl2');
|
|
37
|
+
glContext = glCanvas.getContext('webgl2', {antialias:!canvasPixelated});
|
|
38
38
|
|
|
39
39
|
// some browsers are much faster without copying the gl buffer so we just overlay it instead
|
|
40
|
-
glOverlay &&
|
|
40
|
+
glOverlay && engineRoot.appendChild(glCanvas);
|
|
41
41
|
|
|
42
42
|
// setup vertex and fragment shaders
|
|
43
43
|
glShader = glCreateProgram(
|
|
@@ -92,7 +92,8 @@ function glPreRender()
|
|
|
92
92
|
// set up the shader
|
|
93
93
|
glContext.useProgram(glShader);
|
|
94
94
|
glContext.activeTexture(gl_TEXTURE0);
|
|
95
|
-
|
|
95
|
+
if (textureInfos[0])
|
|
96
|
+
glContext.bindTexture(gl_TEXTURE_2D, glActiveTexture = textureInfos[0].glTexture);
|
|
96
97
|
|
|
97
98
|
// set vertex attributes
|
|
98
99
|
let offset = glAdditive = glBatchAdditive = 0;
|
|
@@ -190,8 +191,14 @@ function glCreateTexture(image)
|
|
|
190
191
|
// build the texture
|
|
191
192
|
const texture = glContext.createTexture();
|
|
192
193
|
glContext.bindTexture(gl_TEXTURE_2D, texture);
|
|
193
|
-
if (image)
|
|
194
|
+
if (image && image.width)
|
|
194
195
|
glContext.texImage2D(gl_TEXTURE_2D, 0, gl_RGBA, gl_RGBA, gl_UNSIGNED_BYTE, image);
|
|
196
|
+
else
|
|
197
|
+
{
|
|
198
|
+
// create a white texture
|
|
199
|
+
const whitePixel = new Uint8Array([255, 255, 255, 255]);
|
|
200
|
+
glContext.texImage2D(gl_TEXTURE_2D, 0, gl_RGBA, 1, 1, 0, gl_RGBA, gl_UNSIGNED_BYTE, whitePixel);
|
|
201
|
+
}
|
|
195
202
|
|
|
196
203
|
// use point filtering for pixelated rendering
|
|
197
204
|
const filter = canvasPixelated ? gl_NEAREST : gl_LINEAR;
|