littlejsengine 1.6.6 → 1.7.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.
Files changed (59) hide show
  1. package/README.md +76 -53
  2. package/build/littlejs.d.ts +154 -136
  3. package/build/littlejs.esm.js +461 -305
  4. package/build/littlejs.esm.min.js +1 -1
  5. package/build/littlejs.js +452 -291
  6. package/build/littlejs.min.js +1 -1
  7. package/build/littlejs.release.js +2317 -2168
  8. package/examples/breakout/game.js +5 -1
  9. package/examples/breakout/index.html +5 -5
  10. package/examples/breakoutTutorial/README.md +6 -6
  11. package/examples/breakoutTutorial/game.js +3 -0
  12. package/examples/breakoutTutorial/index.html +3 -3
  13. package/examples/electron/build.js +105 -0
  14. package/examples/electron/game.js +4 -2
  15. package/examples/electron/index.html +13 -2
  16. package/examples/electron/package.json +5 -3
  17. package/examples/empty/game.js +3 -1
  18. package/examples/empty/index.html +1 -1
  19. package/examples/js13k/build.bat +2 -0
  20. package/examples/js13k/build.js +110 -0
  21. package/examples/js13k/game.js +109 -0
  22. package/examples/js13k/index.html +18 -0
  23. package/examples/js13k/tiles.png +0 -0
  24. package/examples/module/game.js +9 -3
  25. package/examples/module/index.html +2 -2
  26. package/examples/particles/index.html +7 -13
  27. package/examples/platformer/game.js +5 -2
  28. package/examples/platformer/gameEffects.js +12 -12
  29. package/examples/platformer/gamePlayer.js +2 -2
  30. package/examples/platformer/index.html +8 -8
  31. package/examples/puzzle/game.js +5 -3
  32. package/examples/puzzle/index.html +4 -4
  33. package/examples/starter/build.bat +2 -78
  34. package/examples/starter/build.js +109 -0
  35. package/examples/starter/game.js +4 -1
  36. package/examples/starter/index.html +15 -18
  37. package/examples/stress/index.html +5 -7
  38. package/examples/typescript/build.bat +2 -14
  39. package/examples/typescript/build.js +31 -0
  40. package/examples/typescript/game.js +94 -89
  41. package/examples/typescript/game.ts +9 -3
  42. package/examples/typescript/index.html +2 -2
  43. package/package.json +2 -2
  44. package/src/engine.js +3 -3
  45. package/src/engineAudio.js +44 -16
  46. package/src/engineBuild.bat +2 -132
  47. package/src/engineBuild.js +156 -0
  48. package/src/engineDebug.js +25 -15
  49. package/src/engineDraw.js +62 -53
  50. package/src/engineExport.js +7 -12
  51. package/src/engineInput.js +27 -35
  52. package/src/engineObject.js +15 -13
  53. package/src/engineParticles.js +6 -6
  54. package/src/engineRelease.js +1 -3
  55. package/src/engineSettings.js +1 -0
  56. package/src/engineTileLayer.js +31 -18
  57. package/src/engineUtilities.js +161 -93
  58. package/src/engineWebGL.js +63 -27
  59. package/examples/electron/build.bat +0 -52
package/README.md CHANGED
@@ -1,77 +1,86 @@
1
1
  # ![LittleJS Logo](examples/favicon.png) LittleJS - The Tiny JavaScript Game Engine That Can
2
2
 
3
- ## All aboard!
3
+ [![NPM Package][npm]][npm-url]
4
+ [![Build Size][build-size]][build-size-url]
5
+ [![NPM Downloads][npm-downloads]][npmtrends-url]
6
+ [![DeepScan][deepscan]][deepscan-url]
7
+ [![Discord][discord]][discord-url]
4
8
 
9
+ ## 🚂 All aboard!
10
+
11
+ LittleJS is a lightweight open source HTML5 game engine designed for modern web development.
12
+ It's small footprint is packed with a comprehensive feature set, including hybrid rendering, physics, particles, sound effects, music, input handling, and debug tools.
13
+ The code is very clean and well documented with a several examples to get you started. Choo-Choo! 🚂
5
14
 
6
- LittleJS is a super lightweight JavaScript game engine designed for modern web development. With its fast hybrid rendering system, it offers a comprehensive suite of game development tools from rendering to sound effects. The code is very clean and well documented with a variety of examples to get you started. Choo-Choo! 🚂
7
15
  <div align="center">
8
-
16
+
9
17
  ## [Demo](https://killedbyapixel.github.io/LittleJS/examples/starter/) | [Docs](https://killedbyapixel.github.io/LittleJS/docs) | [Trailer](https://youtu.be/chuBzGjv7Ms) | [Discord](https://discord.gg/zb7hcGkyZe) | [Tutorial](https://github.com/KilledByAPixel/LittleJS/tree/main/examples/breakoutTutorial)
18
+
10
19
  </div>
11
20
 
12
21
  ![LittleJS Screenshot](examples/screenshot.jpg)
13
22
 
14
- ## Demos
15
-
16
- ### [Starter Project](https://killedbyapixel.github.io/LittleJS/examples/starter/) - Clean example with only a few things to get you started
17
- ### [Puzzle Game](https://killedbyapixel.github.io/LittleJS/examples/puzzle/) - Match 3 puzzle game with HD rendering and high score tracking
18
- ### [Platformer](https://killedbyapixel.github.io/LittleJS/examples/platformer/) - Platformer/shooter with procedural generation and destruction
19
- ### [Breakout](https://killedbyapixel.github.io/LittleJS/examples/breakout/) - Breakout game with post processing effect
20
- ### [Stress Test](https://killedbyapixel.github.io/LittleJS/examples/stress/) - Max sprite/object test and music system demo
21
- ### [Particle System Designer](https://killedbyapixel.github.io/LittleJS/examples/particles/) - Particle system editor and visualizer
22
-
23
23
  ## About LittleJS
24
24
 
25
25
  LittleJS is a small but powerful game engine with many features and no depenencies.
26
26
 
27
- ### Graphics
27
+ ### ✨ Graphics
28
28
 
29
- - Fast sprite and tile map rendering engine with WebGL
29
+ - Super fast sprite and tile map rendering engine with WebGL
30
30
  - Update and render 10,000+ objects at 60fps, often many times more
31
+ - Particle effect system and [design tool](https://killedbyapixel.github.io/LittleJS/examples/particles/)
31
32
  - Apply [Shadertoy](https://www.shadertoy.com) compatible shaders for post processinge effects
32
33
 
33
- ### Audio
34
+ ### 🔊 Audio
34
35
 
35
36
  - Positional sound effects with [ZzFX](https://killedbyapixel.github.io/ZzFX/) sound effect generator
36
37
  - Music with [ZzFXM](https://keithclark.github.io/ZzFXM/), mp3, or wav audio
37
38
 
38
- ### Input
39
+ ### 🎮 Input
39
40
 
40
41
  - Input processing system for keyboard, mouse, gamepad, and touch
41
42
  - On screen touch gamepad for mobile devices
42
43
 
43
- ### Physics
44
+ ### 💥 Physics
44
45
 
45
- - Kinematic physics object update
46
46
  - 2D physics engine with collision handling for axis aligned boxes
47
- - Very fast collision handling for tile maps
47
+ - Very fast collision handling and raycasting for tile maps
48
48
 
49
- ### Flexability
49
+ ### 🚀 Flexability
50
50
 
51
51
  - Designed to work with all modern web bowsers and mobile devices
52
- - Compatible with TypeScript and includes [an example TS project](https://killedbyapixel.github.io/LittleJS/examples/typescript)
53
- - For size coding competitions like [js13kGames](https://js13kgames.com/), starter project builds to a 7KB zip file
54
- - Build to a Windows executable with [Electron](https://www.electronjs.org/) for distribution on platforms like Steam
55
- - Open Source with the [MIT license](https://github.com/KilledByAPixel/LittleJS/blob/main/LICENSE) so it can be used for anything you want
52
+ - Compatible with TypeScript and Modules with example projects for both
53
+ - For size coding competitions like [js13kGames](https://js13kgames.com/), [a special example project builds to a 7KB zip file](https://killedbyapixel.github.io/LittleJS/examples/js13k)
54
+ - Builds to a Windows executable with [Electron](https://www.electronjs.org/) for distribution on PC platforms like Steam
55
+ - Open Source with the [MIT license](https://github.com/KilledByAPixel/LittleJS/blob/main/LICENSE) so it can be used for anything you want forever
56
56
 
57
- ### Extra Systems
57
+ ### 🛠️ And more...
58
58
 
59
- - Debug rendering system
59
+ - Node.js build system
60
+ - 2D vector math library
61
+ - Debug primitive rendering system
60
62
  - Particle effects system and design tool
61
63
  - Bitmap font rendering and includes a built in engine font
62
64
  - Medal system tracks and displays achievements with Newgrounds integration
63
65
 
66
+ ## Demos
67
+
68
+ ### [Starter Project](https://killedbyapixel.github.io/LittleJS/examples/starter/) - Clean example with only a few things to get you started
69
+ ### [Puzzle Game](https://killedbyapixel.github.io/LittleJS/examples/puzzle/) - Match 3 puzzle game with HD rendering and high score tracking
70
+ ### [Platformer](https://killedbyapixel.github.io/LittleJS/examples/platformer/) - Platformer/shooter with procedural generation and destruction
71
+ ### [Breakout](https://killedbyapixel.github.io/LittleJS/examples/breakout/) - Breakout game with post processing effect
72
+ ### [Stress Test](https://killedbyapixel.github.io/LittleJS/examples/stress/) - Max sprite/object test and music system demo
73
+ ### [Particle System Designer](https://killedbyapixel.github.io/LittleJS/examples/particles/) - Particle system editor and visualizer
74
+
64
75
  ## How to use LittleJS
65
76
 
66
77
  To use LittleJS download the latest package from GitHub or call ```npm install littlejsengine```. This package contains the engine and several small examples.
67
78
 
68
- [You can use the empty example template as a starting point.](https://github.com/KilledByAPixel/LittleJS/blob/main/examples/empty/game.js) This file contians just the minimal setup to start the engine. You can also download and include [littlejs.js](https://github.com/KilledByAPixel/LittleJS/blob/main/build/littlejs.js) or [littlejs.min.js](https://github.com/KilledByAPixel/LittleJS/blob/main/build/littlejs.min.js).
79
+ [You can use the empty example template as a starting point.](https://github.com/KilledByAPixel/LittleJS/blob/main/examples/empty/game.js) This file contains just the minimal setup to start the engine. You can also download and include [littlejs.js](https://github.com/KilledByAPixel/LittleJS/blob/main/build/littlejs.js) or [littlejs.min.js](https://github.com/KilledByAPixel/LittleJS/blob/main/build/littlejs.min.js).
69
80
 
70
- If your game loads any files like images you will need to run a local web server. I recommend an editor that does this automatically like [Visual Studio Code](https://code.visualstudio.com/) with the [Live Server plugin](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer). You can also use [http-server](https://www.npmjs.com/package/http-server) via npm.
81
+ If your game loads any files like images you will need to run a local web server. Some editors can do this automatically like [Visual Studio Code](https://code.visualstudio.com/) with the [Live Server plugin](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer). You can also use [http-server](https://www.npmjs.com/package/http-server) via npm.
71
82
 
72
- ## Tutorial
73
-
74
- - [Breakout Tutorial](https://github.com/KilledByAPixel/LittleJS/blob/main/examples/breakoutTutorial) - Shows how to make a simple game from scatch with LittleJS.
83
+ [The Breakout Tutorial](https://github.com/KilledByAPixel/LittleJS/blob/main/examples/breakoutTutorial) is provided to demonstrate how to make a simple game from scratch. [The tutorial is also available on YouTube.](https://youtu.be/tSwDx-NWTXE?si=bkjMa8-7AN2Wg5MO)
75
84
 
76
85
  ## Builds
77
86
 
@@ -88,7 +97,30 @@ LittleJS can also be imported as a module. There are two module flavors that are
88
97
 
89
98
  To rebuild the engine you must first run ```npm install``` to setup the necessary npm dependencies. Then call ```npm run build``` to build the engine.
90
99
 
91
- The starter project example also includes a batch file [build.bat](https://github.com/KilledByAPixel/LittleJS/blob/main/examples/starter/build.bat) that compresses everything into a tiny zip file using Google Closure, UglifyJS, Roadroller, and ECT.
100
+ The starter example project also 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.
101
+
102
+ ## Engine Source Code
103
+
104
+ This engine is made with simplicity in mind using clean easy to read code.
105
+ There are only a few core files used by the entire engine.
106
+
107
+ - [engine.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engine.js) - Top level engine init, update, and render
108
+ - [engineSettings.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineSettings.js) - Global engine settings
109
+ - [engineObject.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineObject.js) - Base object class and physics
110
+ - [engineDraw.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineDraw.js) - Code for canvas drawing and text
111
+ - [engineAudio.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineAudio.js) - Spacial sound effects, and zzfx sound generator
112
+ - [engineInput.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineInput.js) - Input for keyboard, mouse, touch, and gamepad
113
+ - [engineUtilities.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineUtilities.js) - Vector2, Color, and Timer clases and math functions
114
+
115
+ Optional Components, these components are built to synergize with the rest of the engine but are not required.
116
+
117
+ - [engineTileLayer.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineTileLayer.js) - Tile layer rendering and collision
118
+ - [engineParticles.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineParticles.js) - Particle system with fast rendering and collision
119
+ - [engineWebGL.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineWebGL.js) - Super fast rendering with WebGL and post processing
120
+ - [engineMedals.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineMedals.js) - Achievement tracker with Newgrounds integration
121
+ - [engineDebug.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineDebug.js) - Debug rendering system and information overlay
122
+ - [engineExport.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineExport.js) - Included when exporting engine as a module
123
+ - [engineBuild.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineBuild.js) - Node script used to build the engine
92
124
 
93
125
  ## LittleJS Setup
94
126
 
@@ -157,26 +189,6 @@ class MyObject extends EngineObject
157
189
  }
158
190
  ```
159
191
 
160
- ## Engine Source Code
161
-
162
- This engine is made with simplicity in mind using clean easy to read code. There are only a few files used by the entire engine.
163
-
164
- - [engine.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engine.js) - Top level engine init, update, and render
165
- - [engineSettings.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineSettings.js) - Global engine settings
166
- - [engineObject.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineObject.js) - Base object class and physics
167
- - [engineDraw.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineDraw.js) - Code for canvas drawing and text
168
- - [engineAudio.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineAudio.js) - Spacial sound effects, and zzfx sound generator
169
- - [engineInput.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineInput.js) - Input for keyboard, mouse, touch, and gamepad
170
- - [engineUtilities.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineUtilities.js) - Vector2, Color, and Timer clases and math functions
171
-
172
- Optional Components, these components are built to synergize with the rest of the engine but are not necessary.
173
-
174
- - [engineTileLayer.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineTileLayer.js) - Tile layer rendering and collision
175
- - [engineParticles.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineParticles.js) - Particle system with fast rendering and collision
176
- - [engineWebGL.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineWebGL.js) - Super fast rendering with WebGL and post processing
177
- - [engineMedals.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineMedals.js) - Achievement tracker with Newgrounds integration
178
- - [engineDebug.js](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineDebug.js) - Debug rendering system and information overlay
179
-
180
192
  ## Debugging
181
193
 
182
194
  Debug builds of LittleJS have a special menu that can be opened by pressing the Esc key.
@@ -185,7 +197,7 @@ Debug builds of LittleJS have a special menu that can be opened by pressing the
185
197
  - 1: Debug Physics
186
198
  - 2: Debug Particles
187
199
  - 3: Debug Gamepads
188
- - 4: God Mode
200
+ - 4: Debug Raycasts
189
201
  - 5: Save Screenshot
190
202
 
191
203
  ## Games Made With LittleJS
@@ -205,3 +217,14 @@ Here are a few of the amazing games people are making with LittleJS.
205
217
  - Send me your games!
206
218
 
207
219
  ![LittleJS Logo](examples/favicon.png)
220
+
221
+ [npm]: https://img.shields.io/npm/v/littlejsengine
222
+ [npm-url]: https://www.npmjs.com/package/littlejsengine
223
+ [build-size]: https://badgen.net/bundlephobia/minzip/littlejsengine?1
224
+ [build-size-url]: https://bundlephobia.com/result?p=littlejsengine
225
+ [npm-downloads]: https://img.shields.io/npm/dw/littlejsengine
226
+ [npmtrends-url]: https://www.npmtrends.com/littlejsengine
227
+ [deepscan]: https://deepscan.io/api/teams/22950/projects/26229/branches/831487/badge/grade.svg
228
+ [deepscan-url]: https://deepscan.io/dashboard#view=project&tid=22950&pid=26229&bid=831487
229
+ [discord]: https://img.shields.io/discord/939926111469568050
230
+ [discord-url]: https://discord.gg/zb7hcGkyZe