littlejsengine 1.8.4 → 1.8.6
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/build/littlejs.d.ts +2021 -0
- package/build/littlejs.esm.js +41 -29
- package/build/littlejs.esm.min.js +1 -0
- package/build/littlejs.js +40 -29
- package/build/littlejs.min.js +1 -1
- package/build/littlejs.release.js +41 -30
- package/examples/breakout/index.html +0 -1
- package/examples/breakoutTutorial/index.html +0 -1
- package/examples/electron/index.html +0 -1
- package/examples/module/index.html +0 -1
- package/examples/particles/index.html +0 -1
- package/examples/particles/tiles.png +0 -0
- package/examples/platformer/gamePlayer.js +1 -1
- package/examples/puzzle/index.html +0 -1
- package/examples/starter/build.js +1 -0
- package/examples/starter/index.html +0 -1
- package/examples/stress/index.html +0 -1
- package/examples/typescript/game.js +1 -1
- package/examples/typescript/index.html +0 -1
- package/package.json +1 -1
- package/src/engine.js +1 -1
- package/src/engineAudio.js +1 -1
- package/src/engineExport.js +1 -0
- package/src/engineInput.js +24 -14
- package/src/engineObject.js +1 -1
- package/src/engineParticles.js +1 -1
- package/src/engineRelease.js +1 -1
- package/src/engineTileLayer.js +8 -8
- package/src/engineUtilities.js +1 -1
- package/src/engineWebGL.js +3 -2
package/src/engineTileLayer.js
CHANGED
|
@@ -307,10 +307,10 @@ constructor(pos, size=tileCollisionSize, tileInfo=tile(), scale=vec2(1), renderO
|
|
|
307
307
|
/** Draw directly to the 2D canvas in world space (bipass webgl)
|
|
308
308
|
* @param {Vector2} pos
|
|
309
309
|
* @param {Vector2} size
|
|
310
|
-
* @param {Number}
|
|
311
|
-
* @param {Boolean}
|
|
310
|
+
* @param {Number} angle
|
|
311
|
+
* @param {Boolean} mirror
|
|
312
312
|
* @param {Function} drawFunction */
|
|
313
|
-
drawCanvas2D(pos, size, angle
|
|
313
|
+
drawCanvas2D(pos, size, angle, mirror, drawFunction)
|
|
314
314
|
{
|
|
315
315
|
const context = this.context;
|
|
316
316
|
context.save();
|
|
@@ -324,12 +324,12 @@ constructor(pos, size=tileCollisionSize, tileInfo=tile(), scale=vec2(1), renderO
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
/** Draw a tile directly onto the layer canvas
|
|
327
|
-
* @param {Vector2}
|
|
328
|
-
* @param {Vector2}
|
|
327
|
+
* @param {Vector2} pos
|
|
328
|
+
* @param {Vector2} [size=Vector2(1,1)]
|
|
329
329
|
* @param {TileInfo} [tileInfo]
|
|
330
|
-
* @param {Color}
|
|
331
|
-
* @param {Number}
|
|
332
|
-
* @param {Boolean}
|
|
330
|
+
* @param {Color} [color=Color()]
|
|
331
|
+
* @param {Number} [angle=0]
|
|
332
|
+
* @param {Boolean} [mirror=0] */
|
|
333
333
|
drawTile(pos, size=vec2(1), tileInfo, color=new Color, angle, mirror)
|
|
334
334
|
{
|
|
335
335
|
this.drawCanvas2D(pos, size, angle, mirror, (context)=>
|
package/src/engineUtilities.js
CHANGED
|
@@ -407,7 +407,7 @@ class Vector2
|
|
|
407
407
|
arrayCheck(arraySize) { return this.x >= 0 && this.y >= 0 && this.x < arraySize.x && this.y < arraySize.y; }
|
|
408
408
|
|
|
409
409
|
/** Returns this vector expressed as a string
|
|
410
|
-
* @param {
|
|
410
|
+
* @param {Number} digits - precision to display
|
|
411
411
|
* @return {String} */
|
|
412
412
|
toString(digits=3)
|
|
413
413
|
{ if (debug) { return `(${(this.x<0?'':' ') + this.x.toFixed(digits)},${(this.y<0?'':' ') + this.y.toFixed(digits)} )`; }}
|
package/src/engineWebGL.js
CHANGED
|
@@ -161,7 +161,7 @@ function glCreateProgram(vsSource, fsSource)
|
|
|
161
161
|
return program;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
/** Create WebGL texture from an image and
|
|
164
|
+
/** Create WebGL texture from an image and init the texture settings
|
|
165
165
|
* @param {Image} image
|
|
166
166
|
* @return {WebGLTexture}
|
|
167
167
|
* @memberof WebGL */
|
|
@@ -170,7 +170,8 @@ function glCreateTexture(image)
|
|
|
170
170
|
// build the texture
|
|
171
171
|
const texture = glContext.createTexture();
|
|
172
172
|
glContext.bindTexture(gl_TEXTURE_2D, texture);
|
|
173
|
-
|
|
173
|
+
if (image)
|
|
174
|
+
glContext.texImage2D(gl_TEXTURE_2D, 0, gl_RGBA, gl_RGBA, gl_UNSIGNED_BYTE, image);
|
|
174
175
|
|
|
175
176
|
// use point filtering for pixelated rendering
|
|
176
177
|
const filter = canvasPixelated ? gl_NEAREST : gl_LINEAR;
|