littlejsengine 1.9.0 → 1.9.2

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 (63) hide show
  1. package/README.md +7 -7
  2. package/{build → dist}/littlejs.d.ts +84 -77
  3. package/{build → dist}/littlejs.esm.js +245 -143
  4. package/dist/littlejs.esm.min.js +1 -0
  5. package/{build → dist}/littlejs.js +245 -143
  6. package/dist/littlejs.min.js +1 -0
  7. package/{build → dist}/littlejs.release.js +239 -141
  8. package/examples/breakout/game.js +2 -2
  9. package/examples/breakout/gameObjects.js +3 -3
  10. package/examples/breakout/index.html +3 -3
  11. package/examples/breakoutTutorial/index.html +2 -2
  12. package/examples/electron/build.js +1 -1
  13. package/examples/electron/game.js +49 -38
  14. package/examples/electron/index.html +2 -2
  15. package/examples/electron/tiles.png +0 -0
  16. package/examples/empty/index.html +1 -1
  17. package/examples/js13k/build.js +2 -2
  18. package/examples/js13k/game.js +10 -9
  19. package/examples/js13k/index.html +13 -13
  20. package/examples/js13k/tiles.png +0 -0
  21. package/examples/module/game.js +45 -41
  22. package/examples/module/index.html +1 -1
  23. package/examples/module/tiles.png +0 -0
  24. package/examples/particles/index.html +1 -1
  25. package/examples/platformer/data/gameTileData.tmx +143 -0
  26. package/examples/platformer/data/gameTileData.tsx +4 -0
  27. package/examples/platformer/game.js +0 -1
  28. package/examples/platformer/gameCharacter.js +1 -1
  29. package/examples/platformer/gameEffects.js +42 -110
  30. package/examples/platformer/gameLevel.js +149 -183
  31. package/examples/platformer/gameObjects.js +61 -16
  32. package/examples/platformer/gamePlayer.js +3 -2
  33. package/examples/platformer/gameTileData.js +181 -0
  34. package/examples/platformer/index.html +8 -7
  35. package/examples/platformer/tiles.png +0 -0
  36. package/examples/platformer/tilesLevel.png +0 -0
  37. package/examples/puzzle/game.js +12 -12
  38. package/examples/puzzle/index.html +2 -2
  39. package/examples/starter/build.js +2 -2
  40. package/examples/starter/game.js +6 -6
  41. package/examples/starter/index.html +13 -13
  42. package/examples/starter/tiles.png +0 -0
  43. package/examples/stress/index.html +2 -2
  44. package/examples/typescript/build.bat +4 -1
  45. package/examples/typescript/game.js +34 -31
  46. package/examples/typescript/game.ts +40 -36
  47. package/examples/typescript/index.html +1 -1
  48. package/examples/typescript/tiles.png +0 -0
  49. package/package.json +3 -3
  50. package/src/engine.js +1 -1
  51. package/src/engineAudio.js +4 -10
  52. package/src/engineBuild.js +9 -2
  53. package/src/engineDebug.js +6 -2
  54. package/src/engineDraw.js +27 -27
  55. package/src/engineInput.js +7 -7
  56. package/src/engineMedals.js +2 -2
  57. package/src/engineObject.js +7 -7
  58. package/src/engineParticles.js +9 -9
  59. package/src/engineTileLayer.js +38 -33
  60. package/src/engineUtilities.js +136 -35
  61. package/src/engineWebGL.js +8 -10
  62. package/build/littlejs.esm.min.js +0 -1
  63. package/build/littlejs.min.js +0 -1
@@ -62,8 +62,8 @@ function gameUpdatePost()
62
62
  function gameRender()
63
63
  {
64
64
  // draw a the background
65
- drawRect(cameraPos, levelSize.scale(2), new Color(.5,.5,.5));
66
- drawRect(cameraPos, levelSize, new Color(.02,.02,.02));
65
+ drawRect(cameraPos, levelSize.scale(2), hsl(0,0,.5));
66
+ drawRect(cameraPos, levelSize, hsl(0,0,.02));
67
67
  }
68
68
 
69
69
  ///////////////////////////////////////////////////////////////////////////////
@@ -13,7 +13,7 @@ class Wall extends EngineObject
13
13
 
14
14
  this.mass = 0; // make object have static physics
15
15
  this.setCollision(); // make object collide
16
- this.color = new Color(0,0,0,0); // make object invisible
16
+ this.color = hsl(0,0,0,0); // make object invisible
17
17
  }
18
18
  }
19
19
 
@@ -60,7 +60,7 @@ class Brick extends EngineObject
60
60
 
61
61
  // make explosion effect
62
62
  const color1 = this.color;
63
- const color2 = color1.lerp(new Color, .5);
63
+ const color2 = color1.lerp(hsl(), .5);
64
64
  new ParticleEmitter(
65
65
  this.pos, 0, // pos, angle
66
66
  this.size, .1, 200, PI, // emitSize, emitTime, emitRate, emiteCone
@@ -76,7 +76,7 @@ class Brick extends EngineObject
76
76
  if (o.trailEffect)
77
77
  {
78
78
  o.trailEffect.colorStartA = this.color;
79
- o.trailEffect.colorStartB = this.color.lerp(new Color, .5);
79
+ o.trailEffect.colorStartB = this.color.lerp(hsl(), .5);
80
80
  }
81
81
 
82
82
  return 1;
@@ -5,6 +5,6 @@
5
5
  <link rel=icon type=image/png href=../favicon.png>
6
6
  </head><body>
7
7
 
8
- <script src=../../build/littlejs.js?1812></script>
9
- <script src=gameObjects.js?1812></script>
10
- <script src=game.js?1812></script>
8
+ <script src=../../dist/littlejs.js?192></script>
9
+ <script src=gameObjects.js?192></script>
10
+ <script src=game.js?192></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=../../build/littlejs.js?1812></script>
9
- <script src=game.js?1812></script>
8
+ <script src=../../dist/littlejs.js?192></script>
9
+ <script src=game.js?192></script>
@@ -10,7 +10,7 @@ const PROGRAM_NAME = 'game';
10
10
  const BUILD_FOLDER = 'build';
11
11
  const sourceFiles =
12
12
  [
13
- '../../build/littlejs.release.js',
13
+ '../../dist/littlejs.release.js',
14
14
  'game.js',
15
15
  // add your game's files here
16
16
  ];
@@ -1,11 +1,15 @@
1
1
  /*
2
- Little JS Electron Demo
3
- - A simple starter project
4
- - Builds to an executable with Electron
2
+ Little JS Electron Starter Project
3
+ - A simple starter project for LittleJS
4
+ - Demos all the main engine features
5
+ - Builds to an Electron app
5
6
  */
6
7
 
7
8
  'use strict';
8
9
 
10
+ // show the LittleJS splash screen
11
+ setShowSplashScreen(true);
12
+
9
13
  // sound effects
10
14
  const sound_click = new Sound([1,.5]);
11
15
 
@@ -14,59 +18,61 @@ const medal_example = new Medal(0, 'Example Medal', 'Welcome to LittleJS!');
14
18
  medalsInit('Hello World');
15
19
 
16
20
  // game variables
17
- let particleEmiter;
18
-
19
- // show the LittleJS splash screen
20
- setShowSplashScreen(true);
21
+ let particleEmitter;
21
22
 
22
23
  ///////////////////////////////////////////////////////////////////////////////
23
24
  function gameInit()
24
25
  {
25
26
  // create tile collision and visible tile layer
26
- initTileCollision(vec2(32, 16));
27
+ initTileCollision(vec2(32,16));
27
28
  const pos = vec2();
28
29
  const tileLayer = new TileLayer(pos, tileCollisionSize);
29
30
 
30
31
  // get level data from the tiles image
31
- const imageLevelDataRow = 1;
32
32
  const tileImage = textureInfos[0].image;
33
- mainContext.drawImage(tileImage, 0, 0);
33
+ mainContext.drawImage(tileImage,0,0);
34
+ const imageData = mainContext.getImageData(0,0,tileImage.width,tileImage.height).data;
34
35
  for (pos.x = tileCollisionSize.x; pos.x--;)
35
36
  for (pos.y = tileCollisionSize.y; pos.y--;)
36
37
  {
37
- const imageData = mainContext.getImageData(pos.x, 16*(imageLevelDataRow+1)-pos.y-1, 1, 1).data;
38
- if (imageData[0])
39
- {
40
- const tileIndex = 1;
41
- const direction = randInt(4)
42
- const mirror = randInt(2);
43
- const color = randColor();
44
- const data = new TileLayerData(tileIndex, direction, mirror, color);
45
- tileLayer.setData(pos, data);
46
- setTileCollisionData(pos, 1);
47
- }
38
+ // check if this pixel is set
39
+ const i = pos.x + tileImage.width*(15 + tileCollisionSize.y - pos.y);
40
+ if (!imageData[4*i])
41
+ continue;
42
+
43
+ // set tile data
44
+ const tileIndex = 1;
45
+ const direction = randInt(4)
46
+ const mirror = randInt(2);
47
+ const color = randColor();
48
+ const data = new TileLayerData(tileIndex, direction, mirror, color);
49
+ tileLayer.setData(pos, data);
50
+ setTileCollisionData(pos, 1);
48
51
  }
52
+
53
+ // draw tile layer with new data
49
54
  tileLayer.redraw();
50
55
 
51
- // move camera to center of collision
52
- cameraPos = tileCollisionSize.scale(.5);
56
+ // setup camera
57
+ cameraPos = vec2(16,8);
58
+ cameraScale = 48;
53
59
 
54
60
  // enable gravity
55
61
  gravity = -.01;
56
62
 
57
63
  // create particle emitter
58
- particleEmiter = new ParticleEmitter(
59
- vec2(16), 0, // emitPos, emitAngle
60
- 1, 0, 500, PI, // emitSize, emitTime, emitRate, emiteCone
61
- tile(0, 16), // tileIndex, tileSize
62
- new Color(1,1,1), new Color(0,0,0), // colorStartA, colorStartB
63
- new Color(1,1,1,0), new Color(0,0,0,0), // colorEndA, colorEndB
64
+ particleEmitter = new ParticleEmitter(
65
+ vec2(16,9), 0, // emitPos, emitAngle
66
+ 1, 0, 500, PI, // emitSize, emitTime, emitRate, emiteCone
67
+ tile(0, 16), // tileIndex, tileSize
68
+ hsl(1,1,1), hsl(0,0,0), // colorStartA, colorStartB
69
+ hsl(0,0,0,0), hsl(0,0,0,0), // colorEndA, colorEndB
64
70
  2, .2, .2, .1, .05, // time, sizeStart, sizeEnd, speed, angleSpeed
65
71
  .99, 1, 1, PI, // damping, angleDamping, gravityScale, cone
66
72
  .05, .5, 1, 1 // fadeRate, randomness, collide, additive
67
73
  );
68
- particleEmiter.elasticity = .3; // bounce when it collides
69
- particleEmiter.trailScale = 2; // stretch in direction of motion
74
+ particleEmitter.elasticity = .3; // bounce when it collides
75
+ particleEmitter.trailScale = 2; // stretch in direction of motion
70
76
  }
71
77
 
72
78
  ///////////////////////////////////////////////////////////////////////////////
@@ -78,10 +84,10 @@ function gameUpdate()
78
84
  sound_click.play(mousePos);
79
85
 
80
86
  // change particle color and set to fade out
81
- particleEmiter.colorStartA = new Color;
82
- particleEmiter.colorStartB = randColor();
83
- particleEmiter.colorEndA = particleEmiter.colorStartA.scale(1,0);
84
- particleEmiter.colorEndB = particleEmiter.colorStartB.scale(1,0);
87
+ particleEmitter.colorStartA = hsl();
88
+ particleEmitter.colorStartB = randColor();
89
+ particleEmitter.colorEndA = particleEmitter.colorStartA.scale(1,0);
90
+ particleEmitter.colorEndB = particleEmitter.colorStartB.scale(1,0);
85
91
 
86
92
  // unlock medals
87
93
  medal_example.unlock();
@@ -89,7 +95,7 @@ function gameUpdate()
89
95
 
90
96
  // move particles to mouse location if on screen
91
97
  if (mousePosScreen.x)
92
- particleEmiter.pos = mousePos;
98
+ particleEmitter.pos = mousePos;
93
99
  }
94
100
 
95
101
  ///////////////////////////////////////////////////////////////////////////////
@@ -102,14 +108,19 @@ function gameUpdatePost()
102
108
  function gameRender()
103
109
  {
104
110
  // draw a grey square in the background without using webgl
105
- drawRect(cameraPos, tileCollisionSize.add(vec2(5)), new Color(.2,.2,.2), 0, 0);
111
+ drawRect(vec2(16,8), vec2(20,14), hsl(0,0,.6), 0, 0);
112
+
113
+ // draw the logo as a tile
114
+ drawTile(vec2(21,5), vec2(4.5), tile(3,128));
106
115
  }
107
116
 
108
117
  ///////////////////////////////////////////////////////////////////////////////
109
118
  function gameRenderPost()
110
119
  {
111
120
  // draw to overlay canvas for hud rendering
112
- drawTextScreen('LittleJS Electron Demo', vec2(mainCanvasSize.x/2, 80), 80);
121
+ drawTextScreen('LittleJS Electron Demo',
122
+ vec2(mainCanvasSize.x/2, 70), 80, // position, size
123
+ hsl(0,0,1), 6, hsl(0,0,0)); // color, outline size and color
113
124
  }
114
125
 
115
126
  ///////////////////////////////////////////////////////////////////////////////
@@ -6,7 +6,7 @@
6
6
  </head><body>
7
7
 
8
8
  <!-- LittleJS Engine -->
9
- <script src=../../build/littlejs.js?1812></script>
9
+ <script src=../../dist/littlejs.js?192></script>
10
10
 
11
11
  <!-- Add your game scripts here -->
12
- <script src=game.js?1812></script>
12
+ <script src=game.js?192></script>
Binary file
@@ -2,5 +2,5 @@
2
2
  <title>Little JS Hello World Demo</title>
3
3
  </head><body>
4
4
 
5
- <script src=../../build/littlejs.js></script>
5
+ <script src=../../dist/littlejs.js></script>
6
6
  <script src=game.js></script>
@@ -10,7 +10,7 @@ const PROGRAM_NAME = 'game';
10
10
  const BUILD_FOLDER = 'build';
11
11
  const sourceFiles =
12
12
  [
13
- '../../build/littlejs.release.js',
13
+ '../../dist/littlejs.release.js',
14
14
  'game.js',
15
15
  // add your game's files here
16
16
  ];
@@ -26,7 +26,7 @@ const fs = require('node:fs');
26
26
  const child_process = require('node:child_process');
27
27
 
28
28
  // rebuild engine
29
- child_process.execSync(`npm run build`, { stdio: 'inherit' });
29
+ //child_process.execSync(`npm run build`, { stdio: 'inherit' });
30
30
 
31
31
  // remove old files and setup build folder
32
32
  fs.rmSync(BUILD_FOLDER, { recursive: true, force: true });
@@ -1,6 +1,7 @@
1
1
  /*
2
2
  LittleJS JS13K Starter Game
3
3
  - For size limited projects
4
+ - Includes all core engine features
4
5
  - Builds to 7kb zip file
5
6
  */
6
7
 
@@ -19,7 +20,7 @@ let particleEmitter;
19
20
  function gameInit()
20
21
  {
21
22
  // create tile collision and visible tile layer
22
- initTileCollision(vec2(32, 16));
23
+ initTileCollision(vec2(32,16));
23
24
  const pos = vec2();
24
25
  const tileLayer = new TileLayer(pos, tileCollisionSize);
25
26
 
@@ -48,19 +49,19 @@ function gameInit()
48
49
  // draw tile layer with new data
49
50
  tileLayer.redraw();
50
51
 
51
- // move camera to center of collision
52
- cameraPos = tileCollisionSize.scale(.5);
52
+ // setup camera
53
+ cameraPos = vec2(16,8);
53
54
 
54
55
  // enable gravity
55
56
  gravity = -.01;
56
57
 
57
58
  // create particle emitter
58
59
  particleEmitter = new ParticleEmitter(
59
- vec2(16), 0, // emitPos, emitAngle
60
- 1, 0, 500, PI, // emitSize, emitTime, emitRate, emiteCone
61
- tile(0, 16), // tileIndex, tileSize
60
+ vec2(16,9), 0, // emitPos, emitAngle
61
+ 1, 0, 500, PI, // emitSize, emitTime, emitRate, emiteCone
62
+ tile(0, 16), // tileIndex, tileSize
62
63
  new Color(1,1,1), new Color(0,0,0), // colorStartA, colorStartB
63
- new Color(1,1,1,0), new Color(0,0,0,0), // colorEndA, colorEndB
64
+ new Color(0,0,0,0), new Color(0,0,0,0), // colorEndA, colorEndB
64
65
  2, .2, .2, .1, .05, // time, sizeStart, sizeEnd, speed, angleSpeed
65
66
  .99, 1, 1, PI, // damping, angleDamping, gravityScale, cone
66
67
  .05, .5, 1, 1 // fadeRate, randomness, collide, additive
@@ -99,14 +100,14 @@ function gameUpdatePost()
99
100
  function gameRender()
100
101
  {
101
102
  // draw a grey square in the background without using webgl
102
- drawRect(cameraPos, tileCollisionSize.add(vec2(5)), new Color(.2,.2,.2), 0, 0);
103
+ drawRect(vec2(16,8), vec2(20,14), new Color(.6,.6,.6), 0, 0);
103
104
  }
104
105
 
105
106
  ///////////////////////////////////////////////////////////////////////////////
106
107
  function gameRenderPost()
107
108
  {
108
109
  // draw to overlay canvas for hud rendering
109
- drawTextScreen('LittleJS JS13K Project', vec2(mainCanvasSize.x/2, 80), 80);
110
+ drawTextScreen('LittleJS JS13K Demo', vec2(mainCanvasSize.x/2, 70), 80);
110
111
  }
111
112
 
112
113
  ///////////////////////////////////////////////////////////////////////////////
@@ -1,18 +1,18 @@
1
1
  <head><title>LittleJS JS13K Project</title></head><body>
2
2
 
3
3
  <!-- LittleJS Engine -->
4
- <script src=../../src/engineDebug.js?1812></script>
5
- <script src=../../src/engineUtilities.js?1812></script>
6
- <script src=../../src/engineSettings.js?1812></script>
7
- <script src=../../src/engineObject.js?1812></script>
8
- <script src=../../src/engineDraw.js?1812></script>
9
- <script src=../../src/engineInput.js?1812></script>
10
- <script src=../../src/engineAudio.js?1812></script>
11
- <script src=../../src/engineTileLayer.js?1812></script>
12
- <script src=../../src/engineParticles.js?1812></script>
13
- <script src=../../src/engineMedals.js?1812></script>
14
- <script src=../../src/engineWebGL.js?1812></script>
15
- <script src=../../src/engine.js?1812></script>
4
+ <script src=../../src/engineDebug.js?192></script>
5
+ <script src=../../src/engineUtilities.js?192></script>
6
+ <script src=../../src/engineSettings.js?192></script>
7
+ <script src=../../src/engineObject.js?192></script>
8
+ <script src=../../src/engineDraw.js?192></script>
9
+ <script src=../../src/engineInput.js?192></script>
10
+ <script src=../../src/engineAudio.js?192></script>
11
+ <script src=../../src/engineTileLayer.js?192></script>
12
+ <script src=../../src/engineParticles.js?192></script>
13
+ <script src=../../src/engineMedals.js?192></script>
14
+ <script src=../../src/engineWebGL.js?192></script>
15
+ <script src=../../src/engine.js?192></script>
16
16
 
17
17
  <!-- Add your game scripts here -->
18
- <script src=game.js?1812></script>
18
+ <script src=game.js?192></script>
Binary file
@@ -7,8 +7,8 @@
7
7
  'use strict';
8
8
 
9
9
  // import module
10
- import * as LittleJS from '../../build/littlejs.esm.js';
11
- const {Vector2, Color, Timer, vec2, tile} = LittleJS;
10
+ import * as LittleJS from '../../dist/littlejs.esm.js';
11
+ const {Vector2, Color, Timer, tile, vec2, hsl, rgb} = LittleJS;
12
12
 
13
13
  // show the LittleJS splash screen
14
14
  LittleJS.setShowSplashScreen(true);
@@ -21,62 +21,63 @@ const medal_example = new LittleJS.Medal(0, 'Example Medal', 'Welcome to LittleJ
21
21
  LittleJS.medalsInit('Hello World');
22
22
 
23
23
  // game variables
24
- let particleEmiter, gameTimer;
24
+ let particleEmitter;
25
25
 
26
26
  ///////////////////////////////////////////////////////////////////////////////
27
27
  function gameInit()
28
28
  {
29
29
  // create tile collision and visible tile layer
30
- LittleJS.initTileCollision(vec2(32, 16));
31
- const pos = new Vector2;
32
- const tileLayer = new LittleJS.TileLayer(pos, LittleJS.tileCollisionSize);
30
+ const tileCollisionSize = vec2(32, 16);
31
+ LittleJS.initTileCollision(tileCollisionSize);
32
+ const pos = vec2();
33
+ const tileLayer = new LittleJS.TileLayer(pos, tileCollisionSize);
33
34
 
34
35
  // get level data from the tiles image
35
- const imageLevelDataRow = 1;
36
36
  const mainContext = LittleJS.mainContext;
37
37
  const tileImage = LittleJS.textureInfos[0].image;
38
38
  mainContext.drawImage(tileImage, 0, 0);
39
- for (pos.x = LittleJS.tileCollisionSize.x; pos.x--;)
40
- for (pos.y = LittleJS.tileCollisionSize.y; pos.y--;)
39
+ const imageData = mainContext.getImageData(0,0,tileImage.width,tileImage.height).data;
40
+ for (pos.x = tileCollisionSize.x; pos.x--;)
41
+ for (pos.y = tileCollisionSize.y; pos.y--;)
41
42
  {
42
- const imageData = mainContext.getImageData(pos.x, 16*(imageLevelDataRow+1)-pos.y-1, 1, 1).data;
43
- if (imageData[0])
44
- {
45
- const tileIndex = 1;
46
- const direction = LittleJS.randInt(4)
47
- const mirror = LittleJS.randInt(2);
48
- const color = LittleJS.randColor();
49
- const data = new LittleJS.TileLayerData(tileIndex, direction, mirror, color);
50
- tileLayer.setData(pos, data);
51
- LittleJS.setTileCollisionData(pos, 1);
52
- }
43
+ // check if this pixel is set
44
+ const i = pos.x + tileImage.width*(15 + tileCollisionSize.y - pos.y);
45
+ if (!imageData[4*i])
46
+ continue;
47
+
48
+ // set tile data
49
+ const tileIndex = 1;
50
+ const direction = LittleJS.randInt(4)
51
+ const mirror = !LittleJS.randInt(2);
52
+ const color = LittleJS.randColor();
53
+ const data = new LittleJS.TileLayerData(tileIndex, direction, mirror, color);
54
+ tileLayer.setData(pos, data);
55
+ LittleJS.setTileCollisionData(pos, 1);
53
56
  }
57
+
58
+ // draw tile layer with new data
54
59
  tileLayer.redraw();
55
60
 
56
61
  // move camera to center of collision
57
- LittleJS.setCameraPos(LittleJS.tileCollisionSize.scale(.5));
62
+ LittleJS.setCameraPos(tileCollisionSize.scale(.5));
63
+ LittleJS.setCameraScale(48);
58
64
 
59
65
  // enable gravity
60
66
  LittleJS.setGravity(-.01);
61
67
 
62
68
  // create particle emitter
63
- const center = LittleJS.tileCollisionSize.scale(.5).add(vec2(0,9));
64
- particleEmiter = new LittleJS.ParticleEmitter(
65
- center, 0, // emitPos, emitAngle
66
- 1, 0, 500, Math.PI, // emitSize, emitTime, emitRate, emiteCone
67
- LittleJS.tile(0, 16), // tileIndex, tileSize
68
- new Color(1,1,1), new Color(0,0,0), // colorStartA, colorStartB
69
- new Color(1,1,1,0), new Color(0,0,0,0), // colorEndA, colorEndB
69
+ particleEmitter = new LittleJS.ParticleEmitter(
70
+ vec2(16,9), 0, // emitPos, emitAngle
71
+ 1, 0, 500, Math.PI, // emitSize, emitTime, emitRate, emiteCone
72
+ tile(0, 16), // tileIndex, tileSize
73
+ hsl(1,1,1), hsl(0,0,0), // colorStartA, colorStartB
74
+ hsl(0,0,0,0), hsl(0,0,0,0), // colorEndA, colorEndB
70
75
  2, .2, .2, .1, .05, // time, sizeStart, sizeEnd, speed, angleSpeed
71
76
  .99, 1, 1, Math.PI, // damping, angleDamping, gravityScale, cone
72
- .05, .5, 1, 1 // fadeRate, randomness, collide, additive
77
+ .05, .5, true, true // fadeRate, randomness, collide, additive
73
78
  );
74
- particleEmiter.elasticity = .3; // bounce when it collides
75
- particleEmiter.trailScale = 2; // stretch in direction of motion
76
-
77
- // start the game timer
78
- gameTimer = new Timer;
79
- gameTimer.set();
79
+ particleEmitter.elasticity = .3; // bounce when it collides
80
+ particleEmitter.trailScale = 2; // stretch in direction of motion
80
81
  }
81
82
 
82
83
  ///////////////////////////////////////////////////////////////////////////////
@@ -88,10 +89,10 @@ function gameUpdate()
88
89
  sound_click.play(LittleJS.mousePos);
89
90
 
90
91
  // change particle color and set to fade out
91
- particleEmiter.colorStartA = new Color;
92
- particleEmiter.colorStartB = LittleJS.randColor();
93
- particleEmiter.colorEndA = particleEmiter.colorStartA.scale(1,0);
94
- particleEmiter.colorEndB = particleEmiter.colorStartB.scale(1,0);
92
+ particleEmitter.colorStartA = hsl();
93
+ particleEmitter.colorStartB = LittleJS.randColor();
94
+ particleEmitter.colorEndA = particleEmitter.colorStartA.scale(1,0);
95
+ particleEmitter.colorEndB = particleEmitter.colorStartB.scale(1,0);
95
96
 
96
97
  // unlock medals
97
98
  medal_example.unlock();
@@ -99,7 +100,7 @@ function gameUpdate()
99
100
 
100
101
  // move particles to mouse location if on screen
101
102
  if (LittleJS.mousePosScreen.x)
102
- particleEmiter.pos = LittleJS.mousePos;
103
+ particleEmitter.pos = LittleJS.mousePos;
103
104
  }
104
105
 
105
106
  ///////////////////////////////////////////////////////////////////////////////
@@ -112,7 +113,10 @@ function gameUpdatePost()
112
113
  function gameRender()
113
114
  {
114
115
  // draw a grey square in the background without using webgl
115
- LittleJS.drawRect(LittleJS.cameraPos, LittleJS.tileCollisionSize.add(vec2(5)), new Color(.2,.2,.2), 0, 0);
116
+ LittleJS.drawRect(vec2(16,8), vec2(20,14), hsl(0,0,.6), 0, false);
117
+
118
+ // draw the logo as a tile
119
+ LittleJS.drawTile(vec2(21,5), vec2(4.5), tile(3,128));
116
120
  }
117
121
 
118
122
  ///////////////////////////////////////////////////////////////////////////////
@@ -6,4 +6,4 @@
6
6
  </head><body>
7
7
 
8
8
  <!-- Add your game scripts here -->
9
- <script src=game.js?1812 type=module></script>
9
+ <script src=game.js?192 type=module></script>
Binary file
@@ -9,7 +9,7 @@ button { margin:1px; }
9
9
  </style>
10
10
  </head><body>
11
11
 
12
- <script src=../../build/littlejs.js?1812></script>
12
+ <script src=../../dist/littlejs.js?192></script>
13
13
  <script>
14
14
 
15
15
  'use strict';