littlejsengine 1.4.8 → 1.4.91

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/engine/index.d.ts CHANGED
@@ -849,14 +849,14 @@ declare let touchGamepadAlpha: number;
849
849
  * @default
850
850
  * @memberof Settings */
851
851
  declare let vibrateEnable: number;
852
- /** Volume scale to apply to all sound, music and speech
853
- * @default
854
- * @memberof Settings */
855
- declare let soundVolume: number;
856
852
  /** All audio code can be disabled and removed from build
857
853
  * @default
858
854
  * @memberof Settings */
859
855
  declare let soundEnable: number;
856
+ /** Volume scale to apply to all sound, music and speech
857
+ * @default
858
+ * @memberof Settings */
859
+ declare let soundVolume: number;
860
860
  /** Default range where sound no longer plays
861
861
  * @default
862
862
  * @memberof Settings */
@@ -873,18 +873,18 @@ declare let medalDisplayTime: number;
873
873
  * @default
874
874
  * @memberof Settings */
875
875
  declare let medalDisplaySlideTime: number;
876
- /** Width of medal display
877
- * @default
878
- * @memberof Settings */
879
- declare let medalDisplayWidth: number;
880
- /** Height of medal display
876
+ /** Size of medal display
881
877
  * @default
882
878
  * @memberof Settings */
883
- declare let medalDisplayHeight: number;
879
+ declare let medalDisplaySize: Vector2;
884
880
  /** Size of icon in medal display
885
881
  * @default
886
882
  * @memberof Settings */
887
883
  declare let medalDisplayIconSize: number;
884
+ /** Set to stop medals from being unlockable (like if cheats are enabled)
885
+ * @default
886
+ * @memberof Settings */
887
+ declare let medalsPreventUnlock: any;
888
888
  /**
889
889
  * LittleJS Object Base Object Class
890
890
  * <br> - Base object class used by the engine
@@ -1060,8 +1060,8 @@ declare function worldToScreen(worldPos: Vector2): Vector2;
1060
1060
  declare let engineFontImage: any;
1061
1061
  declare class FontImage {
1062
1062
  /** Create an image font
1063
- * @param {HTMLImageElement} [image] - The image the font is stored in, if undefined the default font is used
1064
- * @param {Vector2} [tileSize=vec2(8)] - The size of the font source tiles
1063
+ * @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
1064
+ * @param {Vector2} [tileSize=vec2(8)] - Size of the font source tiles
1065
1065
  * @param {Vector2} [paddingSize=vec2(0,1)] - How much extra space to add between characters
1066
1066
  * @param {Number} [startTileIndex=0] - Tile index in image where font starts
1067
1067
  * @param {CanvasRenderingContext2D} [context=overlayContext] - context to draw to
@@ -1528,9 +1528,6 @@ declare class Particle extends EngineObject {
1528
1528
  /** List of all medals
1529
1529
  * @memberof Medals */
1530
1530
  declare const medals: any[];
1531
- /** Set to stop medals from being unlockable (like if cheats are enabled)
1532
- * @memberof Medals */
1533
- declare let medalsPreventUnlock: any;
1534
1531
  declare let medalsDisplayQueue: any[];
1535
1532
  declare let medalsSaveName: any;
1536
1533
  declare let medalsDisplayTimeLast: any;
@@ -1589,11 +1586,11 @@ declare class Newgrounds {
1589
1586
  * @param {Number} app_id - The newgrounds App ID
1590
1587
  * @param {String} [cipher] - The encryption Key (AES-128/Base64) */
1591
1588
  constructor(app_id: number, cipher?: string);
1592
- cryptoJS: any;
1593
1589
  app_id: number;
1594
1590
  cipher: string;
1595
1591
  host: string;
1596
- session_id: string | number;
1592
+ cryptoJS: any;
1593
+ session_id: string;
1597
1594
  medals: any;
1598
1595
  scoreboards: any;
1599
1596
  /** Send message to unlock a medal by id
@@ -1621,6 +1618,7 @@ declare class Newgrounds {
1621
1618
  * @return {Object} - The response JSON object
1622
1619
  */
1623
1620
  call(component: string, parameters?: any, async?: boolean): any;
1621
+ CryptoJS(): any;
1624
1622
  }
1625
1623
  /** The WebGL canvas which appears above the main canvas and below the overlay canvas
1626
1624
  * @type {HTMLCanvasElement}
@@ -1681,7 +1679,7 @@ declare const gl_VERTEX_BUFFER_SIZE: number;
1681
1679
  /** Name of engine */
1682
1680
  declare const engineName: "LittleJS";
1683
1681
  /** Version of engine */
1684
- declare const engineVersion: "1.4.8";
1682
+ declare const engineVersion: "1.4.9";
1685
1683
  /** Frames per second to update objects
1686
1684
  * @default */
1687
1685
  declare const frameRate: 60;
@@ -8,22 +8,22 @@ let levelSize, ball, paddle, score, brickCount;
8
8
 
9
9
  // sound effects
10
10
  const sound_start = new Sound([,0,500,,.04,.3,1,2,,,570,.02,.02,,,,.04]);
11
- const sound_break = new Sound([,,90,,.01,.03,4,,,,,,,9,50,.2,,.2,.01], 0);
12
- const sound_bounce = new Sound([,,1e3,,.03,.02,1,2,,,940,.03,,,,,.2,.6,,.06], 0);
11
+ const sound_break = new Sound([,,90,,.01,.03,4,,,,,,,9,50,.2,,.2,.01]);
12
+ const sound_bounce = new Sound([,,1e3,,.03,.02,1,2,,,940,.03,,,,,.2,.6,,.06]);
13
13
 
14
14
  ///////////////////////////////////////////////////////////////////////////////
15
15
  function gameInit()
16
16
  {
17
17
  canvasFixedSize = vec2(1280, 720); // 720p
18
- levelSize = vec2(72, 40);
18
+ levelSize = vec2(38, 20);
19
19
  cameraPos = levelSize.scale(.5);
20
- paddle = new Paddle(vec2(levelSize.x/2-12,2));
20
+ paddle = new Paddle(vec2(levelSize.x/2-12,1));
21
21
  score = brickCount = 0;
22
22
 
23
23
  // spawn bricks
24
24
  const pos = vec2();
25
- for (pos.x = 6; pos.x <= levelSize.x-6; pos.x += 4)
26
- for (pos.y = levelSize.y/2; pos.y <= levelSize.y-4; pos.y += 2)
25
+ for (pos.x = 4; pos.x <= levelSize.x-4; pos.x += 2)
26
+ for (pos.y = 12; pos.y <= levelSize.y-2; pos.y += 1)
27
27
  new Brick(pos);
28
28
 
29
29
  initPostProcess(); // set up a post processing shader
@@ -35,7 +35,7 @@ function gameUpdate()
35
35
  // spawn ball
36
36
  if (!ball && (mouseWasPressed(0) || gamepadWasPressed(0)))
37
37
  {
38
- ball = new Ball(vec2(levelSize.x/2, levelSize.y/2-6));
38
+ ball = new Ball(vec2(levelSize.x/2, levelSize.y/2));
39
39
  sound_start.play();
40
40
  }
41
41
  }
@@ -59,11 +59,11 @@ function gameRenderPost()
59
59
  {
60
60
  // use built in image font for text
61
61
  const font = new FontImage;
62
- font.drawText('Score: ' + score, cameraPos.add(vec2(0,22)), .2, 1);
62
+ font.drawText('Score: ' + score, cameraPos.add(vec2(0,9.6)), .1, 1);
63
63
  if (!brickCount)
64
- font.drawText('You Win!', cameraPos.add(vec2(0,-5)), .25, 1);
64
+ font.drawText('You Win!', cameraPos.add(vec2(0,-5)), .2, 1);
65
65
  else if (!ball)
66
- font.drawText('Click to Play', cameraPos.add(vec2(0,-5)), .25, 1);
66
+ font.drawText('Click to Play', cameraPos.add(vec2(0,-5)), .2, 1);
67
67
  }
68
68
 
69
69
  ///////////////////////////////////////////////////////////////////////////////
@@ -9,7 +9,7 @@ class Paddle extends EngineObject
9
9
  {
10
10
  constructor(pos)
11
11
  {
12
- super(pos, vec2(8,1));
12
+ super(pos, vec2(5,.5));
13
13
 
14
14
  // set to collide
15
15
  this.setCollision();
@@ -38,7 +38,7 @@ class Brick extends EngineObject
38
38
  {
39
39
  constructor(pos)
40
40
  {
41
- super(pos, vec2(4,2), 1, vec2(32,16), 0, randColor());
41
+ super(pos, vec2(2,1), 1, vec2(32,16), 0, randColor());
42
42
 
43
43
  // set to collide
44
44
  this.setCollision();
@@ -62,7 +62,7 @@ class Brick extends EngineObject
62
62
  0, vec2(16), // tileIndex, tileSize
63
63
  color1, color2, // colorStartA, colorStartB
64
64
  color1.scale(1,0), color2.scale(1,0), // colorEndA, colorEndB
65
- .2, 1, 2, .1, .05, // time, sizeStart, sizeEnd, speed, angleSpeed
65
+ .2, .5, 1, .05, .05,// time, sizeStart, sizeEnd, speed, angleSpeed
66
66
  .99, .95, .4, PI, // damping, angleDamping, gravityScale, cone
67
67
  .1, .5, 0, 1 // fadeRate, randomness, collide, additive
68
68
  );
@@ -76,11 +76,11 @@ class Ball extends EngineObject
76
76
  {
77
77
  constructor(pos)
78
78
  {
79
- super(pos, vec2(1), 0);
79
+ super(pos, vec2(.5), 0);
80
80
 
81
81
  // make a bouncy ball
82
82
  this.setCollision();
83
- this.velocity = vec2(randSign(), -1).scale(.2);
83
+ this.velocity = vec2(randSign(), -1).scale(.1);
84
84
  this.elasticity = 1;
85
85
  this.damping = 1;
86
86
  }
@@ -117,7 +117,7 @@ class Ball extends EngineObject
117
117
  {
118
118
  // put english on the ball when it collides with paddle
119
119
  this.velocity = this.velocity.rotate(.2 * (this.pos.x - o.pos.x));
120
- this.velocity.y = max(abs(this.velocity.y), .2);
120
+ this.velocity.y = max(-this.velocity.y, .2);
121
121
  this.bounce();
122
122
  return 0;
123
123
  }
@@ -127,7 +127,7 @@ class Ball extends EngineObject
127
127
  bounce()
128
128
  {
129
129
  // speed up
130
- const speed = min(1.1*this.velocity.length(), 1);
130
+ const speed = min(1.05*this.velocity.length(), .5);
131
131
  this.velocity = this.velocity.normalize(speed);
132
132
 
133
133
  // scale bounce sound pitch by speed
@@ -5,6 +5,6 @@
5
5
  <link rel=icon type=image/png href=../../favicon.png>
6
6
  </head><body>
7
7
 
8
- <script src=../../engine/engine.all.js?121></script>
9
- <script src=gameObjects.js?121></script>
10
- <script src=game.js?121></script>
8
+ <script src=../../engine/engine.all.js?123></script>
9
+ <script src=gameObjects.js?123></script>
10
+ <script src=game.js?123></script>
Binary file
@@ -12,7 +12,7 @@ const Timer = LittleJS.Timer;
12
12
  const vec2 = LittleJS.vec2;
13
13
 
14
14
  // sound effects
15
- const sound_click = new LittleJS.Sound([.5,.5]);
15
+ const sound_click = new LittleJS.Sound([1,.5]);
16
16
 
17
17
  // medals
18
18
  const medal_example = new LittleJS.Medal(0, 'Example Medal', 'Welcome to LittleJS!');
@@ -26,8 +26,8 @@ function gameInit()
26
26
  {
27
27
  // create tile collision and visible tile layer
28
28
  LittleJS.initTileCollision(vec2(32, 16));
29
- const tileLayer = new LittleJS.TileLayer(vec2(), LittleJS.tileCollisionSize);
30
29
  const pos = vec2();
30
+ const tileLayer = new LittleJS.TileLayer(pos, LittleJS.tileCollisionSize);
31
31
 
32
32
  // get level data from the tiles image
33
33
  const imageLevelDataRow = 1;
@@ -36,24 +36,22 @@ function gameInit()
36
36
  for (pos.x = LittleJS.tileCollisionSize.x; pos.x--;)
37
37
  for (pos.y = LittleJS.tileCollisionSize.y; pos.y--;)
38
38
  {
39
- const data = mainContext.getImageData(pos.x, 16*(imageLevelDataRow+1)-pos.y-1, 1, 1).data;
40
- if (data[0])
39
+ const imageData = mainContext.getImageData(pos.x, 16*(imageLevelDataRow+1)-pos.y-1, 1, 1).data;
40
+ if (imageData[0])
41
41
  {
42
- LittleJS.setTileCollisionData(pos, 1);
43
-
44
42
  const tileIndex = 1;
45
43
  const direction = LittleJS.randInt(4)
46
44
  const mirror = LittleJS.randInt(2);
47
45
  const color = LittleJS.randColor();
48
46
  const data = new LittleJS.TileLayerData(tileIndex, direction, mirror, color);
49
47
  tileLayer.setData(pos, data);
48
+ LittleJS.setTileCollisionData(pos, 1);
50
49
  }
51
50
  }
52
51
  tileLayer.redraw();
53
52
 
54
53
  // move camera to center of collision
55
54
  LittleJS.setCameraPos(LittleJS.tileCollisionSize.scale(.5));
56
- LittleJS.setCameraScale(32);
57
55
 
58
56
  // enable gravity
59
57
  LittleJS.setGravity(-.01);
@@ -6,4 +6,4 @@
6
6
  </head><body>
7
7
 
8
8
  <!-- Add your game scripts here -->
9
- <script src=game.js?121 type=module></script>
9
+ <script src=game.js?123 type=module></script>
@@ -15,18 +15,7 @@ button
15
15
  </style>
16
16
  </head><body>
17
17
 
18
- <script src=../../engine/engineDebug.js?121></script>
19
- <script src=../../engine/engineUtilities.js?121></script>
20
- <script src=../../engine/engineSettings.js?121></script>
21
- <script src=../../engine/engineObject.js?121></script>
22
- <script src=../../engine/engineDraw.js?121></script>
23
- <script src=../../engine/engineInput.js?121></script>
24
- <script src=../../engine/engineAudio.js?121></script>
25
- <script src=../../engine/engineTileLayer.js?121></script>
26
- <script src=../../engine/engineParticles.js?121></script>
27
- <script src=../../engine/engineMedals.js?121></script>
28
- <script src=../../engine/engineWebGL.js?121></script>
29
- <script src=../../engine/engine.js?121></script>
18
+ <script src=../../engine/engine.all.js?123></script>
30
19
  <script>
31
20
 
32
21
  'use strict';
@@ -74,6 +63,8 @@ addSetting('randomColorLinear','checkbox',0,0,0, 'Should color be randomized li
74
63
 
75
64
  function makeEmitter()
76
65
  {
66
+ if (particleSystem)
67
+ particleSystem.destroy();
77
68
  particleSystem = new ParticleEmitter(cameraPos);
78
69
  particleSystem.emitConeAngle =
79
70
  particleSystem.particleConeAngle = 3.14;
@@ -84,7 +75,7 @@ function gameInit()
84
75
  {
85
76
  makeEmitter();
86
77
  gravity = -.01;
87
- cameraScale = 50;
78
+ cameraScale = 64;
88
79
 
89
80
  const div = particleSystemDiv = document.createElement('div');
90
81
  div.innerHTML = '<big><b>LittleJS Particle Tool';
@@ -175,7 +166,6 @@ function gameInit()
175
166
  {
176
167
  if (!confirm('Reset to default?'))
177
168
  return;
178
- particleSystem.destroy();
179
169
  makeEmitter();
180
170
  updateInputs(0);
181
171
  cameraScale = 50;
@@ -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?121></script>
9
- <script src=gameObjects.js?121></script>
10
- <script src=gamePlayer.js?121></script>
11
- <script src=gameEffects.js?121></script>
12
- <script src=gameLevel.js?121></script>
13
- <script src=game.js?121></script>
8
+ <script src=../../engine/engine.all.js?123></script>
9
+ <script src=gameObjects.js?123></script>
10
+ <script src=gamePlayer.js?123></script>
11
+ <script src=gameEffects.js?123></script>
12
+ <script src=gameLevel.js?123></script>
13
+ <script src=game.js?123></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?121></script>
9
- <script src=game.js?121></script>
8
+ <script src=../../engine/engine.all.js?123></script>
9
+ <script src=game.js?123></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?121></script>
8
+ <script src=../../engine/engine.all.min.js?123></script>
9
9
  <script>
10
10
 
11
11
  /*
package/game.js CHANGED
@@ -44,7 +44,6 @@ function gameInit()
44
44
 
45
45
  // move camera to center of collision
46
46
  cameraPos = tileCollisionSize.scale(.5);
47
- cameraScale = 32;
48
47
 
49
48
  // enable gravity
50
49
  gravity = -.01;
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?121></script>
10
- <script src=engine/engineUtilities.js?121></script>
11
- <script src=engine/engineSettings.js?121></script>
12
- <script src=engine/engineObject.js?121></script>
13
- <script src=engine/engineDraw.js?121></script>
14
- <script src=engine/engineInput.js?121></script>
15
- <script src=engine/engineAudio.js?121></script>
16
- <script src=engine/engineTileLayer.js?121></script>
17
- <script src=engine/engineParticles.js?121></script>
18
- <script src=engine/engineMedals.js?121></script>
19
- <script src=engine/engineWebGL.js?121></script>
20
- <script src=engine/engine.js?121></script>
9
+ <script src=engine/engineDebug.js?123></script>
10
+ <script src=engine/engineUtilities.js?123></script>
11
+ <script src=engine/engineSettings.js?123></script>
12
+ <script src=engine/engineObject.js?123></script>
13
+ <script src=engine/engineDraw.js?123></script>
14
+ <script src=engine/engineInput.js?123></script>
15
+ <script src=engine/engineAudio.js?123></script>
16
+ <script src=engine/engineTileLayer.js?123></script>
17
+ <script src=engine/engineParticles.js?123></script>
18
+ <script src=engine/engineMedals.js?123></script>
19
+ <script src=engine/engineWebGL.js?123></script>
20
+ <script src=engine/engine.js?123></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?121></script>
26
+ <script src=game.js?123></script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "littlejsengine",
3
- "version": "1.4.8",
3
+ "version": "1.4.91",
4
4
  "description": "LittleJS - Tiny and Fast HTML5 Game Engine",
5
5
  "main": "engine/engine.all.module.js",
6
6
  "repository": {