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.
- package/README.md +13 -9
- package/build/littlejs.d.ts +92 -88
- package/build/littlejs.esm.js +312 -251
- package/build/littlejs.esm.min.js +1 -1
- package/build/littlejs.js +270 -206
- package/build/littlejs.min.js +1 -1
- package/build/littlejs.release.js +271 -203
- package/examples/breakout/index.html +3 -3
- package/examples/breakoutTutorial/index.html +2 -2
- package/examples/favicon.png +0 -0
- package/examples/module/index.html +1 -1
- package/examples/particles/index.html +1 -1
- package/examples/platformer/index.html +6 -6
- package/examples/puzzle/game.js +1 -1
- package/examples/puzzle/index.html +2 -2
- package/examples/starter/index.html +13 -13
- package/examples/stress/index.html +1 -1
- package/examples/typescript/index.html +1 -1
- package/package.json +2 -2
- package/src/engine.js +29 -30
- package/src/engineAudio.js +42 -18
- package/src/engineDebug.js +17 -22
- package/src/engineDraw.js +24 -24
- package/src/engineExport.js +42 -45
- package/src/engineInput.js +32 -19
- package/src/engineMedals.js +31 -8
- package/src/engineObject.js +21 -21
- package/src/engineParticles.js +3 -6
- package/src/engineRelease.js +18 -19
- package/src/engineSettings.js +4 -4
- package/src/engineTileLayer.js +18 -14
- package/src/engineUtilities.js +41 -32
- package/src/engineWebGL.js +8 -8
package/src/engineExport.js
CHANGED
|
@@ -1,205 +1,202 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LittleJS Module Export
|
|
3
|
-
*
|
|
3
|
+
* - Export engine as a module with extra functions where necessary
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
// Setters for all variables that devs will need to modify
|
|
7
|
-
|
|
8
|
-
|
|
9
6
|
/** Set position of camera in world space
|
|
10
7
|
* @param {Vector2} pos
|
|
11
8
|
* @memberof Settings */
|
|
12
|
-
|
|
9
|
+
function setCameraPos(pos) { cameraPos = pos; }
|
|
13
10
|
|
|
14
11
|
/** Set scale of camera in world space
|
|
15
12
|
* @param {Number} scale
|
|
16
13
|
* @memberof Settings */
|
|
17
|
-
|
|
14
|
+
function setCameraScale(scale) { cameraScale = scale; }
|
|
18
15
|
|
|
19
16
|
/** Set max size of the canvas
|
|
20
17
|
* @param {Vector2} size
|
|
21
18
|
* @memberof Settings */
|
|
22
|
-
|
|
19
|
+
function setCanvasMaxSize(size) { canvasMaxSize = size; }
|
|
23
20
|
|
|
24
21
|
/** Set fixed size of the canvas
|
|
25
22
|
* @param {Vector2} size
|
|
26
23
|
* @memberof Settings */
|
|
27
|
-
|
|
24
|
+
function setCanvasFixedSize(size) { canvasFixedSize = size; }
|
|
28
25
|
|
|
29
26
|
/** Disables anti aliasing for pixel art if true
|
|
30
27
|
* @param {Boolean} pixelated
|
|
31
28
|
* @memberof Settings */
|
|
32
|
-
|
|
29
|
+
function setCanvasPixelated(pixelated) { canvasPixelated = pixelated; }
|
|
33
30
|
|
|
34
31
|
/** Set default font used for text rendering
|
|
35
32
|
* @param {String} font
|
|
36
33
|
* @memberof Settings */
|
|
37
|
-
|
|
34
|
+
function setFontDefault(font) { fontDefault = font; }
|
|
38
35
|
|
|
39
36
|
/** Set if webgl rendering is enabled
|
|
40
37
|
* @param {Boolean} enable
|
|
41
38
|
* @memberof Settings */
|
|
42
|
-
|
|
39
|
+
function setGlEnable(enable) { glEnable = enable; }
|
|
43
40
|
|
|
44
41
|
/** Set to not composite the WebGL canvas
|
|
45
42
|
* @param {Boolean} overlay
|
|
46
43
|
* @memberof Settings */
|
|
47
|
-
|
|
44
|
+
function setGlOverlay(overlay) { glOverlay = overlay; }
|
|
48
45
|
|
|
49
46
|
/** Set default size of tiles in pixels
|
|
50
47
|
* @param {Vector2} size
|
|
51
48
|
* @memberof Settings */
|
|
52
|
-
|
|
49
|
+
function setTileSizeDefault(size) { tileSizeDefault = size; }
|
|
53
50
|
|
|
54
51
|
/** Set to prevent tile bleeding from neighbors in pixels
|
|
55
52
|
* @param {Number} scale
|
|
56
53
|
* @memberof Settings */
|
|
57
|
-
|
|
54
|
+
function setTileFixBleedScale(scale) { tileFixBleedScale = scale; }
|
|
58
55
|
|
|
59
56
|
/** Set if collisions between objects are enabled
|
|
60
57
|
* @param {Boolean} enable
|
|
61
58
|
* @memberof Settings */
|
|
62
|
-
|
|
59
|
+
function setEnablePhysicsSolver(enable) { enablePhysicsSolver = enable; }
|
|
63
60
|
|
|
64
61
|
/** Set default object mass for collison calcuations
|
|
65
62
|
* @param {Number} mass
|
|
66
63
|
* @memberof Settings */
|
|
67
|
-
|
|
64
|
+
function setObjectDefaultMass(mass) { objectDefaultMass = mass; }
|
|
68
65
|
|
|
69
66
|
/** Set how much to slow velocity by each frame
|
|
70
67
|
* @param {Number} damping
|
|
71
68
|
* @memberof Settings */
|
|
72
|
-
|
|
69
|
+
function setObjectDefaultDamping(damp) { objectDefaultDamping = damp; }
|
|
73
70
|
|
|
74
71
|
/** Set how much to slow angular velocity each frame
|
|
75
72
|
* @param {Number} damping
|
|
76
73
|
* @memberof Settings */
|
|
77
|
-
|
|
74
|
+
function setObjectDefaultAngleDamping(damp) { objectDefaultAngleDamping = damp; }
|
|
78
75
|
|
|
79
76
|
/** Set how much to bounce when a collision occur
|
|
80
77
|
* @param {Number} elasticity
|
|
81
78
|
* @memberof Settings */
|
|
82
|
-
|
|
79
|
+
function setObjectDefaultElasticity(elasticity) { objectDefaultElasticity = elasticity; }
|
|
83
80
|
|
|
84
81
|
/** Set how much to slow when touching
|
|
85
82
|
* @param {Number} friction
|
|
86
83
|
* @memberof Settings */
|
|
87
|
-
|
|
84
|
+
function setObjectDefaultFriction(friction) { objectDefaultFriction = friction; }
|
|
88
85
|
|
|
89
86
|
/** Set max speed to avoid fast objects missing collisions
|
|
90
87
|
* @param {Number} speed
|
|
91
88
|
* @memberof Settings */
|
|
92
|
-
|
|
89
|
+
function setObjectMaxSpeed(speed) { objectMaxSpeed = speed; }
|
|
93
90
|
|
|
94
91
|
/** Set how much gravity to apply to objects along the Y axis
|
|
95
92
|
* @param {Number} gravity
|
|
96
93
|
* @memberof Settings */
|
|
97
|
-
|
|
94
|
+
function setGravity(g) { gravity = g; }
|
|
98
95
|
|
|
99
96
|
/** Set to scales emit rate of particles
|
|
100
97
|
* @param {Number} scale
|
|
101
98
|
* @memberof Settings */
|
|
102
|
-
|
|
99
|
+
function setParticleEmitRateScale(scale) { particleEmitRateScale = scale; }
|
|
103
100
|
|
|
104
101
|
/** Set if gamepads are enabled
|
|
105
102
|
* @param {Boolean} enable
|
|
106
103
|
* @memberof Settings */
|
|
107
|
-
|
|
104
|
+
function setGamepadsEnable(enable) { gamepadsEnable = enable; }
|
|
108
105
|
|
|
109
106
|
/** Set if the dpad input is also routed to the left analog stick
|
|
110
107
|
* @param {Boolean} enable
|
|
111
108
|
* @memberof Settings */
|
|
112
|
-
|
|
109
|
+
function setGamepadDirectionEmulateStick(enable) { gamepadDirectionEmulateStick = enable; }
|
|
113
110
|
|
|
114
111
|
/** Set if true the WASD keys are also routed to the direction keys
|
|
115
112
|
* @param {Boolean} enable
|
|
116
113
|
* @memberof Settings */
|
|
117
|
-
|
|
114
|
+
function setInputWASDEmulateDirection(enable) { inputWASDEmulateDirection = enable; }
|
|
118
115
|
|
|
119
116
|
/** Set if touch gamepad should appear on mobile devices
|
|
120
117
|
* @param {Boolean} enable
|
|
121
118
|
* @memberof Settings */
|
|
122
|
-
|
|
119
|
+
function setTouchGamepadEnable(enable) { touchGamepadEnable = enable; }
|
|
123
120
|
|
|
124
121
|
/** Set if touch gamepad should be analog stick or 8 way dpad
|
|
125
122
|
* @param {Boolean} analog
|
|
126
123
|
* @memberof Settings */
|
|
127
|
-
|
|
124
|
+
function setTouchGamepadAnalog(analog) { touchGamepadAnalog = analog; }
|
|
128
125
|
|
|
129
126
|
/** Set size of virutal gamepad for touch devices in pixels
|
|
130
127
|
* @param {Number} size
|
|
131
128
|
* @memberof Settings */
|
|
132
|
-
|
|
129
|
+
function setTouchGamepadSize(size) { touchGamepadSize = size; }
|
|
133
130
|
|
|
134
131
|
/** Set transparency of touch gamepad overlay
|
|
135
132
|
* @param {Number} alpha
|
|
136
133
|
* @memberof Settings */
|
|
137
|
-
|
|
134
|
+
function setTouchGamepadAlpha(alpha) { touchGamepadAlpha = alpha; }
|
|
138
135
|
|
|
139
136
|
/** Set to allow vibration hardware if it exists
|
|
140
137
|
* @param {Boolean} enable
|
|
141
138
|
* @memberof Settings */
|
|
142
|
-
|
|
139
|
+
function setVibrateEnable(enable) { vibrateEnable = enable; }
|
|
143
140
|
|
|
144
141
|
/** Set to disable all audio code
|
|
145
142
|
* @param {Boolean} enable
|
|
146
143
|
* @memberof Settings */
|
|
147
|
-
|
|
144
|
+
function setSoundEnable(enable) { soundEnable = enable; }
|
|
148
145
|
|
|
149
146
|
/** Set volume scale to apply to all sound, music and speech
|
|
150
147
|
* @param {Number} volume
|
|
151
148
|
* @memberof Settings */
|
|
152
|
-
|
|
149
|
+
function setSoundVolume(volume) { soundVolume = volume; }
|
|
153
150
|
|
|
154
151
|
/** Set default range where sound no longer plays
|
|
155
152
|
* @param {Number} range
|
|
156
153
|
* @memberof Settings */
|
|
157
|
-
|
|
154
|
+
function setSoundDefaultRange(range) { soundDefaultRange = range; }
|
|
158
155
|
|
|
159
156
|
/** Set default range percent to start tapering off sound
|
|
160
157
|
* @param {Number} taper
|
|
161
158
|
* @memberof Settings */
|
|
162
|
-
|
|
159
|
+
function setSoundDefaultTaper(taper) { soundDefaultTaper = taper; }
|
|
163
160
|
|
|
164
161
|
/** Set how long to show medals for in seconds
|
|
165
162
|
* @param {Number} time
|
|
166
163
|
* @memberof Settings */
|
|
167
|
-
|
|
164
|
+
function setMedalDisplayTime(time) { medalDisplayTime = time; }
|
|
168
165
|
|
|
169
166
|
/** Set how quickly to slide on/off medals in seconds
|
|
170
167
|
* @param {Number} time
|
|
171
168
|
* @memberof Settings */
|
|
172
|
-
|
|
169
|
+
function setMedalDisplaySlideTime(time) { medalDisplaySlideTime = time; }
|
|
173
170
|
|
|
174
171
|
/** Set size of medal display
|
|
175
172
|
* @param {Vector2} size
|
|
176
173
|
* @memberof Settings */
|
|
177
|
-
|
|
174
|
+
function setMedalDisplaySize(size) { medalDisplaySize = size; }
|
|
178
175
|
|
|
179
176
|
/** Set size of icon in medal display
|
|
180
177
|
* @param {Number} size
|
|
181
178
|
* @memberof Settings */
|
|
182
|
-
|
|
179
|
+
function setMedalDisplayIconSize(size) { medalDisplayIconSize = size; }
|
|
183
180
|
|
|
184
181
|
/** Set to stop medals from being unlockable
|
|
185
182
|
* @param {Boolean} preventUnlock
|
|
186
183
|
* @memberof Settings */
|
|
187
|
-
|
|
184
|
+
function setMedalsPreventUnlock(prevent) { medalsPreventUnlock = prevent; }
|
|
188
185
|
|
|
189
186
|
/** Set if watermark with FPS should be shown
|
|
190
187
|
* @param {Boolean} show
|
|
191
188
|
* @memberof Debug */
|
|
192
|
-
|
|
189
|
+
function setShowWatermark(show) { showWatermark = show; }
|
|
193
190
|
|
|
194
191
|
/** Set if god mode is enabled
|
|
195
192
|
* @param {Boolean} enable
|
|
196
193
|
* @memberof Debug */
|
|
197
|
-
|
|
194
|
+
function setGodMode(enable) { godMode = enable; }
|
|
198
195
|
|
|
199
196
|
/** Set key code used to toggle debug mode, Esc by default
|
|
200
197
|
* @param {Number} key
|
|
201
198
|
* @memberof Debug */
|
|
202
|
-
|
|
199
|
+
function setDebugKey(key) { debugKey = key; }
|
|
203
200
|
|
|
204
201
|
export {
|
|
205
202
|
// Setters for global variables
|
|
@@ -207,7 +204,7 @@ export {
|
|
|
207
204
|
setCameraScale,
|
|
208
205
|
setCanvasMaxSize,
|
|
209
206
|
setCanvasFixedSize,
|
|
210
|
-
|
|
207
|
+
setCanvasPixelated,
|
|
211
208
|
setFontDefault,
|
|
212
209
|
setGlEnable,
|
|
213
210
|
setGlOverlay,
|
|
@@ -246,7 +243,7 @@ export {
|
|
|
246
243
|
// Settings
|
|
247
244
|
canvasMaxSize,
|
|
248
245
|
canvasFixedSize,
|
|
249
|
-
|
|
246
|
+
canvasPixelated,
|
|
250
247
|
fontDefault,
|
|
251
248
|
tileSizeDefault,
|
|
252
249
|
tileFixBleedScale,
|
package/src/engineInput.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LittleJS Input System
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* - Tracks key down, pressed, and released
|
|
4
|
+
* - Also tracks mouse buttons, position, and wheel
|
|
5
|
+
* - Supports multiple gamepads
|
|
6
|
+
* - Virtual gamepad for touch devices with touchGamepadSize
|
|
7
7
|
* @namespace Input
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -14,25 +14,28 @@
|
|
|
14
14
|
* @param {Number} [device=0]
|
|
15
15
|
* @return {Boolean}
|
|
16
16
|
* @memberof Input */
|
|
17
|
-
|
|
17
|
+
function keyIsDown(key, device=0)
|
|
18
|
+
{ return inputData[device] && inputData[device][key] & 1; }
|
|
18
19
|
|
|
19
20
|
/** Returns true if device key was pressed this frame
|
|
20
21
|
* @param {Number} key
|
|
21
22
|
* @param {Number} [device=0]
|
|
22
23
|
* @return {Boolean}
|
|
23
24
|
* @memberof Input */
|
|
24
|
-
|
|
25
|
+
function keyWasPressed(key, device=0)
|
|
26
|
+
{ return inputData[device] && inputData[device][key] & 2 ? 1 : 0; }
|
|
25
27
|
|
|
26
28
|
/** Returns true if device key was released this frame
|
|
27
29
|
* @param {Number} key
|
|
28
30
|
* @param {Number} [device=0]
|
|
29
31
|
* @return {Boolean}
|
|
30
32
|
* @memberof Input */
|
|
31
|
-
|
|
33
|
+
function keyWasReleased(key, device=0)
|
|
34
|
+
{ return inputData[device] && inputData[device][key] & 4 ? 1 : 0; }
|
|
32
35
|
|
|
33
36
|
/** Clears all input
|
|
34
37
|
* @memberof Input */
|
|
35
|
-
|
|
38
|
+
function clearInput() { inputData = [[]]; }
|
|
36
39
|
|
|
37
40
|
/** Returns true if mouse button is down
|
|
38
41
|
* @function
|
|
@@ -85,28 +88,32 @@ let preventDefaultInput = 0;
|
|
|
85
88
|
* @param {Number} [gamepad=0]
|
|
86
89
|
* @return {Boolean}
|
|
87
90
|
* @memberof Input */
|
|
88
|
-
|
|
91
|
+
function gamepadIsDown(button, gamepad=0)
|
|
92
|
+
{ return keyIsDown(button, gamepad+1); }
|
|
89
93
|
|
|
90
94
|
/** Returns true if gamepad button was pressed
|
|
91
95
|
* @param {Number} button
|
|
92
96
|
* @param {Number} [gamepad=0]
|
|
93
97
|
* @return {Boolean}
|
|
94
98
|
* @memberof Input */
|
|
95
|
-
|
|
99
|
+
function gamepadWasPressed(button, gamepad=0)
|
|
100
|
+
{ return keyWasPressed(button, gamepad+1); }
|
|
96
101
|
|
|
97
102
|
/** Returns true if gamepad button was released
|
|
98
103
|
* @param {Number} button
|
|
99
104
|
* @param {Number} [gamepad=0]
|
|
100
105
|
* @return {Boolean}
|
|
101
106
|
* @memberof Input */
|
|
102
|
-
|
|
107
|
+
function gamepadWasReleased(button, gamepad=0)
|
|
108
|
+
{ return keyWasReleased(button, gamepad+1); }
|
|
103
109
|
|
|
104
110
|
/** Returns gamepad stick value
|
|
105
111
|
* @param {Number} stick
|
|
106
112
|
* @param {Number} [gamepad=0]
|
|
107
113
|
* @return {Vector2}
|
|
108
114
|
* @memberof Input */
|
|
109
|
-
|
|
115
|
+
function gamepadStick(stick, gamepad=0)
|
|
116
|
+
{ return stickData[gamepad] ? stickData[gamepad][stick] || vec2() : vec2(); }
|
|
110
117
|
|
|
111
118
|
///////////////////////////////////////////////////////////////////////////////
|
|
112
119
|
// Input update called by engine
|
|
@@ -145,12 +152,18 @@ onkeydown = (e)=>
|
|
|
145
152
|
e.repeat || (inputData[isUsingGamepad = 0][remapKey(e.which)] = 3);
|
|
146
153
|
preventDefaultInput && e.preventDefault();
|
|
147
154
|
}
|
|
155
|
+
|
|
148
156
|
onkeyup = (e)=>
|
|
149
157
|
{
|
|
150
158
|
if (debug && e.target != document.body) return;
|
|
151
159
|
inputData[0][remapKey(e.which)] = 4;
|
|
152
160
|
}
|
|
153
|
-
|
|
161
|
+
|
|
162
|
+
function remapKey(c)
|
|
163
|
+
{
|
|
164
|
+
return inputWASDEmulateDirection ?
|
|
165
|
+
c==87?38 : c==83?40 : c==65?37 : c==68?39 : c : c;
|
|
166
|
+
}
|
|
154
167
|
|
|
155
168
|
///////////////////////////////////////////////////////////////////////////////
|
|
156
169
|
// Mouse event handlers
|
|
@@ -159,10 +172,10 @@ onmousedown = (e)=> {inputData[isUsingGamepad = 0][e.button] = 3; onmousemove(e)
|
|
|
159
172
|
onmouseup = (e)=> inputData[0][e.button] = inputData[0][e.button] & 2 | 4;
|
|
160
173
|
onmousemove = (e)=> mousePosScreen = mouseToScreen(e);
|
|
161
174
|
onwheel = (e)=> e.ctrlKey || (mouseWheel = sign(e.deltaY));
|
|
162
|
-
oncontextmenu = (e)=>
|
|
175
|
+
oncontextmenu = (e)=> false; // prevent right click menu
|
|
163
176
|
|
|
164
177
|
// convert a mouse or touch event position to screen space
|
|
165
|
-
|
|
178
|
+
function mouseToScreen(mousePos)
|
|
166
179
|
{
|
|
167
180
|
if (!mainCanvas)
|
|
168
181
|
return vec2(); // fix bug that can occur if user clicks before page loads
|
|
@@ -208,8 +221,7 @@ function gamepadsUpdate()
|
|
|
208
221
|
if (gamepad)
|
|
209
222
|
{
|
|
210
223
|
// read clamp dead zone of analog sticks
|
|
211
|
-
const deadZone = .3, deadZoneMax = .8
|
|
212
|
-
const applyDeadZone = (v)=>
|
|
224
|
+
const deadZone = .3, deadZoneMax = .8, applyDeadZone = (v)=>
|
|
213
225
|
v > deadZone ? percent( v, deadZone, deadZoneMax) :
|
|
214
226
|
v < -deadZone ? -percent(-v, deadZone, deadZoneMax) : 0;
|
|
215
227
|
|
|
@@ -242,11 +254,12 @@ function gamepadsUpdate()
|
|
|
242
254
|
/** Pulse the vibration hardware if it exists
|
|
243
255
|
* @param {Number} [pattern=100] - a single value in miliseconds or vibration interval array
|
|
244
256
|
* @memberof Input */
|
|
245
|
-
|
|
257
|
+
function vibrate(pattern)
|
|
258
|
+
{ vibrateEnable && navigator && navigator.vibrate && navigator.vibrate(pattern); }
|
|
246
259
|
|
|
247
260
|
/** Cancel any ongoing vibration
|
|
248
261
|
* @memberof Input */
|
|
249
|
-
|
|
262
|
+
function vibrateStop() { vibrate(0); }
|
|
250
263
|
|
|
251
264
|
///////////////////////////////////////////////////////////////////////////////
|
|
252
265
|
// Touch input
|
package/src/engineMedals.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LittleJS Medal System
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* - Tracks and displays medals
|
|
4
|
+
* - Saves medals to local storage
|
|
5
|
+
* - Newgrounds integration
|
|
6
6
|
* @namespace Medals
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -19,8 +19,8 @@ let medalsDisplayQueue = [], medalsSaveName, medalsDisplayTimeLast;
|
|
|
19
19
|
///////////////////////////////////////////////////////////////////////////////
|
|
20
20
|
|
|
21
21
|
/** Initialize medals with a save name used for storage
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* - Call this after creating all medals
|
|
23
|
+
* - Checks if medals are unlocked
|
|
24
24
|
* @param {String} saveName
|
|
25
25
|
* @memberof Medals */
|
|
26
26
|
function medalsInit(saveName)
|
|
@@ -290,9 +290,32 @@ class Newgrounds
|
|
|
290
290
|
CryptoJS()
|
|
291
291
|
{
|
|
292
292
|
///////////////////////////////////////////////////////////////////////////////
|
|
293
|
-
// Crypto-JS - https://github.com/brix/crypto-js
|
|
294
|
-
//
|
|
295
|
-
|
|
293
|
+
// Crypto-JS - https://github.com/brix/crypto-js - MIT License
|
|
294
|
+
//
|
|
295
|
+
// [The MIT License (MIT)](http://opensource.org/licenses/MIT)
|
|
296
|
+
//
|
|
297
|
+
// Copyright (c) 2009-2013 Jeff Mott
|
|
298
|
+
// Copyright (c) 2013-2016 Evan Vosberg
|
|
299
|
+
//
|
|
300
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
301
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
302
|
+
// in the Software without restriction, including without limitation the rights
|
|
303
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
304
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
305
|
+
// furnished to do so, subject to the following conditions:
|
|
306
|
+
//
|
|
307
|
+
// The above copyright notice and this permission notice shall be included in
|
|
308
|
+
// all copies or substantial portions of the Software.
|
|
309
|
+
//
|
|
310
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
311
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
312
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
313
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
314
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
315
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
316
|
+
// THE SOFTWARE.
|
|
296
317
|
return eval(Function("[M='GBMGXz^oVYPPKKbB`agTXU|LxPc_ZBcMrZvCr~wyGfWrwk@ATqlqeTp^N?p{we}jIpEnB_sEr`l?YDkDhWhprc|Er|XETG?pTl`e}dIc[_N~}fzRycIfpW{HTolvoPB_FMe_eH~BTMx]yyOhv?biWPCGc]kABencBhgERHGf{OL`Dj`c^sh@canhy[secghiyotcdOWgO{tJIE^JtdGQRNSCrwKYciZOa]Y@tcRATYKzv|sXpboHcbCBf`}SKeXPFM|RiJsSNaIb]QPc[D]Jy_O^XkOVTZep`ONmntLL`Qz~UupHBX_Ia~WX]yTRJIxG`ioZ{fefLJFhdyYo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wyab{nxOF?`HCle}nBZzlTQjkLmoXbXhOtBglFoMz?eqre`HiE@vNwBulglmQjj]DB@pPkPUgA^sjOAUNdSu_`oAzar?n?eMnw{{hYmslYi[TnlJD'",...']charCodeAtUinyxpf',"for(;e<10359;c[e++]=p-=128,A=A?p-A&&A:p==34&&p)for(p=1;p<128;y=f.map((n,x)=>(U=r[n]*2+1,U=Math.log(U/(h-U)),t-=a[x]*U,U/500)),t=~-h/(1+Math.exp(t))|1,i=o%h<t,o=o%h+(i?t:h-t)*(o>>17)-!i*t,f.map((n,x)=>(U=r[n]+=(i*h/2-r[n]<<13)/((C[n]+=C[n]<5)+1/20)>>13,a[x]+=y[x]*(i-t/h))),p=p*2+i)for(f='010202103203210431053105410642065206541'.split(t=0).map((n,x)=>(U=0,[...n].map((n,x)=>(U=U*997+(c[e-n]|0)|0)),h*32-1&U*997+p+!!A*129)*12+x);o<h*32;o=o*64|M.charCodeAt(d++)&63);for(C=String.fromCharCode(...c);r=/[\0-#?@\\\\~]/.exec(C);)with(C.split(r))C=join(shift());return C")([],[],1<<17,[0,0,0,0,0,0,0,0,0,0,0,0],new Uint16Array(51e6).fill(1<<15),new Uint8Array(51e6),0,0,0,0));
|
|
318
|
+
// end of Crypto-JS
|
|
319
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
297
320
|
}
|
|
298
321
|
}
|
package/src/engineObject.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* LittleJS Object System
|
|
3
|
+
*/
|
|
4
4
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* LittleJS Object Base Object Class
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
9
|
+
* - Base object class used by the engine
|
|
10
|
+
* - Automatically adds self to object list
|
|
11
|
+
* - Will be updated and rendered each frame
|
|
12
|
+
* - Renders as a sprite from a tilesheet by default
|
|
13
|
+
* - Can have color and addtive color applied
|
|
14
|
+
* - 2d Physics and collision system
|
|
15
|
+
* - Sorted by renderOrder
|
|
16
|
+
* - Objects can have children attached
|
|
17
|
+
* - Parents are updated before children, and set child transform
|
|
18
|
+
* - Call destroy() to get rid of objects
|
|
19
|
+
*
|
|
20
|
+
* The physics system used by objects is simple and fast with some caveats...
|
|
21
|
+
* - Collision uses the axis aligned size, the object's rotation angle is only for rendering
|
|
22
|
+
* - Objects are guaranteed to not intersect tile collision from physics
|
|
23
|
+
* - If an object starts or is moved inside tile collision, it will not collide with that tile
|
|
24
|
+
* - Collision for objects can be set to be solid to block other objects
|
|
25
|
+
* - Objects may get pushed into overlapping other solid objects, if so they will push away
|
|
26
|
+
* - Solid objects are more performance intensive and should be used sparingly
|
|
27
27
|
* @example
|
|
28
28
|
* // create an engine object, normally you would first extend the class with your own
|
|
29
29
|
* const pos = vec2(2,3);
|
package/src/engineParticles.js
CHANGED
package/src/engineRelease.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* LittleJS - Release Build
|
|
3
|
+
* MIT License - Copyright 2021 Frank Force
|
|
4
|
+
* - This file is used for release builds in place of engineDebug.js
|
|
5
|
+
* - Debug functionality is disabled to reduce size and increase performance
|
|
6
|
+
*/
|
|
8
7
|
|
|
9
8
|
'use strict';
|
|
10
9
|
|
|
@@ -20,15 +19,15 @@ const debugGamepads = 0;
|
|
|
20
19
|
const debugMedals = 0;
|
|
21
20
|
|
|
22
21
|
// debug commands are automatically removed from the final build
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
function ASSERT (){}
|
|
23
|
+
function debugInit (){}
|
|
24
|
+
function debugUpdate (){}
|
|
25
|
+
function debugRender (){}
|
|
26
|
+
function debugRect (){}
|
|
27
|
+
function debugCircle (){}
|
|
28
|
+
function debugPoint (){}
|
|
29
|
+
function debugLine (){}
|
|
30
|
+
function debugAABB (){}
|
|
31
|
+
function debugText (){}
|
|
32
|
+
function debugClear (){}
|
|
33
|
+
function debugSaveCanvas (){}
|
package/src/engineSettings.js
CHANGED
|
@@ -36,11 +36,11 @@ let canvasMaxSize = vec2(1920, 1200);
|
|
|
36
36
|
* @memberof Settings */
|
|
37
37
|
let canvasFixedSize = vec2();
|
|
38
38
|
|
|
39
|
-
/** Disables
|
|
39
|
+
/** Disables filtering for crisper pixel art if true
|
|
40
40
|
* @type {Boolean}
|
|
41
41
|
* @default
|
|
42
42
|
* @memberof Settings */
|
|
43
|
-
let
|
|
43
|
+
let canvasPixelated = 1;
|
|
44
44
|
|
|
45
45
|
/** Default font used for text rendering
|
|
46
46
|
* @type {String}
|
|
@@ -157,8 +157,8 @@ let gamepadDirectionEmulateStick = 1;
|
|
|
157
157
|
let inputWASDEmulateDirection = 1;
|
|
158
158
|
|
|
159
159
|
/** True if touch gamepad should appear on mobile devices
|
|
160
|
-
*
|
|
161
|
-
*
|
|
160
|
+
* - Supports left analog stick, 4 face buttons and start button (button 9)
|
|
161
|
+
* - Must be set by end of gameInit to be activated
|
|
162
162
|
* @type {Boolean}
|
|
163
163
|
* @default 0
|
|
164
164
|
* @memberof Settings */
|