littlejsengine 1.6.4 → 1.6.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.
@@ -6,6 +6,6 @@
6
6
  <link rel=icon type=image/png href=../favicon.png>
7
7
  </head><body>
8
8
 
9
- <script src=../../build/littlejs.js?126></script>
10
- <script src=gameObjects.js?126></script>
11
- <script src=game.js?126></script>
9
+ <script src=../../build/littlejs.js?166></script>
10
+ <script src=gameObjects.js?166></script>
11
+ <script src=game.js?166></script>
@@ -6,5 +6,5 @@
6
6
  <link rel=icon type=image/png href=../favicon.png>
7
7
  </head><body>
8
8
 
9
- <script src=../../build/littlejs.js?126></script>
10
- <script src=game.js?126></script>
9
+ <script src=../../build/littlejs.js?166></script>
10
+ <script src=game.js?166></script>
Binary file
@@ -7,4 +7,4 @@
7
7
  </head><body>
8
8
 
9
9
  <!-- Add your game scripts here -->
10
- <script src=game.js?126 type=module></script>
10
+ <script src=game.js?166 type=module></script>
@@ -16,7 +16,7 @@ button
16
16
  </style>
17
17
  </head><body>
18
18
 
19
- <script src=../../build/littlejs.js?126></script>
19
+ <script src=../../build/littlejs.js?166></script>
20
20
  <script>
21
21
 
22
22
  'use strict';
@@ -6,9 +6,9 @@
6
6
  <link rel=icon type=image/png href=../favicon.png>
7
7
  </head><body>
8
8
 
9
- <script src=../../build/littlejs.js?126></script>
10
- <script src=gameObjects.js?126></script>
11
- <script src=gamePlayer.js?126></script>
12
- <script src=gameEffects.js?126></script>
13
- <script src=gameLevel.js?126></script>
14
- <script src=game.js?126></script>
9
+ <script src=../../build/littlejs.js?166></script>
10
+ <script src=gameObjects.js?166></script>
11
+ <script src=gamePlayer.js?166></script>
12
+ <script src=gameEffects.js?166></script>
13
+ <script src=gameLevel.js?166></script>
14
+ <script src=game.js?166></script>
@@ -6,7 +6,7 @@
6
6
 
7
7
  'use strict';
8
8
 
9
- cavasPixelated = 0; // do not use pixelated rendering
9
+ canvasPixelated = 0; // do not use pixelated rendering
10
10
 
11
11
  const fallTime = .2;
12
12
  const cameraOffset = vec2(0,-.5);
@@ -6,5 +6,5 @@
6
6
  <link rel=icon type=image/png href=../favicon.png>
7
7
  </head><body>
8
8
 
9
- <script src=../../build/littlejs.js?126></script>
10
- <script src=game.js?126></script>
9
+ <script src=../../build/littlejs.js?166></script>
10
+ <script src=game.js?166></script>
@@ -7,21 +7,21 @@
7
7
  </head><body>
8
8
 
9
9
  <!-- LittleJS engine scripts -->
10
- <script src=../../src/engineDebug.js?126></script>
11
- <script src=../../src/engineUtilities.js?126></script>
12
- <script src=../../src/engineSettings.js?126></script>
13
- <script src=../../src/engineObject.js?126></script>
14
- <script src=../../src/engineDraw.js?126></script>
15
- <script src=../../src/engineInput.js?126></script>
16
- <script src=../../src/engineAudio.js?126></script>
17
- <script src=../../src/engineTileLayer.js?126></script>
18
- <script src=../../src/engineParticles.js?126></script>
19
- <script src=../../src/engineMedals.js?126></script>
20
- <script src=../../src/engineWebGL.js?126></script>
21
- <script src=../../src/engine.js?126></script>
10
+ <script src=../../src/engineDebug.js?166></script>
11
+ <script src=../../src/engineUtilities.js?166></script>
12
+ <script src=../../src/engineSettings.js?166></script>
13
+ <script src=../../src/engineObject.js?166></script>
14
+ <script src=../../src/engineDraw.js?166></script>
15
+ <script src=../../src/engineInput.js?166></script>
16
+ <script src=../../src/engineAudio.js?166></script>
17
+ <script src=../../src/engineTileLayer.js?166></script>
18
+ <script src=../../src/engineParticles.js?166></script>
19
+ <script src=../../src/engineMedals.js?166></script>
20
+ <script src=../../src/engineWebGL.js?166></script>
21
+ <script src=../../src/engine.js?166></script>
22
22
 
23
23
  <!-- You can also include all engine scripts like this... -->
24
24
  <!-- <script src=engine/engine.all.js></script> -->
25
25
 
26
26
  <!-- Add your game scripts here -->
27
- <script src=game.js?126></script>
27
+ <script src=game.js?166></script>
@@ -6,7 +6,7 @@
6
6
  <link rel=icon type=image/png href=../favicon.png>
7
7
  </head><body>
8
8
 
9
- <script src=../../build/littlejs.min.js?126></script>
9
+ <script src=../../build/littlejs.min.js?166></script>
10
10
  <script>
11
11
 
12
12
  /*
@@ -7,4 +7,4 @@
7
7
  </head><body>
8
8
 
9
9
  <!-- Add your game scripts here -->
10
- <script src=game.js?126 type=module></script>
10
+ <script src=game.js?166 type=module></script>
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "littlejsengine",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "description": "LittleJS - Tiny and Fast HTML5 Game Engine",
5
- "main": "engine/engine.all.module.js",
5
+ "main": "build/littlejs.esm.js",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/KilledByAPixel/LittleJS.git"
package/src/engine.js CHANGED
@@ -1,24 +1,20 @@
1
- /*
2
- LittleJS - The Tiny JavaScript Game Engine That Can!
3
- MIT License - Copyright 2021 Frank Force
4
-
5
- Engine Features
6
- - Object oriented system with base class engine object
7
- - Base class object handles update, physics, collision, rendering, etc
8
- - Engine helper classes and functions like Vector2, Color, and Timer
9
- - Super fast rendering system for tile sheets
10
- - Sound effects audio with zzfx and music with zzfxm
11
- - Input processing system with gamepad and touchscreen support
12
- - Tile layer rendering and collision system
13
- - Particle effect system
14
- - Medal system tracks and displays achievements
15
- - Debug tools and debug rendering system
16
- - Post processing effects
17
- - Call engineInit() to start it up!
18
- */
19
-
20
- /**
21
- * LittleJS Engine Globals
1
+ /**
2
+ * LittleJS - The Tiny JavaScript Game Engine That Can!
3
+ * MIT License - Copyright 2021 Frank Force
4
+ *
5
+ * Engine Features
6
+ * - Object oriented system with base class engine object
7
+ * - Base class object handles update, physics, collision, rendering, etc
8
+ * - Engine helper classes and functions like Vector2, Color, and Timer
9
+ * - Super fast rendering system for tile sheets
10
+ * - Sound effects audio with zzfx and music with zzfxm
11
+ * - Input processing system with gamepad and touchscreen support
12
+ * - Tile layer rendering and collision system
13
+ * - Particle effect system
14
+ * - Medal system tracks and displays achievements
15
+ * - Debug tools and debug rendering system
16
+ * - Post processing effects
17
+ * - Call engineInit() to start it up!
22
18
  * @namespace Engine
23
19
  */
24
20
 
@@ -34,7 +30,7 @@ const engineName = 'LittleJS';
34
30
  * @type {String}
35
31
  * @default
36
32
  * @memberof Engine */
37
- const engineVersion = '1.6.4';
33
+ const engineVersion = '1.6.6';
38
34
 
39
35
  /** Frames per second to update objects
40
36
  * @type {Number}
@@ -104,10 +100,11 @@ function engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRender
104
100
  debug && (tileImage.onload=()=>ASSERT(1)); // tile sheet can not reloaded
105
101
 
106
102
  // setup html
107
- const styleBody = 'margin:0;overflow:hidden;background:#000' + // fill the window
108
- ';touch-action:none' + // prevent mobile pinch to resize
109
- ';user-select:none' + // prevent mobile hold to select
110
- ';-webkit-user-select:none'; // compatibility for ios
103
+ const styleBody = 'margin:0;overflow:hidden;' + // fill the window
104
+ 'background:#000;' + // set background color
105
+ 'touch-action:none;' + // prevent mobile pinch to resize
106
+ 'user-select:none;' + // prevent mobile hold to select
107
+ '-webkit-user-select:none'; // compatibility for ios
111
108
  document.body.style = styleBody;
112
109
  document.body.appendChild(mainCanvas = document.createElement('canvas'));
113
110
  mainContext = mainCanvas.getContext('2d');
@@ -120,8 +117,10 @@ function engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRender
120
117
  document.body.appendChild(overlayCanvas = document.createElement('canvas'));
121
118
  overlayContext = overlayCanvas.getContext('2d');
122
119
 
123
- // set canvas style to fill the window
124
- const styleCanvas = 'position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)';
120
+ // set canvas style
121
+ const styleCanvas = 'position:absolute;' +
122
+ 'top:50%;left:50%;transform:translate(-50%,-50%);' + // center the canvas
123
+ (canvasPixelated?'image-rendering:pixelated':''); // set pixelated rendering
125
124
  (glCanvas||mainCanvas).style = mainCanvas.style = overlayCanvas.style = styleCanvas;
126
125
 
127
126
  gameInit();
@@ -254,7 +253,7 @@ function enginePreRender()
254
253
  mainCanvasSize = vec2(mainCanvas.width, mainCanvas.height);
255
254
 
256
255
  // disable smoothing for pixel art
257
- mainContext.imageSmoothingEnabled = !cavasPixelated;
256
+ mainContext.imageSmoothingEnabled = !canvasPixelated;
258
257
 
259
258
  // setup gl rendering if enabled
260
259
  glEnable && glPreRender();
@@ -268,7 +267,7 @@ function engineObjectsUpdate()
268
267
  engineObjectsCollide = engineObjects.filter(o=>o.collideSolidObjects);
269
268
 
270
269
  // recursive object update
271
- const updateObject = (o)=>
270
+ function updateObject(o)
272
271
  {
273
272
  if (!o.destroyed)
274
273
  {
@@ -1,19 +1,20 @@
1
1
  /**
2
2
  * LittleJS Audio System
3
- * <br> - <a href=https://killedbyapixel.github.io/ZzFX/>ZzFX Sound Effects</a>
4
- * <br> - <a href=https://keithclark.github.io/ZzFXM/>ZzFXM Music</a>
5
- * <br> - Caches sounds and music for fast playback
6
- * <br> - Can attenuate and apply stereo panning to sounds
7
- * <br> - Ability to play mp3, ogg, and wave files
8
- * <br> - Speech synthesis wrapper functions
3
+ * - <a href=https://killedbyapixel.github.io/ZzFX/>ZzFX Sound Effects</a> - Sound Effect Generator
4
+ * - <a href=https://keithclark.github.io/ZzFXM/>ZzFXM Music</a> - Music System
5
+ * - Caches sounds and music for fast playback
6
+ * - Can attenuate and apply stereo panning to sounds
7
+ * - Ability to play mp3, ogg, and wave files
8
+ * - Speech synthesis wrapper functions
9
+ * @namespace Audio
9
10
  */
10
11
 
11
12
  'use strict';
12
13
 
13
14
  /**
14
15
  * Sound Object - Stores a zzfx sound for later use and can be played positionally
15
- * <br>
16
- * <br><b><a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a></b>
16
+ *
17
+ * <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
17
18
  * @example
18
19
  * // create a sound
19
20
  * const sound_example = new Sound([.5,.5]);
@@ -97,8 +98,8 @@ class Sound
97
98
 
98
99
  /**
99
100
  * Music Object - Stores a zzfx music track for later use
100
- * <br>
101
- * <br><b><a href=https://keithclark.github.io/ZzFXM/>Create music with the ZzFXM tracker.</a></b>
101
+ *
102
+ * <a href=https://keithclark.github.io/ZzFXM/>Create music with the ZzFXM tracker.</a>
102
103
  * @example
103
104
  * // create some music
104
105
  * const music_example = new Music(
@@ -208,14 +209,15 @@ function speak(text, language='', volume=1, rate=1, pitch=1)
208
209
 
209
210
  /** Stop all queued speech
210
211
  * @memberof Audio */
211
- const speakStop = ()=> speechSynthesis && speechSynthesis.cancel();
212
+ function speakStop() {speechSynthesis && speechSynthesis.cancel();}
212
213
 
213
214
  /** Get frequency of a note on a musical scale
214
215
  * @param {Number} semitoneOffset - How many semitones away from the root note
215
216
  * @param {Number} [rootNoteFrequency=220] - Frequency at semitone offset 0
216
217
  * @return {Number} - The frequency of the note
217
218
  * @memberof Audio */
218
- const getNoteFrequency = (semitoneOffset, rootFrequency=220)=> rootFrequency * 2**(semitoneOffset/12);
219
+ function getNoteFrequency(semitoneOffset, rootFrequency=220)
220
+ { return rootFrequency * 2**(semitoneOffset/12); }
219
221
 
220
222
  ///////////////////////////////////////////////////////////////////////////////
221
223
 
@@ -273,12 +275,12 @@ function playSamples(sampleChannels, volume=1, rate=1, pan=0, loop=0)
273
275
  // ZzFXMicro - Zuper Zmall Zound Zynth - v1.2.0 by Frank Force
274
276
 
275
277
  /** Generate and play a ZzFX sound
276
- * <br>
277
- * <br><b><a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a></b>
278
+ *
279
+ * <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
278
280
  * @param {Array} zzfxSound - Array of ZzFX parameters, ex. [.5,.5]
279
- * @return {Array} - Array of audio samples
281
+ * @return {AudioBufferSourceNode} - The audio node of the sound played
280
282
  * @memberof Audio */
281
- const zzfx = (...zzfxSound) => playSamples([zzfxG(...zzfxSound)]);
283
+ function zzfx(...zzfxSound) { return playSamples([zzfxG(...zzfxSound)]); }
282
284
 
283
285
  /** Sample rate used for all ZzFX sounds
284
286
  * @default 44100
@@ -286,7 +288,29 @@ const zzfx = (...zzfxSound) => playSamples([zzfxG(...zzfxSound)]);
286
288
  const zzfxR = 44100;
287
289
 
288
290
  /** Generate samples for a ZzFX sound
289
- * @memberof Audio */
291
+ * @param {Number} [volume=1] - Volume scale (percent)
292
+ * @param {Number} [randomness=.05] - How much to randomize frequency (percent Hz)
293
+ * @param {Number} [frequency=220] - Frequency of sound (Hz)
294
+ * @param {Number} [attack=0] - Attack time, how fast sound starts (seconds)
295
+ * @param {Number} [sustain=0] - Sustain time, how long sound holds (seconds)
296
+ * @param {Number} [release=.1] - Release time, how fast sound fades out (seconds)
297
+ * @param {Number} [shape=0] - Shape of the sound wave
298
+ * @param {Number} [shapeCurve=1] - Squarenes of wave (0=square, 1=normal, 2=pointy)
299
+ * @param {Number} [slide=0] - How much to slide frequency (kHz/s)
300
+ * @param {Number} [deltaSlide=0] - How much to change slide (kHz/s/s)
301
+ * @param {Number} [pitchJump=0] - Frequency of pitch jump (Hz)
302
+ * @param {Number} [pitchJumpTime=0] - Time of pitch jump (seconds)
303
+ * @param {Number} [repeatTime=0] - Resets some parameters periodically (seconds)
304
+ * @param {Number} [noise=0] - How much random noise to add (percent)
305
+ * @param {Number} [modulation=0] - Frequency of modulation wave, negative flips phase (Hz)
306
+ * @param {Number} [bitCrush=0] - Resamples at a lower frequency in (samples*100)
307
+ * @param {Number} [delay=0] - Overlap sound with itself for reverb and flanger effects (seconds)
308
+ * @param {Number} [sustainVolume=1] - Volume level for sustain (percent)
309
+ * @param {Number} [decay=0] - Decay time, how long to reach sustain after attack (seconds)
310
+ * @param {Number} [tremolo=0] - Trembling effect, rate controlled by repeat time (precent)
311
+ * @return {Array} - Array of audio samples
312
+ * @memberof Audio
313
+ */
290
314
  function zzfxG
291
315
  (
292
316
  // parameters
@@ -376,7 +400,7 @@ function zzfxG
376
400
  * @param {Array} patterns - Array of pattern data
377
401
  * @param {Array} sequence - Array of pattern indexes
378
402
  * @param {Number} [BPM=125] - Playback speed of the song in BPM
379
- * @returns {Array} - Left and right channel sample data
403
+ * @return {Array} - Left and right channel sample data
380
404
  * @memberof Audio */
381
405
  function zzfxM(instruments, patterns, sequence, BPM = 125)
382
406
  {
@@ -1,15 +1,10 @@
1
- /*
2
- LittleJS - Debug Build
3
- MIT License - Copyright 2021 Frank Force
4
- */
5
-
6
1
  /**
7
2
  * LittleJS Debug System
8
- * <br> - Press ~ to show debug overlay with mouse pick
9
- * <br> - Number keys toggle debug functions
10
- * <br> - +/- apply time scale
11
- * <br> - Debug primitive rendering
12
- * <br> - Save a 2d canvas as an image
3
+ * - Press ~ to show debug overlay with mouse pick
4
+ * - Number keys toggle debug functions
5
+ * - +/- apply time scale
6
+ * - Debug primitive rendering
7
+ * - Save a 2d canvas as an image
13
8
  * @namespace Debug
14
9
  */
15
10
 
@@ -62,7 +57,7 @@ debugParticles = 0, debugGamepads = 0, debugMedals = 0, debugTakeScreenshot, dow
62
57
  * @param {Boolean} assertion
63
58
  * @param {Object} output
64
59
  * @memberof Debug */
65
- const ASSERT = enableAsserts ? (...assert)=> console.assert(...assert) : ()=>{};
60
+ function ASSERT(...assert) { enableAsserts && console.assert(...assert); }
66
61
 
67
62
  /** Draw a debug rectangle in world space
68
63
  * @param {Vector2} pos
@@ -72,7 +67,7 @@ const ASSERT = enableAsserts ? (...assert)=> console.assert(...assert) : ()=>{};
72
67
  * @param {Number} [angle=0]
73
68
  * @param {Boolean} [fill=false]
74
69
  * @memberof Debug */
75
- const debugRect = (pos, size=vec2(), color='#fff', time=0, angle=0, fill=false)=>
70
+ function debugRect(pos, size=vec2(), color='#fff', time=0, angle=0, fill=false)
76
71
  {
77
72
  ASSERT(typeof color == 'string'); // pass in regular html strings as colors
78
73
  debugPrimitives.push({pos, size:vec2(size), color, time:new Timer(time), angle, fill});
@@ -85,7 +80,7 @@ const debugRect = (pos, size=vec2(), color='#fff', time=0, angle=0, fill=false)=
85
80
  * @param {Number} [time=0]
86
81
  * @param {Boolean} [fill=false]
87
82
  * @memberof Debug */
88
- const debugCircle = (pos, radius=0, color='#fff', time=0, fill=false)=>
83
+ function debugCircle(pos, radius=0, color='#fff', time=0, fill=false)
89
84
  {
90
85
  ASSERT(typeof color == 'string'); // pass in regular html strings as colors
91
86
  debugPrimitives.push({pos, size:radius, color, time:new Timer(time), angle:0, fill});
@@ -97,7 +92,7 @@ const debugCircle = (pos, radius=0, color='#fff', time=0, fill=false)=>
97
92
  * @param {Number} [time=0]
98
93
  * @param {Number} [angle=0]
99
94
  * @memberof Debug */
100
- const debugPoint = (pos, color, time, angle)=> debugRect(pos, 0, color, time, angle);
95
+ function debugPoint(pos, color, time, angle) {debugRect(pos, 0, color, time, angle);}
101
96
 
102
97
  /** Draw a debug line in world space
103
98
  * @param {Vector2} posA
@@ -106,7 +101,7 @@ const debugPoint = (pos, color, time, angle)=> debugRect(pos, 0, color, time, an
106
101
  * @param {Number} [thickness=.1]
107
102
  * @param {Number} [time=0]
108
103
  * @memberof Debug */
109
- const debugLine = (posA, posB, color, thickness=.1, time)=>
104
+ function debugLine(posA, posB, color, thickness=.1, time)
110
105
  {
111
106
  const halfDelta = vec2((posB.x - posA.x)/2, (posB.y - posA.y)/2);
112
107
  const size = vec2(thickness, halfDelta.length()*2);
@@ -120,7 +115,7 @@ const debugLine = (posA, posB, color, thickness=.1, time)=>
120
115
  * @param {Vector2} sizeB
121
116
  * @param {String} [color='#fff']
122
117
  * @memberof Debug */
123
- const debugAABB = (pA, sA, pB, sB, color)=>
118
+ function debugAABB(pA, sA, pB, sB, color)
124
119
  {
125
120
  const minPos = vec2(min(pA.x - sA.x/2, pB.x - sB.x/2), min(pA.y - sA.y/2, pB.y - sB.y/2));
126
121
  const maxPos = vec2(max(pA.x + sA.x/2, pB.x + sB.x/2), max(pA.y + sA.y/2, pB.y + sB.y/2));
@@ -136,7 +131,7 @@ const debugAABB = (pA, sA, pB, sB, color)=>
136
131
  * @param {Number} [angle=0]
137
132
  * @param {String} [font='monospace']
138
133
  * @memberof Debug */
139
- const debugText = (text, pos, size=1, color='#fff', time=0, angle=0, font='monospace')=>
134
+ function debugText(text, pos, size=1, color='#fff', time=0, angle=0, font='monospace')
140
135
  {
141
136
  ASSERT(typeof color == 'string'); // pass in regular html strings as colors
142
137
  debugPrimitives.push({text, pos, size, color, time:new Timer(time), angle, font});
@@ -144,13 +139,13 @@ const debugText = (text, pos, size=1, color='#fff', time=0, angle=0, font='monos
144
139
 
145
140
  /** Clear all debug primitives in the list
146
141
  * @memberof Debug */
147
- const debugClear = ()=> debugPrimitives = [];
142
+ function debugClear() { debugPrimitives = []; }
148
143
 
149
144
  /** Save a canvas to disk
150
145
  * @param {HTMLCanvasElement} canvas
151
146
  * @param {String} [filename]
152
147
  * @memberof Debug */
153
- const debugSaveCanvas = (canvas, filename = engineName + '.png') =>
148
+ function debugSaveCanvas(canvas, filename = engineName + '.png')
154
149
  {
155
150
  downloadLink.download = 'screenshot.png';
156
151
  downloadLink.href = canvas.toDataURL('image/png').replace('image/png','image/octet-stream');
@@ -160,14 +155,14 @@ const debugSaveCanvas = (canvas, filename = engineName + '.png') =>
160
155
  ///////////////////////////////////////////////////////////////////////////////
161
156
  // Engine debug function (called automatically)
162
157
 
163
- const debugInit = ()=>
158
+ function debugInit()
164
159
  {
165
160
  // create link for saving screenshots
166
161
  document.body.appendChild(downloadLink = document.createElement('a'));
167
162
  downloadLink.style.display = 'none';
168
163
  }
169
164
 
170
- const debugUpdate = ()=>
165
+ function debugUpdate()
171
166
  {
172
167
  if (!debug)
173
168
  return;
@@ -195,7 +190,7 @@ const debugUpdate = ()=>
195
190
  }
196
191
  }
197
192
 
198
- const debugRender = ()=>
193
+ function debugRender()
199
194
  {
200
195
  glCopyToContext(mainContext);
201
196
 
package/src/engineDraw.js CHANGED
@@ -1,22 +1,22 @@
1
1
  /**
2
2
  * LittleJS Drawing System
3
- * <br> - Hybrid with both Canvas2D and WebGL available
4
- * <br> - Super fast tile sheet rendering with WebGL
5
- * <br> - Can apply rotation, mirror, color and additive color
6
- * <br> - Many useful utility functions
7
- * <br>
8
- * <br>LittleJS uses a hybrid rendering solution with the best of both Canvas2D and WebGL.
9
- * <br>There are 3 canvas/contexts available to draw to...
10
- * <br> - mainCanvas - 2D background canvas, non WebGL stuff like tile layers are drawn here.
11
- * <br> - glCanvas - Used by the accelerated WebGL batch rendering system.
12
- * <br> - overlayCanvas - Another 2D canvas that appears on top of the other 2 canvases.
13
- * <br>
14
- * <br>The WebGL rendering system is very fast with some caveats...
15
- * <br> - The default setup supports only 1 tile sheet, to support more call glCreateTexture and glSetTexture
16
- * <br> - Switching blend modes (additive) or textures causes another draw call which is expensive in excess
17
- * <br> - Group additive rendering together using renderOrder to mitigate this issue
18
- * <br>
19
- * <br>The LittleJS rendering solution is intentionally simple, feel free to adjust it for your needs!
3
+ * - Hybrid with both Canvas2D and WebGL available
4
+ * - Super fast tile sheet rendering with WebGL
5
+ * - Can apply rotation, mirror, color and additive color
6
+ * - Many useful utility functions
7
+ *
8
+ * LittleJS uses a hybrid rendering solution with the best of both Canvas2D and WebGL.
9
+ * There are 3 canvas/contexts available to draw to...
10
+ * mainCanvas - 2D background canvas, non WebGL stuff like tile layers are drawn here.
11
+ * glCanvas - Used by the accelerated WebGL batch rendering system.
12
+ * overlayCanvas - Another 2D canvas that appears on top of the other 2 canvases.
13
+ *
14
+ * The WebGL rendering system is very fast with some caveats...
15
+ * - The default setup supports only 1 tile sheet, to support more call glCreateTexture and glSetTexture
16
+ * - Switching blend modes (additive) or textures causes another draw call which is expensive in excess
17
+ * - Group additive rendering together using renderOrder to mitigate this issue
18
+ *
19
+ * The LittleJS rendering solution is intentionally simple, feel free to adjust it for your needs!
20
20
  * @namespace Draw
21
21
  */
22
22
 
@@ -60,7 +60,7 @@ let tileImageSize, tileImageFixBleed, drawCount;
60
60
  * @param {Vector2} screenPos
61
61
  * @return {Vector2}
62
62
  * @memberof Draw */
63
- const screenToWorld = (screenPos)=>
63
+ function screenToWorld(screenPos)
64
64
  {
65
65
  ASSERT(mainCanvasSize.x && mainCanvasSize.y, 'mainCanvasSize is invalid');
66
66
  return screenPos.add(vec2(.5)).subtract(mainCanvasSize.scale(.5)).multiply(vec2(1/cameraScale,-1/cameraScale)).add(cameraPos);
@@ -71,7 +71,7 @@ const screenToWorld = (screenPos)=>
71
71
  * @param {Vector2} worldPos
72
72
  * @return {Vector2}
73
73
  * @memberof Draw */
74
- const worldToScreen = (worldPos)=>
74
+ function worldToScreen(worldPos)
75
75
  {
76
76
  ASSERT(mainCanvasSize.x && mainCanvasSize.y, 'mainCanvasSize is invalid');
77
77
  return worldPos.subtract(cameraPos).multiply(vec2(cameraScale,-cameraScale)).add(mainCanvasSize.scale(.5)).subtract(vec2(.5));
@@ -280,9 +280,9 @@ let engineFontImage;
280
280
 
281
281
  /**
282
282
  * Font Image Object - Draw text on a 2D canvas by using characters in an image
283
- * <br> - 96 characters (from space to tilde) are stored in an image
284
- * <br> - Uses a default 8x8 font if none is supplied
285
- * <br> - You can also use fonts from the main tile sheet
283
+ * - 96 characters (from space to tilde) are stored in an image
284
+ * - Uses a default 8x8 font if none is supplied
285
+ * - You can also use fonts from the main tile sheet
286
286
  * @example
287
287
  * // use built in font
288
288
  * const font = new ImageFont;
@@ -322,7 +322,7 @@ class FontImage
322
322
  {
323
323
  const context = this.context;
324
324
  context.save();
325
- context.imageSmoothingEnabled = !cavasPixelated;
325
+ context.imageSmoothingEnabled = !canvasPixelated;
326
326
 
327
327
  const size = this.tileSize;
328
328
  const drawSize = size.add(this.paddingSize).scale(scale);
@@ -368,7 +368,7 @@ class FontImage
368
368
  /** Returns true if fullscreen mode is active
369
369
  * @return {Boolean}
370
370
  * @memberof Draw */
371
- const isFullscreen = ()=> document.fullscreenElement;
371
+ function isFullscreen() { return document.fullscreenElement; }
372
372
 
373
373
  /** Toggle fullsceen mode
374
374
  * @memberof Draw */