littlejsengine 1.4.0 → 1.4.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.
Files changed (40) hide show
  1. package/build.bat +1 -1
  2. package/buildSetup.bat +2 -2
  3. package/engine/engine.all.js +244 -161
  4. package/engine/engine.all.min.js +1 -1
  5. package/engine/engine.all.module.js +4812 -0
  6. package/engine/engine.all.release.js +228 -138
  7. package/engine/engine.all.release.module.js +4457 -0
  8. package/engine/engine.js +12 -8
  9. package/engine/engineBuild.bat +21 -2
  10. package/engine/engineDebug.js +16 -23
  11. package/engine/engineDraw.js +13 -13
  12. package/engine/engineExport.js +333 -0
  13. package/engine/engineInput.js +8 -7
  14. package/engine/engineMedals.js +10 -6
  15. package/engine/engineObject.js +4 -4
  16. package/engine/engineParticles.js +45 -21
  17. package/engine/engineTileLayer.js +1 -1
  18. package/engine/engineUtilities.js +21 -25
  19. package/engine/engineWebGL.js +114 -54
  20. package/engine/index.d.ts +41 -30
  21. package/examples/breakout/game.js +63 -11
  22. package/examples/breakout/gameObjects.js +14 -12
  23. package/examples/breakout/index.html +3 -3
  24. package/examples/empty/game.js +35 -0
  25. package/examples/empty/index.html +9 -0
  26. package/examples/empty/tiles.png +0 -0
  27. package/examples/module/game.js +122 -0
  28. package/examples/module/index.html +9 -0
  29. package/examples/module/tiles.png +0 -0
  30. package/examples/particles/index.html +14 -14
  31. package/examples/particles/tiles.png +0 -0
  32. package/examples/platformer/gameObjects.js +5 -5
  33. package/examples/platformer/gamePlayer.js +7 -5
  34. package/examples/platformer/index.html +6 -6
  35. package/examples/puzzle/index.html +2 -2
  36. package/examples/stress/index.html +2 -2
  37. package/game.js +9 -11
  38. package/index.html +13 -13
  39. package/package.json +35 -25
  40. package/README.md +0 -54
@@ -72,7 +72,7 @@ class Crate extends GameObject
72
72
  this.health = 5;
73
73
 
74
74
  // make it a solid object for collision
75
- this.setCollision(1, 1);
75
+ this.setCollision();
76
76
  }
77
77
 
78
78
  kill()
@@ -98,7 +98,7 @@ class Enemy extends GameObject
98
98
  this.color = (new Color).setHSLA(rand(), 1, .7);
99
99
  this.health = 5;
100
100
  this.bounceTime = new Timer(rand(1e3));
101
- this.setCollision(1);
101
+ this.setCollision(1,0);
102
102
  }
103
103
 
104
104
  update()
@@ -157,7 +157,7 @@ class Grenade extends GameObject
157
157
  this.friction = .9;
158
158
  this.angleDamping = .96;
159
159
  this.renderOrder = 1e8;
160
- this.setCollision(1);
160
+ this.setCollision(1,0);
161
161
  }
162
162
 
163
163
  update()
@@ -206,7 +206,7 @@ class Weapon extends EngineObject
206
206
  this.renderOrder = parent.renderOrder + 1;
207
207
  this.fireTimeBuffer = this.localAngle = 0;
208
208
  this.recoilTimer = new Timer;
209
- parent.addChild(parent.weapon = this, vec2(.6,0));
209
+ parent.addChild(this, vec2(.6,0));
210
210
 
211
211
  // shell effect
212
212
  this.addChild(this.shellEmitter = new ParticleEmitter(
@@ -271,7 +271,7 @@ class Bullet extends EngineObject
271
271
  this.renderOrder = 100;
272
272
  this.drawSize = vec2(.2,.5);
273
273
  this.range = 20;
274
- this.setCollision(1);
274
+ this.setCollision(1,0);
275
275
  }
276
276
 
277
277
  update()
@@ -15,7 +15,8 @@ class Character extends GameObject
15
15
  {
16
16
  super(pos, vec2(.6,.95), 32);
17
17
 
18
- new Weapon(this.lastPos = this.pos, this);
18
+ this.weapon = new Weapon(pos, this);
19
+ this.lastPos = pos;
19
20
  this.groundTimer = new Timer;
20
21
  this.jumpTimer = new Timer;
21
22
  this.pressedJumpTimer = new Timer;
@@ -29,7 +30,7 @@ class Character extends GameObject
29
30
  this.walkCyclePercent = 0;
30
31
  this.health = 1;
31
32
  this.moveInput = 0;
32
- this.setCollision(1);
33
+ this.setCollision(1,0);
33
34
  }
34
35
 
35
36
  update()
@@ -103,8 +104,8 @@ class Character extends GameObject
103
104
  else if (moveInput.y)
104
105
  this.climbingLadder = 1;
105
106
 
106
- // update weapon trigger
107
- this.weapon.triggerIsDown = this.holdingShoot && !this.dodgeTimer.active();
107
+ if (this.weapon) // update weapon trigger
108
+ this.weapon.triggerIsDown = this.holdingShoot && !this.dodgeTimer.active();
108
109
 
109
110
  // update ladder
110
111
  if (this.climbingLadder)
@@ -246,7 +247,8 @@ class Character extends GameObject
246
247
  sound_die.play(this.pos);
247
248
 
248
249
  this.health = 0;
249
- this.weapon.destroy();
250
+ if (this.weapon)
251
+ this.weapon.destroy();
250
252
  this.deadTimer.set();
251
253
  this.size = this.size.scale(.5);
252
254
  const fallDirection = damagingObject ? sign(damagingObject.velocity.x) : randSign();
@@ -5,9 +5,9 @@
5
5
  <link rel=icon type=image/png href=../../favicon.png>
6
6
  </head><body>
7
7
 
8
- <script src=../../engine/engine.all.js?112></script>
9
- <script src=gameObjects.js?112></script>
10
- <script src=gamePlayer.js?112></script>
11
- <script src=gameEffects.js?112></script>
12
- <script src=gameLevel.js?112></script>
13
- <script src=game.js?103></script>
8
+ <script src=../../engine/engine.all.js?118></script>
9
+ <script src=gameObjects.js?118></script>
10
+ <script src=gamePlayer.js?118></script>
11
+ <script src=gameEffects.js?118></script>
12
+ <script src=gameLevel.js?118></script>
13
+ <script src=game.js?118></script>
@@ -5,5 +5,5 @@
5
5
  <link rel=icon type=image/png href=../../favicon.png>
6
6
  </head><body>
7
7
 
8
- <script src=../../engine/engine.all.js?112></script>
9
- <script src=game.js?112></script>
8
+ <script src=../../engine/engine.all.js?118></script>
9
+ <script src=game.js?118></script>
@@ -5,7 +5,7 @@
5
5
  <link rel=icon type=image/png href=../../favicon.png>
6
6
  </head><body>
7
7
 
8
- <script src=../../engine/engine.all.min.js?112></script>
8
+ <script src=../../engine/engine.all.min.js?118></script>
9
9
  <script>
10
10
 
11
11
  /*
@@ -31,7 +31,7 @@ class TestObject extends EngineObject
31
31
  super(pos, vec2(1), 0, vec2(16), 0, spriteColor);
32
32
 
33
33
  this.additiveColor = spriteAdditiveColor;
34
- this.setCollision(1, 1);
34
+ this.setCollision();
35
35
  }
36
36
  }
37
37
 
package/game.js CHANGED
@@ -4,12 +4,6 @@
4
4
 
5
5
  'use strict';
6
6
 
7
- // popup errors if there are any (help diagnose issues on mobile devices)
8
- //onerror = (...parameters)=> alert(parameters);
9
-
10
- // game variables
11
- let particleEmiter;
12
-
13
7
  // sound effects
14
8
  const sound_click = new Sound([.5,.5]);
15
9
 
@@ -17,6 +11,9 @@ const sound_click = new Sound([.5,.5]);
17
11
  const medal_example = new Medal(0, 'Example Medal', 'Welcome to LittleJS!');
18
12
  medalsInit('Hello World');
19
13
 
14
+ // game variables
15
+ let particleEmiter;
16
+
20
17
  ///////////////////////////////////////////////////////////////////////////////
21
18
  function gameInit()
22
19
  {
@@ -56,13 +53,14 @@ function gameInit()
56
53
  // create particle emitter
57
54
  const center = tileCollisionSize.scale(.5).add(vec2(0,9));
58
55
  particleEmiter = new ParticleEmitter(
59
- center, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emiteCone
56
+ center, 0, // emitPos, emitAngle
57
+ 1, 0, 500, PI, // emitSize, emitTime, emitRate, emiteCone
60
58
  0, vec2(16), // tileIndex, tileSize
61
59
  new Color(1,1,1), new Color(0,0,0), // colorStartA, colorStartB
62
60
  new Color(1,1,1,0), new Color(0,0,0,0), // colorEndA, colorEndB
63
- 2, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
64
- .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate,
65
- .5, 1, 1 // randomness, collide, additive, randomColorLinear, renderOrder
61
+ 2, .2, .2, .1, .05, // time, sizeStart, sizeEnd, speed, angleSpeed
62
+ .99, 1, 1, PI, // damping, angleDamping, gravityScale, cone
63
+ .05, .5, 1, 1 // fadeRate, randomness, collide, additive
66
64
  );
67
65
  particleEmiter.elasticity = .3; // bounce when it collides
68
66
  particleEmiter.trailScale = 2; // stretch in direction of motion
@@ -108,7 +106,7 @@ function gameRender()
108
106
  function gameRenderPost()
109
107
  {
110
108
  // draw to overlay canvas for hud rendering
111
- drawTextScreen('Hello World', vec2(overlayCanvas.width/2, 80), 80, new Color, 9);
109
+ drawTextScreen('Hello World', vec2(mainCanvasSize.x/2, 80), 80);
112
110
  }
113
111
 
114
112
  ///////////////////////////////////////////////////////////////////////////////
package/index.html CHANGED
@@ -6,21 +6,21 @@
6
6
  </head><body>
7
7
 
8
8
  <!-- LittleJS engine scripts -->
9
- <script src=engine/engineDebug.js?112></script>
10
- <script src=engine/engineUtilities.js?112></script>
11
- <script src=engine/engineSettings.js?112></script>
12
- <script src=engine/engineObject.js?112></script>
13
- <script src=engine/engineDraw.js?112></script>
14
- <script src=engine/engineInput.js?112></script>
15
- <script src=engine/engineAudio.js?112></script>
16
- <script src=engine/engineTileLayer.js?112></script>
17
- <script src=engine/engineParticles.js?112></script>
18
- <script src=engine/engineMedals.js?112></script>
19
- <script src=engine/engineWebGL.js?112></script>
20
- <script src=engine/engine.js?112></script>
9
+ <script src=engine/engineDebug.js?118></script>
10
+ <script src=engine/engineUtilities.js?118></script>
11
+ <script src=engine/engineSettings.js?118></script>
12
+ <script src=engine/engineObject.js?118></script>
13
+ <script src=engine/engineDraw.js?118></script>
14
+ <script src=engine/engineInput.js?118></script>
15
+ <script src=engine/engineAudio.js?118></script>
16
+ <script src=engine/engineTileLayer.js?118></script>
17
+ <script src=engine/engineParticles.js?118></script>
18
+ <script src=engine/engineMedals.js?118></script>
19
+ <script src=engine/engineWebGL.js?118></script>
20
+ <script src=engine/engine.js?118></script>
21
21
 
22
22
  <!-- You can also include all engine scripts like this... -->
23
23
  <!-- <script src=engine/engine.all.js></script> -->
24
24
 
25
25
  <!-- Add your game scripts here -->
26
- <script src=game.js?112></script>
26
+ <script src=game.js?118></script>
package/package.json CHANGED
@@ -1,25 +1,35 @@
1
- {
2
- "name": "littlejsengine",
3
- "version": "1.4.0",
4
- "description": "LittleJS - Tiny and Fast HTML5 Game Engine",
5
- "main": "engine/engine.all.js",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/KilledByAPixel/LittleJS.git"
9
- },
10
- "keywords": [
11
- "HTML5",
12
- "JavaScript",
13
- "game",
14
- "engine",
15
- "library",
16
- "JS13K",
17
- "webgl"
18
- ],
19
- "author": "Frank Force",
20
- "license": "MIT",
21
- "bugs": {
22
- "url": "https://github.com/KilledByAPixel/LittleJS/issues"
23
- },
24
- "homepage": "https://github.com/KilledByAPixel/LittleJS"
25
- }
1
+ {
2
+ "name": "littlejsengine",
3
+ "version": "1.4.6",
4
+ "description": "LittleJS - Tiny and Fast HTML5 Game Engine",
5
+ "main": "engine/engine.all.module.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/KilledByAPixel/LittleJS.git"
9
+ },
10
+ "keywords": [
11
+ "HTML5",
12
+ "JavaScript",
13
+ "game",
14
+ "engine",
15
+ "library",
16
+ "JS13K",
17
+ "webgl"
18
+ ],
19
+ "author": "Frank Force",
20
+ "license": "MIT",
21
+ "bugs": {
22
+ "url": "https://github.com/KilledByAPixel/LittleJS/issues"
23
+ },
24
+ "homepage": "https://github.com/KilledByAPixel/LittleJS",
25
+ "scripts": {
26
+ "build": "build.bat"
27
+ },
28
+ "dependencies": {
29
+ "ect-bin": "^1.4.1",
30
+ "google-closure-compiler": "^20221102.0.1",
31
+ "roadroller": "^2.1.0",
32
+ "typescript": "^4.9.5",
33
+ "uglify-js": "^3.17.4"
34
+ }
35
+ }
package/README.md DELETED
@@ -1,54 +0,0 @@
1
- # ![LittleJS Logo](favicon.png) LittleJS - The Tiny JavaScript Game Engine That Can
2
-
3
- ## All aboard!
4
-
5
- LittleJS is a super lightweight JavaScript game engine with a fast hybrid rendering system. It provides everything necessary to make amazing games, including rendering, physics, particles, sound effects, music, input handling, and debug tools. LittleJS is designed to be extremely small yet powerful enough for a variety of applications, from game jams to commercial releases. The code is very well documented with a variety of examples to get you started. Choo-Choo! 🚂
6
-
7
- ## [LittleJS Documentation](https://killedbyapixel.github.io/LittleJS/docs) - [LittleJS Trailer](https://youtu.be/chuBzGjv7Ms) - [LittleJS Discord](https://discord.gg/zb7hcGkyZe)
8
-
9
- ![LittleJS Screenshot](examples/screenshot.jpg)
10
-
11
- ## Example Projects
12
-
13
- ### [Hello World](https://killedbyapixel.github.io/LittleJS/) - Clean project with only a few things to get you started
14
- ### [Puzzle Game](https://killedbyapixel.github.io/LittleJS/examples/puzzle) - Match 3 puzzle game with HD rendering and high score tracking
15
- ### [Platformer](https://killedbyapixel.github.io/LittleJS/examples/platformer) - Platformer/shooter with procedural generation and destruction
16
- ### [Breakout](https://killedbyapixel.github.io/LittleJS/examples/breakout) - Breakout game with mouse/touch or gamepad control
17
- ### [Stress Test](https://killedbyapixel.github.io/LittleJS/examples/stress) - Max sprite/object test and music system demo
18
-
19
- ## Features
20
-
21
- - Very small footprint with no dependencies
22
- - Can update and render 10,000+ objects at 60fps, often many times more
23
- - Object oriented system with fast 2D physics and collision handling for axis aligned boxes
24
- - Positional audio effects with [zzfx](https://killedbyapixel.github.io/ZzFX/) and music with [zzfxm](https://keithclark.github.io/ZzFXM/), mp3s, or wavs
25
- - Input processing system with keyboard, mouse, gamepad, and touch support
26
- - Particle effects system (particle editor/designer in progress)
27
- - Medal system tracks and displays achievements with Newgrounds and OS13k integration
28
- - Several easy to understand example projects you can build on
29
- - Debug tools and debug rendering system
30
- - [Full documentation](https://killedbyapixel.github.io/LittleJS/docs) automatically generated from the source code block tags with [JSDoc](https://github.com/jsdoc/jsdoc)
31
- - Build system automatically combines everything, minifies, and removes unused code
32
- - For size coding competitions like [js13kGames](https://js13kgames.com/), starter project builds to a 7KB zip file
33
- - (https://github.com/lifthrasiir/roadroller)
34
- - Easily build a Windows executable with [Electron](https://www.electronjs.org/) for distribution on platforms like Steam
35
- - Open Source with the [MIT license](https://github.com/KilledByAPixel/LittleJS/blob/main/LICENSE) so it can be used for anything you want
36
-
37
- ## Builds
38
-
39
- To easily include LittleJS in your game, you can use one of the 3 pre-built js files. These are also built automatically by the build scripts..
40
-
41
- - [engine.all.js](https://github.com/KilledByAPixel/LittleJS/blob/main/engine/engine.all.js) - The full game engine with debug mode available
42
- - [engine.all.release.js](https://github.com/KilledByAPixel/LittleJS/blob/main/engine/engine.all.release.js) - The engine optimized for release builds
43
- - [engine.all.min.js](https://github.com/KilledByAPixel/LittleJS/blob/main/engine/engine.all.min.js) - The engine in release mode and minified
44
-
45
- The hello world example includes a batch file [build.bat](https://github.com/KilledByAPixel/LittleJS/blob/main/build.bat) that compresses everything into a tiny zip file using Google Closure, UglifyJS, Roadroller, and ECT. You must run [buildSetup.bat](https://github.com/KilledByAPixel/LittleJS/blob/main/buildSetup.bat) to install the necessary npm dependencies.
46
-
47
- ## Games Made With LittleJS
48
-
49
- - [Space Huggers](https://www.newgrounds.com/portal/view/819609) - Run and gun platformer with procedural levels
50
- - [Space Huggers - JS13k Edition](https://github.com/KilledByAPixel/SpaceHuggers) - Original js13k game with source code
51
- - [Isletopia](https://store.steampowered.com/app/1861260/Isletopia) - Relaxing strategy game of greenifying barren islands
52
- - Send me your games!
53
-
54
- ![LittleJS Logo](favicon.png)