littlejsengine 1.9.7 → 1.9.8

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/LICENSE CHANGED
@@ -19,3 +19,25 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
+
23
+ -------------------------------------------------------------------------------
24
+
25
+ This project uses the Box2D physics engine, which is licensed under the zlib license.
26
+ Copyright (c) 2006 Erin Catto (Box2D)
27
+ Copyright (c) 2011 The box2d.js contributors
28
+
29
+ This software is provided 'as-is', without any express or implied
30
+ warranty. In no event will the authors be held liable for any damages
31
+ arising from the use of this software.
32
+
33
+ Permission is granted to anyone to use this software for any purpose,
34
+ including commercial applications, and to alter it and redistribute it
35
+ freely, subject to the following restrictions:
36
+
37
+ 1. The origin of this software must not be misrepresented; you must not
38
+ claim that you wrote the original software. If you use this software
39
+ in a product, an acknowledgment in the product documentation would be
40
+ appreciated but is not required.
41
+ 2. Altered source versions must be plainly marked as such, and must not be
42
+ misrepresented as being the original software.
43
+ 3. This notice may not be removed or altered from any source distribution.
package/README.md CHANGED
@@ -86,14 +86,15 @@ Learn how to make a simple game from scratch with [The Breakout Tutorial.](https
86
86
 
87
87
  Join our vibrant community on [Discord](https://discord.gg/zb7hcGkyZe) to get help, share your projects, and collaborate with others!
88
88
 
89
- ## Demos
89
+ ## Examples
90
90
 
91
- These examples are for both learning and using as starter projects to create your own games.
91
+ These demos are for both learning and using as starter projects to create your own games.
92
92
 
93
93
  - [Starter Project](https://killedbyapixel.github.io/LittleJS/examples/starter/) - Clean example with only a few things to get you started
94
94
  - [Breakout](https://killedbyapixel.github.io/LittleJS/examples/breakout/) - Block breaking game with post-processing effects
95
95
  - [Puzzle Game](https://killedbyapixel.github.io/LittleJS/examples/puzzle/) - Match 3 puzzle game with HD rendering and high score tracking
96
96
  - [Platformer](https://killedbyapixel.github.io/LittleJS/examples/platformer/) - Platformer/shooter with level data from [Tiled Editor](https://github.com/mapeditor/tiled)
97
+ - [Box2D Demo](https://killedbyapixel.github.io/LittleJS/examples/box2d/) - Box2D plugin demonstration and testbed
97
98
  - [Stress Test](https://killedbyapixel.github.io/LittleJS/examples/stress/) - Max sprite/object test and music system demo
98
99
  - [Particle System Designer](https://killedbyapixel.github.io/LittleJS/examples/particles/) - Particle system editor and visualizer
99
100
 
@@ -194,16 +195,20 @@ Debug builds of LittleJS have a special menu that can be opened by pressing the
194
195
 
195
196
  Here are a few of the amazing games people made using LittleJS...
196
197
 
197
- - [Space Huggers](https://www.newgrounds.com/portal/view/819609) - Run and gun platformer with procedural levels
198
- - [Undergrowth](https://undergrowth.squidband.uk/) - An interactive music videogame for the band Squid
199
- - [Space Huggers - JS13K Edition](https://github.com/KilledByAPixel/SpaceHuggers) - Original js13k game with source code
200
- - [Isletopia](https://store.steampowered.com/app/1861260/Isletopia) - Relaxing strategy game of greenifying barren islands
198
+ - [Space Huggers](https://github.com/KilledByAPixel/SpaceHuggers) - Original js13k game with source code by [KilledByAPixel](https://frankforce.com/)
199
+ - [Undergrowth](https://undergrowth.squidband.uk/) - An interactive music videogame for the band Squid by [KilledByAPixel](https://frankforce.com/)
200
+ - [Isletopia](https://store.steampowered.com/app/1861260/Isletopia) - Relaxing strategy game of greenifying barren islands by [Gamex Studio](https://x.com/gamesgamex)
201
201
  - [Dead Again](https://js13kgames.com/entries/dead-again) - Top down survial horror by [sanojian & repsej](https://github.com/sanojian/js13k_2022)
202
202
  - [Hel's Trial](https://js13kgames.com/entries/hels-trial) - Turn based RPG by [Sebastian Dorn](https://github.com/sebadorn/js13k-2022-death)
203
203
  - [Bit Butcher](https://js13kgames.com/entries/bit-butcher) - Survival crafting game by [Deathray Games](https://github.com/deathraygames/bit-butcher)
204
204
  - [Necrotic Commander](https://js13kgames.com/entries/necrotic-commander) - Tower defense game by [Daniel Jeffery](https://github.com/d-jeffery/NecroticCommander)
205
- - [Boxing up Bamboo](https://patrickgh3.itch.io/boxing-up-bamboo) - A challenging puzzle game by [Patrick Traynor](https://cwpat.me/about)
206
- - [Samurai Sam](https://dev.js13kgames.com/2023/games/samurai-sam) - A Fruit Ninja inspired game by [John Edvard](https://reitgames.com)
205
+ - [Boxing up Bamboo](https://patrickgh3.itch.io/boxing-up-bamboo) - Challenging puzzle game by [Patrick Traynor](https://cwpat.me/about)
206
+ - [Samurai Sam](https://dev.js13kgames.com/2023/games/samurai-sam) - Fruit Ninja inspired rhythm game by [John Edvard](https://reitgames.com)
207
+ - [brrr!](https://snowfrog.itch.io/brrr) - Base defense and shooting game by [Snowfrog](https://www.snowfrog.dev/)
208
+ - [Wands of Triskaidekai](https://js13kgames.com/2024/games/wands-of-triskaidekai) - Platformer with experimental gameplay by [gregwoodsfrontier](https://github.com/gregwoodsfrontier)
209
+ - [Data Warrior: 13kb limit](https://js13kgames.com/2024/games/data-warrior-13kb-limit) - Vampire Survivors-like game by [rndD](https://github.com/rndD)
210
+ - [The Way of the Dodo](https://js13kgames.com/2024/games/the-way-of-the-dodo) - Single button platformer by [repsej](https://github.com/repsej)
211
+ - [Wendol Village](https://js13kgames.com/2024/games/wendol-village) - Warcraft-like RTS game by [sanojian](https://github.com/sanojian)
207
212
 
208
213
  ![LittleJS Logo](examples/favicon.png)
209
214
 
@@ -123,6 +123,15 @@ declare module "littlejsengine" {
123
123
  * @param {Boolean} [fill]
124
124
  * @memberof Debug */
125
125
  export function debugRect(pos: Vector2, size?: Vector2, color?: string, time?: number, angle?: number, fill?: boolean): void;
126
+ /** Draw a debug poly in world space
127
+ * @param {Vector2} pos
128
+ * @param {Array} points
129
+ * @param {String} [color]
130
+ * @param {Number} [time]
131
+ * @param {Number} [angle]
132
+ * @param {Boolean} [fill]
133
+ * @memberof Debug */
134
+ export function debugPoly(pos: Vector2, points: any[], color?: string, time?: number, angle?: number, fill?: boolean): void;
126
135
  /** Draw a debug circle in world space
127
136
  * @param {Vector2} pos
128
137
  * @param {Number} [radius]
@@ -146,14 +155,14 @@ declare module "littlejsengine" {
146
155
  * @param {Number} [time]
147
156
  * @memberof Debug */
148
157
  export function debugLine(posA: Vector2, posB: Vector2, color?: string, thickness?: number, time?: number): void;
149
- /** Draw a debug axis aligned bounding box in world space
158
+ /** Draw a debug combined axis aligned bounding box in world space
150
159
  * @param {Vector2} pA - position A
151
160
  * @param {Vector2} sA - size A
152
161
  * @param {Vector2} pB - position B
153
162
  * @param {Vector2} sB - size B
154
163
  * @param {String} [color]
155
164
  * @memberof Debug */
156
- export function debugAABB(pA: Vector2, sA: Vector2, pB: Vector2, sB: Vector2, color?: string): void;
165
+ export function debugOverlap(pA: Vector2, sA: Vector2, pB: Vector2, sB: Vector2, color?: string): void;
157
166
  /** Draw a debug axis aligned bounding box in world space
158
167
  * @param {String} text
159
168
  * @param {Vector2} pos
@@ -173,6 +182,17 @@ declare module "littlejsengine" {
173
182
  * @param {String} [type]
174
183
  * @memberof Debug */
175
184
  export function debugSaveCanvas(canvas: HTMLCanvasElement, filename?: string, type?: string): void;
185
+ /** Save a text file to disk
186
+ * @param {String} text
187
+ * @param {String} [filename]
188
+ * @param {String} [type]
189
+ * @memberof Debug */
190
+ export function debugSaveText(text: string, filename?: string, type?: string): void;
191
+ /** Save a data url to disk
192
+ * @param {String} dataURL
193
+ * @param {String} filename
194
+ * @memberof Debug */
195
+ export function debugSaveDataURL(dataURL: string, filename: string): void;
176
196
  /**
177
197
  * LittleJS Engine Settings
178
198
  * - All settings for the engine are here
@@ -190,7 +210,7 @@ declare module "littlejsengine" {
190
210
  export let cameraScale: number;
191
211
  /** The max size of the canvas, centered if window is larger
192
212
  * @type {Vector2}
193
- * @default Vector2(1920,1200)
213
+ * @default Vector2(1920,1080)
194
214
  * @memberof Settings */
195
215
  export let canvasMaxSize: Vector2;
196
216
  /** Fixed size of the canvas, if enabled canvas size never changes
@@ -731,6 +751,11 @@ declare module "littlejsengine" {
731
751
  x: number;
732
752
  /** @property {Number} - Y axis location */
733
753
  y: number;
754
+ /** Sets values of this vector and returns self
755
+ * @param {Number} [x] - X axis location
756
+ * @param {Number} [y] - Y axis location
757
+ * @return {Vector2} */
758
+ set(x?: number, y?: number): Vector2;
734
759
  /** Returns a new vector that is a copy of this
735
760
  * @return {Vector2} */
736
761
  copy(): Vector2;
@@ -850,6 +875,13 @@ declare module "littlejsengine" {
850
875
  b: number;
851
876
  /** @property {Number} - Alpha */
852
877
  a: number;
878
+ /** Sets values of this color and returns self
879
+ * @param {Number} [r] - red
880
+ * @param {Number} [g] - green
881
+ * @param {Number} [b] - blue
882
+ * @param {Number} [a] - alpha
883
+ * @return {Color} */
884
+ set(r?: number, g?: number, b?: number, a?: number): Color;
853
885
  /** Returns a new color that is a copy of this
854
886
  * @return {Color} */
855
887
  copy(): Color;
@@ -1269,11 +1301,6 @@ declare module "littlejsengine" {
1269
1301
  * @return {WebGLTexture}
1270
1302
  * @memberof WebGL */
1271
1303
  export function glCreateTexture(image: HTMLImageElement): WebGLTexture;
1272
- /** Set up a post processing shader
1273
- * @param {String} shaderCode
1274
- * @param {Boolean} includeOverlay
1275
- * @memberof WebGL */
1276
- export function glInitPostProcess(shaderCode: string, includeOverlay?: boolean): void;
1277
1304
  /**
1278
1305
  * LittleJS Input System
1279
1306
  * - Tracks keyboard down, pressed, and released
@@ -1420,7 +1447,12 @@ declare module "littlejsengine" {
1420
1447
  * @return {AudioBufferSourceNode} - The audio source node
1421
1448
  */
1422
1449
  play(pos?: Vector2, volume?: number, pitch?: number, randomnessScale?: number, loop?: boolean): AudioBufferSourceNode;
1450
+ gainNode: GainNode;
1423
1451
  source: AudioBufferSourceNode;
1452
+ /** Set the sound volume
1453
+ * @param {Number} [volume] - How much to scale volume by
1454
+ */
1455
+ setVolume(volume?: number): void;
1424
1456
  /** Stop the last instance of this sound that was played */
1425
1457
  stop(): void;
1426
1458
  /** Get source of most recent instance of this sound that was played
@@ -1546,15 +1578,16 @@ declare module "littlejsengine" {
1546
1578
  * @memberof Audio */
1547
1579
  export let audioContext: AudioContext;
1548
1580
  /** Play cached audio samples with given settings
1549
- * @param {Array} sampleChannels - Array of arrays of samples to play (for stereo playback)
1550
- * @param {Number} [volume] - How much to scale volume by
1551
- * @param {Number} [rate] - The playback rate to use
1552
- * @param {Number} [pan] - How much to apply stereo panning
1553
- * @param {Boolean} [loop] - True if the sound should loop when it reaches the end
1554
- * @param {Number} [sampleRate=44100] - Sample rate for the sound
1581
+ * @param {Array} sampleChannels - Array of arrays of samples to play (for stereo playback)
1582
+ * @param {Number} [volume] - How much to scale volume by
1583
+ * @param {Number} [rate] - The playback rate to use
1584
+ * @param {Number} [pan] - How much to apply stereo panning
1585
+ * @param {Boolean} [loop] - True if the sound should loop when it reaches the end
1586
+ * @param {Number} [sampleRate=44100] - Sample rate for the sound
1587
+ * @param {GainNode} [gainNode] - Optional gain node for volume control while playing
1555
1588
  * @return {AudioBufferSourceNode} - The audio node of the sound played
1556
1589
  * @memberof Audio */
1557
- export function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean, sampleRate?: number): AudioBufferSourceNode;
1590
+ export function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean, sampleRate?: number, gainNode?: GainNode): AudioBufferSourceNode;
1558
1591
  /** Generate and play a ZzFX sound
1559
1592
  *
1560
1593
  * <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
@@ -1664,6 +1697,18 @@ declare module "littlejsengine" {
1664
1697
  /** Destroy this object, destroy it's children, detach it's parent, and mark it for removal */
1665
1698
  destroy(): void;
1666
1699
  destroyed: number;
1700
+ /** Convert from local space to world space
1701
+ * @param {Vector2} pos - local space point */
1702
+ localToWorld(pos: Vector2): Vector2;
1703
+ /** Convert from world space to local space
1704
+ * @param {Vector2} pos - world space point */
1705
+ worldToLocal(pos: Vector2): Vector2;
1706
+ /** Convert from local space to world space for a vector (rotation only)
1707
+ * @param {Vector2} vec - local space vector */
1708
+ localToWorldVector(vec: Vector2): Vector2;
1709
+ /** Convert from world space to local space for a vector (rotation only)
1710
+ * @param {Vector2} vec - world space vector */
1711
+ worldToLocalVector(vec: Vector2): Vector2;
1667
1712
  /** Called to check if a tile collision should be resolved
1668
1713
  * @param {Number} tileData - the value of the tile at the position
1669
1714
  * @param {Vector2} pos - tile where the collision occured
@@ -1703,6 +1748,8 @@ declare module "littlejsengine" {
1703
1748
  /** Returns string containg info about this object for debugging
1704
1749
  * @return {String} */
1705
1750
  toString(): string;
1751
+ /** Render debug info for this object */
1752
+ renderDebugInfo(): void;
1706
1753
  }
1707
1754
  /**
1708
1755
  * LittleJS Tile Layer System
@@ -2011,9 +2058,9 @@ declare module "littlejsengine" {
2011
2058
  * @namespace Medals
2012
2059
  */
2013
2060
  /** List of all medals
2014
- * @type {Array}
2061
+ * @type {Object}
2015
2062
  * @memberof Medals */
2016
- export const medals: any[];
2063
+ export const medals: any;
2017
2064
  /** Set to stop medals from being unlockable (like if cheats are enabled)
2018
2065
  * @type {Boolean}
2019
2066
  * @default
@@ -2025,12 +2072,6 @@ declare module "littlejsengine" {
2025
2072
  * @param {String} saveName
2026
2073
  * @memberof Medals */
2027
2074
  export function medalsInit(saveName: string): void;
2028
- /** This can used to enable Newgrounds functionality
2029
- * @param {Number} app_id - The newgrounds App ID
2030
- * @param {String} [cipher] - The encryption Key (AES-128/Base64)
2031
- * @param {Object} [cryptoJS] - An instance of CryptoJS, if there is a cipher
2032
- * @memberof Medals */
2033
- export function newgroundsInit(app_id: number, cipher?: string, cryptoJS?: any): void;
2034
2075
  /**
2035
2076
  * Medal - Tracks an unlockable medal
2036
2077
  * @example
@@ -2071,50 +2112,4 @@ declare module "littlejsengine" {
2071
2112
  renderIcon(pos: Vector2, size?: number): void;
2072
2113
  storageKey(): string;
2073
2114
  }
2074
- /**
2075
- * Newgrounds API wrapper object
2076
- * @example
2077
- * // create a newgrounds object, replace the app id with your own
2078
- * const app_id = '53123:1ZuSTQ9l';
2079
- * newgrounds = new Newgrounds(app_id);
2080
- */
2081
- export class Newgrounds {
2082
- /** Create a newgrounds object
2083
- * @param {Number} app_id - The newgrounds App ID
2084
- * @param {String} [cipher] - The encryption Key (AES-128/Base64)
2085
- * @param {Object} [cryptoJS] - An instance of CryptoJS, if there is a cipher */
2086
- constructor(app_id: number, cipher?: string, cryptoJS?: any);
2087
- app_id: number;
2088
- cipher: string;
2089
- cryptoJS: any;
2090
- host: string;
2091
- session_id: string;
2092
- medals: any;
2093
- scoreboards: any;
2094
- /** Send message to unlock a medal by id
2095
- * @param {Number} id - The medal id */
2096
- unlockMedal(id: number): any;
2097
- /** Send message to post score
2098
- * @param {Number} id - The scoreboard id
2099
- * @param {Number} value - The score value */
2100
- postScore(id: number, value: number): any;
2101
- /** Get scores from a scoreboard
2102
- * @param {Number} id - The scoreboard id
2103
- * @param {String} [user] - A user's id or name
2104
- * @param {Number} [social] - If true, only social scores will be loaded
2105
- * @param {Number} [skip] - Number of scores to skip before start
2106
- * @param {Number} [limit] - Number of scores to include in the list
2107
- * @return {Object} - The response JSON object
2108
- */
2109
- getScores(id: number, user?: string, social?: number, skip?: number, limit?: number): any;
2110
- /** Send message to log a view */
2111
- logView(): any;
2112
- /** Send a message to call a component of the Newgrounds API
2113
- * @param {String} component - Name of the component
2114
- * @param {Object} [parameters] - Parameters to use for call
2115
- * @param {Boolean} [async] - If true, don't wait for response before continuing
2116
- * @return {Object} - The response JSON object
2117
- */
2118
- call(component: string, parameters?: any, async?: boolean): any;
2119
- }
2120
2115
  }