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/LittleJS.zip
ADDED
|
Binary file
|
package/README.md
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
## 🚂 All aboard!
|
|
16
16
|
|
|
17
|
-
LittleJS is a fast lightweight open source HTML5 game engine for
|
|
18
|
-
Its small footprint is packed with a comprehensive feature set including hybrid rendering, physics, particles, sound
|
|
19
|
-
The code is
|
|
17
|
+
LittleJS is a fast, lightweight, and fully open source HTML5 game engine designed for simplicity and performance.
|
|
18
|
+
Its small footprint is packed with a comprehensive feature set including hybrid rendering, physics, particles, sound, and input handling.
|
|
19
|
+
The code is clean and well documented with some fun examples to get you started right away. Choo-Choo!
|
|
20
20
|
|
|
21
21
|
### 🚀 Join the First Ever LittleJS Game Jam
|
|
22
22
|
|
|
@@ -30,7 +30,7 @@ The code is very clean and well documented with some fun examples to get you sta
|
|
|
30
30
|
|
|
31
31
|

|
|
32
32
|
|
|
33
|
-
## About LittleJS
|
|
33
|
+
## About LittleJS Engine
|
|
34
34
|
|
|
35
35
|
LittleJS is a small but powerful game engine with many features and no dependencies.
|
|
36
36
|
|
|
@@ -43,7 +43,7 @@ LittleJS is a small but powerful game engine with many features and no dependenc
|
|
|
43
43
|
|
|
44
44
|
### 🔊 Audio
|
|
45
45
|
|
|
46
|
-
- Positional sound effects with wave files or ZzFX
|
|
46
|
+
- Positional sound effects with wave files, mp3s, or ZzFX
|
|
47
47
|
- Use [ZzFX](https://killedbyapixel.github.io/ZzFX/) sound effect generator to play sounds without asset files
|
|
48
48
|
- Music with mp3, ogg, wave, or [ZzFXM](https://keithclark.github.io/ZzFXM/)
|
|
49
49
|
|
|
@@ -116,76 +116,6 @@ To rebuild the engine you must first run ```npm install``` to setup the necessar
|
|
|
116
116
|
|
|
117
117
|
The starter example project includes a node js file [build.js](https://github.com/KilledByAPixel/LittleJS/blob/main/examples/starter/build.js) that compresses everything into a tiny zip file using Google Closure, UglifyJS, and ECT Zip.
|
|
118
118
|
|
|
119
|
-
## LittleJS Setup
|
|
120
|
-
|
|
121
|
-
To start LittleJS, you need to create these 5 functions and pass them to engineInit.
|
|
122
|
-
|
|
123
|
-
```javascript
|
|
124
|
-
function gameInit()
|
|
125
|
-
{
|
|
126
|
-
// called once after the engine starts up
|
|
127
|
-
// setup the game
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function gameUpdate()
|
|
131
|
-
{
|
|
132
|
-
// called every frame at 60 frames per second
|
|
133
|
-
// handle input and update the game state
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function gameUpdatePost()
|
|
137
|
-
{
|
|
138
|
-
// called after physics and objects are updated
|
|
139
|
-
// setup camera and prepare for render
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function gameRender()
|
|
143
|
-
{
|
|
144
|
-
// called before objects are rendered
|
|
145
|
-
// draw any background effects that appear behind objects
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function gameRenderPost()
|
|
149
|
-
{
|
|
150
|
-
// called after objects are rendered
|
|
151
|
-
// draw effects or hud that appear above all objects
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Startup LittleJS Engine
|
|
155
|
-
engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost);
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
## LittleJS Objects
|
|
159
|
-
|
|
160
|
-
LittleJS can be used as an object oriented system by extending the base class [EngineObject](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineObject.js) with your own. This lightweight class provides many useful features including physics, collision, parent/child system, and sorted rendering. These objects are added to the global list of objects where they will automatically be updated and rendered until destroyed.
|
|
161
|
-
|
|
162
|
-
Here is a template you can use to make objects that behave however you want. See the examples for a complete demonstration.
|
|
163
|
-
|
|
164
|
-
```javascript
|
|
165
|
-
class MyObject extends EngineObject
|
|
166
|
-
{
|
|
167
|
-
constructor(pos, size, tileInfo, angle)
|
|
168
|
-
{
|
|
169
|
-
super(pos, size, tileInfo, angle);
|
|
170
|
-
// setup object
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
update()
|
|
174
|
-
{
|
|
175
|
-
// update object physics and position
|
|
176
|
-
super.update();
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
render()
|
|
180
|
-
{
|
|
181
|
-
// draw object as a sprite
|
|
182
|
-
super.render();
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
## Debugging
|
|
188
|
-
|
|
189
119
|
Debug builds of LittleJS have a special menu that can be opened by pressing the Esc key.
|
|
190
120
|
|
|
191
121
|
## Games Made With LittleJS
|
|
@@ -194,8 +124,10 @@ Here are a few of the amazing games people made using LittleJS...
|
|
|
194
124
|
|
|
195
125
|
- [Space Huggers](https://github.com/KilledByAPixel/SpaceHuggers) - Original js13k game with source code by [KilledByAPixel](https://frankforce.com/)
|
|
196
126
|
- [Undergrowth](https://undergrowth.squidband.uk/) - An interactive music videogame for the band Squid by [KilledByAPixel](https://frankforce.com/)
|
|
197
|
-
- [
|
|
127
|
+
- [The Way of the Dodo](https://js13kgames.com/2024/games/the-way-of-the-dodo) - Single button platformer by [repsej](https://github.com/repsej)
|
|
128
|
+
- [Wendol Village](https://js13kgames.com/2024/games/wendol-village) - Warcraft-like RTS game by [sanojian](https://github.com/sanojian)
|
|
198
129
|
- [Dead Again](https://js13kgames.com/entries/dead-again) - Top down survial horror by [sanojian & repsej](https://github.com/sanojian/js13k_2022)
|
|
130
|
+
- [Isletopia](https://store.steampowered.com/app/1861260/Isletopia) - Relaxing strategy game of greenifying barren islands by [Gamex Studio](https://x.com/gamesgamex)
|
|
199
131
|
- [Hel's Trial](https://js13kgames.com/entries/hels-trial) - Turn based RPG by [Sebastian Dorn](https://github.com/sebadorn/js13k-2022-death)
|
|
200
132
|
- [Bit Butcher](https://js13kgames.com/entries/bit-butcher) - Survival crafting game by [Deathray Games](https://github.com/deathraygames/bit-butcher)
|
|
201
133
|
- [Necrotic Commander](https://js13kgames.com/entries/necrotic-commander) - Tower defense game by [Daniel Jeffery](https://github.com/d-jeffery/NecroticCommander)
|
|
@@ -204,8 +136,6 @@ Here are a few of the amazing games people made using LittleJS...
|
|
|
204
136
|
- [brrr!](https://snowfrog.itch.io/brrr) - Base defense and shooting game by [Snowfrog](https://www.snowfrog.dev/)
|
|
205
137
|
- [Wands of Triskaidekai](https://js13kgames.com/2024/games/wands-of-triskaidekai) - Platformer with experimental gameplay by [gregwoodsfrontier](https://github.com/gregwoodsfrontier)
|
|
206
138
|
- [Data Warrior: 13kb limit](https://js13kgames.com/2024/games/data-warrior-13kb-limit) - Vampire Survivors-like game by [rndD](https://github.com/rndD)
|
|
207
|
-
- [The Way of the Dodo](https://js13kgames.com/2024/games/the-way-of-the-dodo) - Single button platformer by [repsej](https://github.com/repsej)
|
|
208
|
-
- [Wendol Village](https://js13kgames.com/2024/games/wendol-village) - Warcraft-like RTS game by [sanojian](https://github.com/sanojian)
|
|
209
139
|
- [Unblock](https://js13kgames.com/games/unblock) - Retro style space shooter by [Isaac Benitez](https://github.com/isacben)
|
|
210
140
|
|
|
211
141
|

|
package/dist/littlejs.d.ts
CHANGED
|
@@ -64,15 +64,15 @@ declare module "littlejsengine" {
|
|
|
64
64
|
* @memberof Engine */
|
|
65
65
|
export function setPaused(isPaused: boolean): void;
|
|
66
66
|
/** Startup LittleJS engine with your callback functions
|
|
67
|
-
* @param {Function} gameInit
|
|
68
|
-
* @param {Function} gameUpdate
|
|
69
|
-
* @param {Function} gameUpdatePost - Called after physics and objects are updated,
|
|
70
|
-
* @param {Function} gameRender
|
|
71
|
-
* @param {Function} gameRenderPost - Called after objects are rendered,
|
|
72
|
-
* @param {Array} [imageSources=[]] -
|
|
67
|
+
* @param {Function|function():Promise} gameInit - Called once after the engine starts up
|
|
68
|
+
* @param {Function} gameUpdate - Called every frame before objects are updated
|
|
69
|
+
* @param {Function} gameUpdatePost - Called after physics and objects are updated, even when paused
|
|
70
|
+
* @param {Function} gameRender - Called before objects are rendered, for drawing the background
|
|
71
|
+
* @param {Function} gameRenderPost - Called after objects are rendered, useful for drawing UI
|
|
72
|
+
* @param {Array} [imageSources=[]] - List of images to load
|
|
73
73
|
* @param {HTMLElement} [rootElement] - Root element to attach to, the document body by default
|
|
74
74
|
* @memberof Engine */
|
|
75
|
-
export function engineInit(gameInit: Function, gameUpdate: Function, gameUpdatePost: Function, gameRender: Function, gameRenderPost: Function, imageSources?: any[], rootElement?: HTMLElement): void;
|
|
75
|
+
export function engineInit(gameInit: Function | (() => Promise<any>), gameUpdate: Function, gameUpdatePost: Function, gameRender: Function, gameRenderPost: Function, imageSources?: any[], rootElement?: HTMLElement): void;
|
|
76
76
|
/** Update each engine object, remove destroyed objects, and update time
|
|
77
77
|
* @memberof Engine */
|
|
78
78
|
export function engineObjectsUpdate(): void;
|
|
@@ -232,11 +232,16 @@ declare module "littlejsengine" {
|
|
|
232
232
|
* @default Vector2()
|
|
233
233
|
* @memberof Settings */
|
|
234
234
|
export let canvasFixedSize: Vector2;
|
|
235
|
-
/**
|
|
235
|
+
/** Use nearest neighbor scaling algorithm for canvas for more pixelated look
|
|
236
236
|
* @type {Boolean}
|
|
237
237
|
* @default
|
|
238
238
|
* @memberof Settings */
|
|
239
239
|
export let canvasPixelated: boolean;
|
|
240
|
+
/** Disables texture filtering for crisper pixel art
|
|
241
|
+
* @type {Boolean}
|
|
242
|
+
* @default
|
|
243
|
+
* @memberof Settings */
|
|
244
|
+
export let tilesPixelated: boolean;
|
|
240
245
|
/** Default font used for text rendering
|
|
241
246
|
* @type {String}
|
|
242
247
|
* @default
|
|
@@ -415,10 +420,14 @@ declare module "littlejsengine" {
|
|
|
415
420
|
* @param {Vector2} size
|
|
416
421
|
* @memberof Settings */
|
|
417
422
|
export function setCanvasFixedSize(size: Vector2): void;
|
|
418
|
-
/**
|
|
423
|
+
/** Use nearest neighbor scaling algorithm for canvas for more pixelated look
|
|
419
424
|
* @param {Boolean} pixelated
|
|
420
425
|
* @memberof Settings */
|
|
421
426
|
export function setCanvasPixelated(pixelated: boolean): void;
|
|
427
|
+
/** Disables texture filtering for crisper pixel art
|
|
428
|
+
* @param {Boolean} pixelated
|
|
429
|
+
* @memberof Settings */
|
|
430
|
+
export function setTilesPixelated(pixelated: boolean): void;
|
|
422
431
|
/** Set default font used for text rendering
|
|
423
432
|
* @param {String} font
|
|
424
433
|
* @memberof Settings */
|
|
@@ -700,7 +709,8 @@ declare module "littlejsengine" {
|
|
|
700
709
|
* @return {Number}
|
|
701
710
|
* @memberof Random */
|
|
702
711
|
export function rand(valueA?: number, valueB?: number): number;
|
|
703
|
-
/** Returns a floored random value the two values passed in
|
|
712
|
+
/** Returns a floored random value between the two values passed in
|
|
713
|
+
* The upper bound is exclusive. (If 2 is passed in, result will be 0 or 1)
|
|
704
714
|
* @param {Number} valueA
|
|
705
715
|
* @param {Number} [valueB]
|
|
706
716
|
* @return {Number}
|
|
@@ -875,6 +885,9 @@ declare module "littlejsengine" {
|
|
|
875
885
|
* @param {Number} digits - precision to display
|
|
876
886
|
* @return {String} */
|
|
877
887
|
toString(digits?: number): string;
|
|
888
|
+
/** Checks if this is a valid vector
|
|
889
|
+
* @return {Boolean} */
|
|
890
|
+
isValid(): boolean;
|
|
878
891
|
}
|
|
879
892
|
/**
|
|
880
893
|
* Color object (red, green, blue, alpha) with some helpful functions
|
|
@@ -965,6 +978,9 @@ declare module "littlejsengine" {
|
|
|
965
978
|
/** Returns this color expressed as 32 bit RGBA value
|
|
966
979
|
* @return {Number} */
|
|
967
980
|
rgbaInt(): number;
|
|
981
|
+
/** Checks if this is a valid color
|
|
982
|
+
* @return {Boolean} */
|
|
983
|
+
isValid(): boolean;
|
|
968
984
|
}
|
|
969
985
|
/**
|
|
970
986
|
* Timer object tracks how long has passed since it was set
|
|
@@ -1109,7 +1125,7 @@ declare module "littlejsengine" {
|
|
|
1109
1125
|
* tile(2) // a tile at index 2 using the default tile size of 16
|
|
1110
1126
|
* tile(5, 8) // a tile at index 5 using a tile size of 8
|
|
1111
1127
|
* tile(1, 16, 3) // a tile at index 1 of size 16 on texture 3
|
|
1112
|
-
* tile(vec2(4,8), vec2(30,10)) // a tile at
|
|
1128
|
+
* tile(vec2(4,8), vec2(30,10)) // a tile at index (4,8) with a size of (30,10)
|
|
1113
1129
|
* @memberof Draw
|
|
1114
1130
|
*/
|
|
1115
1131
|
export function tile(pos?: (number | Vector2), size?: (number | Vector2), textureIndex?: number, padding?: number): TileInfo;
|
|
@@ -1292,7 +1308,7 @@ declare module "littlejsengine" {
|
|
|
1292
1308
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=mainContext]
|
|
1293
1309
|
* @memberof Draw */
|
|
1294
1310
|
export function setBlendMode(additive?: boolean, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1295
|
-
/** Draw text on
|
|
1311
|
+
/** Draw text on main canvas in world space
|
|
1296
1312
|
* Automatically splits new lines into rows
|
|
1297
1313
|
* @param {String} text
|
|
1298
1314
|
* @param {Vector2} pos
|
|
@@ -1300,12 +1316,12 @@ declare module "littlejsengine" {
|
|
|
1300
1316
|
* @param {Color} [color=(1,1,1,1)]
|
|
1301
1317
|
* @param {Number} [lineWidth]
|
|
1302
1318
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1303
|
-
* @param {CanvasTextAlign} [textAlign]
|
|
1319
|
+
* @param {CanvasTextAlign} [textAlign='center']
|
|
1304
1320
|
* @param {String} [font=fontDefault]
|
|
1305
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
|
|
1306
1321
|
* @param {Number} [maxWidth]
|
|
1322
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=mainContext]
|
|
1307
1323
|
* @memberof Draw */
|
|
1308
|
-
export function
|
|
1324
|
+
export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, maxWidth?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1309
1325
|
/** Draw text on overlay canvas in world space
|
|
1310
1326
|
* Automatically splits new lines into rows
|
|
1311
1327
|
* @param {String} text
|
|
@@ -1316,10 +1332,23 @@ declare module "littlejsengine" {
|
|
|
1316
1332
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1317
1333
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
1318
1334
|
* @param {String} [font=fontDefault]
|
|
1319
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
|
|
1320
1335
|
* @param {Number} [maxWidth]
|
|
1321
1336
|
* @memberof Draw */
|
|
1322
|
-
export function
|
|
1337
|
+
export function drawTextOverlay(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, maxWidth?: number): void;
|
|
1338
|
+
/** Draw text on overlay canvas in screen space
|
|
1339
|
+
* Automatically splits new lines into rows
|
|
1340
|
+
* @param {String} text
|
|
1341
|
+
* @param {Vector2} pos
|
|
1342
|
+
* @param {Number} [size]
|
|
1343
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1344
|
+
* @param {Number} [lineWidth]
|
|
1345
|
+
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1346
|
+
* @param {CanvasTextAlign} [textAlign]
|
|
1347
|
+
* @param {String} [font=fontDefault]
|
|
1348
|
+
* @param {Number} [maxWidth]
|
|
1349
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
|
|
1350
|
+
* @memberof Draw */
|
|
1351
|
+
export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, maxWidth?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1323
1352
|
export let engineFontImage: any;
|
|
1324
1353
|
/**
|
|
1325
1354
|
* Font Image Object - Draw text on a 2D canvas by using characters in an image
|
|
@@ -1601,7 +1630,7 @@ declare module "littlejsengine" {
|
|
|
1601
1630
|
play(pos?: Vector2, volume?: number, pitch?: number, randomnessScale?: number, loop?: boolean): AudioBufferSourceNode;
|
|
1602
1631
|
gainNode: GainNode;
|
|
1603
1632
|
source: AudioBufferSourceNode;
|
|
1604
|
-
/** Set the sound volume
|
|
1633
|
+
/** Set the sound volume of the most recently played instance of this sound
|
|
1605
1634
|
* @param {Number} [volume] - How much to scale volume by
|
|
1606
1635
|
*/
|
|
1607
1636
|
setVolume(volume?: number): void;
|
|
@@ -1914,24 +1943,24 @@ declare module "littlejsengine" {
|
|
|
1914
1943
|
* - Drawn directly to the main canvas without using WebGL
|
|
1915
1944
|
* @namespace TileCollision
|
|
1916
1945
|
*/
|
|
1917
|
-
/** The tile collision layer
|
|
1946
|
+
/** The tile collision layer grid, use setTileCollisionData and getTileCollisionData to access
|
|
1918
1947
|
* @type {Array}
|
|
1919
1948
|
* @memberof TileCollision */
|
|
1920
1949
|
export let tileCollision: any[];
|
|
1921
|
-
/** Size of the tile collision layer
|
|
1950
|
+
/** Size of the tile collision layer 2d grid
|
|
1922
1951
|
* @type {Vector2}
|
|
1923
1952
|
* @memberof TileCollision */
|
|
1924
1953
|
export let tileCollisionSize: Vector2;
|
|
1925
1954
|
/** Clear and initialize tile collision
|
|
1926
|
-
* @param {Vector2} size
|
|
1955
|
+
* @param {Vector2} size - width and height of tile collision 2d grid
|
|
1927
1956
|
* @memberof TileCollision */
|
|
1928
1957
|
export function initTileCollision(size: Vector2): void;
|
|
1929
|
-
/** Set tile collision data
|
|
1958
|
+
/** Set tile collision data for a given cell in the grid
|
|
1930
1959
|
* @param {Vector2} pos
|
|
1931
1960
|
* @param {Number} [data]
|
|
1932
1961
|
* @memberof TileCollision */
|
|
1933
1962
|
export function setTileCollisionData(pos: Vector2, data?: number): void;
|
|
1934
|
-
/** Get tile collision data
|
|
1963
|
+
/** Get tile collision data for a given cell in the grid
|
|
1935
1964
|
* @param {Vector2} pos
|
|
1936
1965
|
* @return {Number}
|
|
1937
1966
|
* @memberof TileCollision */
|
|
@@ -1943,7 +1972,8 @@ declare module "littlejsengine" {
|
|
|
1943
1972
|
* @return {Boolean}
|
|
1944
1973
|
* @memberof TileCollision */
|
|
1945
1974
|
export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): boolean;
|
|
1946
|
-
/** Return the center of first tile hit
|
|
1975
|
+
/** Return the center of first tile hit, undefined if nothing was hit.
|
|
1976
|
+
* This does not return the exact intersection, but the center of the tile hit.
|
|
1947
1977
|
* @param {Vector2} posStart
|
|
1948
1978
|
* @param {Vector2} posEnd
|
|
1949
1979
|
* @param {EngineObject} [object]
|
|
@@ -2245,14 +2275,19 @@ declare module "littlejsengine" {
|
|
|
2245
2275
|
* @param {String} [src] - Image location for the medal
|
|
2246
2276
|
*/
|
|
2247
2277
|
constructor(id: number, name: string, description?: string, icon?: string, src?: string);
|
|
2278
|
+
/** @property {Number} - The unique identifier of the medal */
|
|
2248
2279
|
id: number;
|
|
2280
|
+
/** @property {String} - Name of the medal */
|
|
2249
2281
|
name: string;
|
|
2282
|
+
/** @property {String} - Description of the medal */
|
|
2250
2283
|
description: string;
|
|
2284
|
+
/** @property {String} - Icon for the medal */
|
|
2251
2285
|
icon: string;
|
|
2286
|
+
/** @property {Boolean} - Is the medal unlocked? */
|
|
2287
|
+
unlocked: boolean;
|
|
2252
2288
|
image: HTMLImageElement;
|
|
2253
2289
|
/** Unlocks a medal if not already unlocked */
|
|
2254
2290
|
unlock(): void;
|
|
2255
|
-
unlocked: number;
|
|
2256
2291
|
/** Render a medal
|
|
2257
2292
|
* @param {Number} [hidePercent] - How much to slide the medal off screen
|
|
2258
2293
|
*/
|