littlejsengine 1.5.0 → 1.5.1
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/engine.all.js +179 -97
- package/engine/engine.all.min.js +1 -1
- package/engine/engine.all.module.js +362 -173
- package/engine/engine.all.module.min.js +1 -1
- package/engine/engine.all.release.js +173 -96
- package/engine/engine.js +47 -16
- package/engine/engineAudio.js +1 -1
- package/engine/engineDebug.js +6 -1
- package/engine/engineDraw.js +24 -26
- package/engine/engineExport.js +183 -76
- package/engine/engineInput.js +6 -1
- package/engine/engineMedals.js +1 -0
- package/engine/engineObject.js +6 -6
- package/engine/engineParticles.js +5 -5
- package/engine/engineSettings.js +46 -20
- package/engine/engineTileLayer.js +13 -12
- package/engine/engineUtilities.js +13 -7
- package/engine/engineWebGL.js +11 -2
- package/engine/index.d.ts +1788 -1615
- package/examples/breakout/game.js +3 -1
- package/examples/breakout/index.html +3 -3
- package/examples/module/index.html +1 -1
- package/examples/particles/index.html +1 -1
- package/examples/platformer/game.js +2 -0
- package/examples/platformer/gameObjects.js +3 -3
- package/examples/platformer/index.html +6 -6
- package/examples/puzzle/index.html +2 -2
- package/examples/stress/index.html +4 -4
- package/examples/typescript/game.js +89 -89
- package/examples/typescript/index.html +1 -1
- package/index.html +13 -13
- package/package.json +6 -6
package/engine/engine.all.js
CHANGED
|
@@ -16,26 +16,31 @@
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
/** True if debug is enabled
|
|
19
|
+
* @type {Boolean}
|
|
19
20
|
* @default
|
|
20
21
|
* @memberof Debug */
|
|
21
22
|
const debug = 1;
|
|
22
23
|
|
|
23
24
|
/** True if asserts are enaled
|
|
25
|
+
* @type {Boolean}
|
|
24
26
|
* @default
|
|
25
27
|
* @memberof Debug */
|
|
26
28
|
const enableAsserts = 1;
|
|
27
29
|
|
|
28
30
|
/** Size to render debug points by default
|
|
31
|
+
* @type {Number}
|
|
29
32
|
* @default
|
|
30
33
|
* @memberof Debug */
|
|
31
34
|
const debugPointSize = .5;
|
|
32
35
|
|
|
33
36
|
/** True if watermark with FPS should be down, false in release builds
|
|
37
|
+
* @type {Boolean}
|
|
34
38
|
* @default
|
|
35
39
|
* @memberof Debug */
|
|
36
40
|
let showWatermark = 1;
|
|
37
41
|
|
|
38
42
|
/** True if god mode is enabled, handle this however you want
|
|
43
|
+
* @type {Boolean}
|
|
39
44
|
* @default
|
|
40
45
|
* @memberof Debug */
|
|
41
46
|
let godMode = 0;
|
|
@@ -55,7 +60,7 @@ const ASSERT = enableAsserts ? (...assert)=> console.assert(...assert) : ()=>{};
|
|
|
55
60
|
|
|
56
61
|
/** Draw a debug rectangle in world space
|
|
57
62
|
* @param {Vector2} pos
|
|
58
|
-
* @param {Vector2} [size=
|
|
63
|
+
* @param {Vector2} [size=Vector2()]
|
|
59
64
|
* @param {String} [color='#fff']
|
|
60
65
|
* @param {Number} [time=0]
|
|
61
66
|
* @param {Number} [angle=0]
|
|
@@ -398,7 +403,8 @@ const debugRender = ()=>
|
|
|
398
403
|
'use strict';
|
|
399
404
|
|
|
400
405
|
/** A shortcut to get Math.PI
|
|
401
|
-
* @
|
|
406
|
+
* @type {Number}
|
|
407
|
+
* @default Math.PI
|
|
402
408
|
* @memberof Utilities */
|
|
403
409
|
const PI = Math.PI;
|
|
404
410
|
|
|
@@ -532,8 +538,8 @@ const randInCircle = (radius=1, minRadius=0)=> radius > 0 ? randVector(radius *
|
|
|
532
538
|
const randVector = (length=1)=> new Vector2().setAngle(rand(2*PI), length);
|
|
533
539
|
|
|
534
540
|
/** Returns a random color between the two passed in colors, combine components if linear
|
|
535
|
-
* @param {Color} [colorA=
|
|
536
|
-
* @param {Color} [colorB=
|
|
541
|
+
* @param {Color} [colorA=Color()]
|
|
542
|
+
* @param {Color} [colorB=Color(0,0,0,1)]
|
|
537
543
|
* @param {Boolean} [linear]
|
|
538
544
|
* @return {Color}
|
|
539
545
|
* @memberof Random */
|
|
@@ -541,6 +547,8 @@ const randColor = (cA = new Color, cB = new Color(0,0,0,1), linear)=>
|
|
|
541
547
|
linear ? cA.lerp(cB, rand()) : new Color(rand(cA.r,cB.r),rand(cA.g,cB.g),rand(cA.b,cB.b),rand(cA.a,cB.a));
|
|
542
548
|
|
|
543
549
|
/** Seed used by the randSeeded function
|
|
550
|
+
* @type {Number}
|
|
551
|
+
* @default
|
|
544
552
|
* @memberof Random */
|
|
545
553
|
let randSeed = 1;
|
|
546
554
|
|
|
@@ -679,7 +687,8 @@ class Vector2
|
|
|
679
687
|
|
|
680
688
|
/** Sets this vector with angle and length passed in
|
|
681
689
|
* @param {Number} [angle=0]
|
|
682
|
-
* @param {Number} [length=1]
|
|
690
|
+
* @param {Number} [length=1]
|
|
691
|
+
* @return {Vector2} */
|
|
683
692
|
setAngle(a=0, length=1) { this.x = length*Math.sin(a); this.y = length*Math.cos(a); return this; }
|
|
684
693
|
|
|
685
694
|
/** Returns copy of this vector rotated by the angle passed in
|
|
@@ -748,9 +757,11 @@ const colorHSLA = (h, s, l, a)=> new Color().setHSLA(h, s, l, a);
|
|
|
748
757
|
/**
|
|
749
758
|
* Color object (red, green, blue, alpha) with some helpful functions
|
|
750
759
|
* @example
|
|
751
|
-
* let a = new Color;
|
|
752
|
-
* let b = new Color(1, 0, 0);
|
|
753
|
-
* let c = new Color(0, 0, 0, 0);
|
|
760
|
+
* let a = new Color; // white
|
|
761
|
+
* let b = new Color(1, 0, 0); // red
|
|
762
|
+
* let c = new Color(0, 0, 0, 0); // transparent black
|
|
763
|
+
* let d = colorRGBA(0, 0, 1); // blue using rgb color
|
|
764
|
+
* let e = colorHSLA(.3, 1, .5); // green using hsl color
|
|
754
765
|
*/
|
|
755
766
|
class Color
|
|
756
767
|
{
|
|
@@ -974,11 +985,12 @@ class Timer
|
|
|
974
985
|
|
|
975
986
|
/** Position of camera in world space
|
|
976
987
|
* @type {Vector2}
|
|
977
|
-
* @default
|
|
988
|
+
* @default Vector2()
|
|
978
989
|
* @memberof Settings */
|
|
979
990
|
let cameraPos = vec2();
|
|
980
991
|
|
|
981
992
|
/** Scale of camera in world space
|
|
993
|
+
* @type {Number}
|
|
982
994
|
* @default
|
|
983
995
|
* @memberof Settings */
|
|
984
996
|
let cameraScale = 32;
|
|
@@ -987,24 +999,26 @@ let cameraScale = 32;
|
|
|
987
999
|
// Display settings
|
|
988
1000
|
|
|
989
1001
|
/** The max size of the canvas, centered if window is larger
|
|
990
|
-
* @type {Vector2}
|
|
991
|
-
* @default
|
|
1002
|
+
* @type {Vector2}
|
|
1003
|
+
* @default Vector2(1920,1200)
|
|
992
1004
|
* @memberof Settings */
|
|
993
1005
|
let canvasMaxSize = vec2(1920, 1200);
|
|
994
1006
|
|
|
995
1007
|
/** Fixed size of the canvas, if enabled canvas size never changes
|
|
996
1008
|
* - you may also need to set mainCanvasSize if using screen space coords in startup
|
|
997
|
-
* @type {Vector2}
|
|
998
|
-
* @default
|
|
1009
|
+
* @type {Vector2}
|
|
1010
|
+
* @default Vector2()
|
|
999
1011
|
* @memberof Settings */
|
|
1000
1012
|
let canvasFixedSize = vec2();
|
|
1001
1013
|
|
|
1002
1014
|
/** Disables anti aliasing for pixel art if true
|
|
1015
|
+
* @type {Boolean}
|
|
1003
1016
|
* @default
|
|
1004
1017
|
* @memberof Settings */
|
|
1005
1018
|
let cavasPixelated = 1;
|
|
1006
1019
|
|
|
1007
1020
|
/** Default font used for text rendering
|
|
1021
|
+
* @type {String}
|
|
1008
1022
|
* @default
|
|
1009
1023
|
* @memberof Settings */
|
|
1010
1024
|
let fontDefault = 'arial';
|
|
@@ -1013,11 +1027,13 @@ let fontDefault = 'arial';
|
|
|
1013
1027
|
// WebGL settings
|
|
1014
1028
|
|
|
1015
1029
|
/** Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)
|
|
1030
|
+
* @type {Boolean}
|
|
1016
1031
|
* @default
|
|
1017
1032
|
* @memberof Settings */
|
|
1018
1033
|
let glEnable = 1;
|
|
1019
1034
|
|
|
1020
1035
|
/** Fixes slow rendering in some browsers by not compositing the WebGL canvas
|
|
1036
|
+
* @type {Boolean}
|
|
1021
1037
|
* @default
|
|
1022
1038
|
* @memberof Settings */
|
|
1023
1039
|
let glOverlay = 1;
|
|
@@ -1026,12 +1042,13 @@ let glOverlay = 1;
|
|
|
1026
1042
|
// Tile sheet settings
|
|
1027
1043
|
|
|
1028
1044
|
/** Default size of tiles in pixels
|
|
1029
|
-
* @type {Vector2}
|
|
1030
|
-
* @default
|
|
1045
|
+
* @type {Vector2}
|
|
1046
|
+
* @default Vector2(16,16)
|
|
1031
1047
|
* @memberof Settings */
|
|
1032
1048
|
let tileSizeDefault = vec2(16);
|
|
1033
1049
|
|
|
1034
1050
|
/** Prevent tile bleeding from neighbors in pixels
|
|
1051
|
+
* @type {Number}
|
|
1035
1052
|
* @default
|
|
1036
1053
|
* @memberof Settings */
|
|
1037
1054
|
let tileFixBleedScale = .3;
|
|
@@ -1039,53 +1056,56 @@ let tileFixBleedScale = .3;
|
|
|
1039
1056
|
///////////////////////////////////////////////////////////////////////////////
|
|
1040
1057
|
// Object settings
|
|
1041
1058
|
|
|
1042
|
-
/** Default size of objects
|
|
1043
|
-
* @type {Vector2}
|
|
1044
|
-
* @default
|
|
1045
|
-
* @memberof Settings */
|
|
1046
|
-
let objectDefaultSize = vec2(1);
|
|
1047
|
-
|
|
1048
1059
|
/** Enable physics solver for collisions between objects
|
|
1060
|
+
* @type {Boolean}
|
|
1049
1061
|
* @default
|
|
1050
1062
|
* @memberof Settings */
|
|
1051
1063
|
let enablePhysicsSolver = 1;
|
|
1052
1064
|
|
|
1053
1065
|
/** Default object mass for collison calcuations (how heavy objects are)
|
|
1066
|
+
* @type {Number}
|
|
1054
1067
|
* @default
|
|
1055
1068
|
* @memberof Settings */
|
|
1056
1069
|
let objectDefaultMass = 1;
|
|
1057
1070
|
|
|
1058
1071
|
/** How much to slow velocity by each frame (0-1)
|
|
1072
|
+
* @type {Number}
|
|
1059
1073
|
* @default
|
|
1060
1074
|
* @memberof Settings */
|
|
1061
|
-
let objectDefaultDamping =
|
|
1075
|
+
let objectDefaultDamping = 1;
|
|
1062
1076
|
|
|
1063
1077
|
/** How much to slow angular velocity each frame (0-1)
|
|
1078
|
+
* @type {Number}
|
|
1064
1079
|
* @default
|
|
1065
1080
|
* @memberof Settings */
|
|
1066
|
-
let objectDefaultAngleDamping =
|
|
1081
|
+
let objectDefaultAngleDamping = 1;
|
|
1067
1082
|
|
|
1068
1083
|
/** How much to bounce when a collision occurs (0-1)
|
|
1069
|
-
* @
|
|
1084
|
+
* @type {Number}
|
|
1085
|
+
* @default 0
|
|
1070
1086
|
* @memberof Settings */
|
|
1071
1087
|
let objectDefaultElasticity = 0;
|
|
1072
1088
|
|
|
1073
1089
|
/** How much to slow when touching (0-1)
|
|
1090
|
+
* @type {Number}
|
|
1074
1091
|
* @default
|
|
1075
1092
|
* @memberof Settings */
|
|
1076
1093
|
let objectDefaultFriction = .8;
|
|
1077
1094
|
|
|
1078
1095
|
/** Clamp max speed to avoid fast objects missing collisions
|
|
1096
|
+
* @type {Number}
|
|
1079
1097
|
* @default
|
|
1080
1098
|
* @memberof Settings */
|
|
1081
1099
|
let objectMaxSpeed = 1;
|
|
1082
1100
|
|
|
1083
1101
|
/** How much gravity to apply to objects along the Y axis, negative is down
|
|
1084
|
-
* @
|
|
1102
|
+
* @type {Number}
|
|
1103
|
+
* @default 0
|
|
1085
1104
|
* @memberof Settings */
|
|
1086
1105
|
let gravity = 0;
|
|
1087
1106
|
|
|
1088
1107
|
/** Scales emit rate of particles, useful for low graphics mode (0 disables particle emitters)
|
|
1108
|
+
* @type {Number}
|
|
1089
1109
|
* @default
|
|
1090
1110
|
* @memberof Settings */
|
|
1091
1111
|
let particleEmitRateScale = 1;
|
|
@@ -1094,16 +1114,19 @@ let particleEmitRateScale = 1;
|
|
|
1094
1114
|
// Input settings
|
|
1095
1115
|
|
|
1096
1116
|
/** Should gamepads be allowed
|
|
1117
|
+
* @type {Boolean}
|
|
1097
1118
|
* @default
|
|
1098
1119
|
* @memberof Settings */
|
|
1099
1120
|
let gamepadsEnable = 1;
|
|
1100
1121
|
|
|
1101
1122
|
/** If true, the dpad input is also routed to the left analog stick (for better accessability)
|
|
1123
|
+
* @type {Boolean}
|
|
1102
1124
|
* @default
|
|
1103
1125
|
* @memberof Settings */
|
|
1104
1126
|
let gamepadDirectionEmulateStick = 1;
|
|
1105
1127
|
|
|
1106
1128
|
/** If true the WASD keys are also routed to the direction keys (for better accessability)
|
|
1129
|
+
* @type {Boolean}
|
|
1107
1130
|
* @default
|
|
1108
1131
|
* @memberof Settings */
|
|
1109
1132
|
let inputWASDEmulateDirection = 1;
|
|
@@ -1111,26 +1134,31 @@ let inputWASDEmulateDirection = 1;
|
|
|
1111
1134
|
/** True if touch gamepad should appear on mobile devices
|
|
1112
1135
|
* <br> - Supports left analog stick, 4 face buttons and start button (button 9)
|
|
1113
1136
|
* <br> - Must be set by end of gameInit to be activated
|
|
1114
|
-
* @
|
|
1137
|
+
* @type {Boolean}
|
|
1138
|
+
* @default 0
|
|
1115
1139
|
* @memberof Settings */
|
|
1116
1140
|
let touchGamepadEnable = 0;
|
|
1117
1141
|
|
|
1118
1142
|
/** True if touch gamepad should be analog stick or false to use if 8 way dpad
|
|
1143
|
+
* @type {Boolean}
|
|
1119
1144
|
* @default
|
|
1120
1145
|
* @memberof Settings */
|
|
1121
1146
|
let touchGamepadAnalog = 1;
|
|
1122
1147
|
|
|
1123
1148
|
/** Size of virutal gamepad for touch devices in pixels
|
|
1149
|
+
* @type {Number}
|
|
1124
1150
|
* @default
|
|
1125
1151
|
* @memberof Settings */
|
|
1126
1152
|
let touchGamepadSize = 99;
|
|
1127
1153
|
|
|
1128
1154
|
/** Transparency of touch gamepad overlay
|
|
1155
|
+
* @type {Number}
|
|
1129
1156
|
* @default
|
|
1130
1157
|
* @memberof Settings */
|
|
1131
1158
|
let touchGamepadAlpha = .3;
|
|
1132
1159
|
|
|
1133
1160
|
/** Allow vibration hardware if it exists
|
|
1161
|
+
* @type {Boolean}
|
|
1134
1162
|
* @default
|
|
1135
1163
|
* @memberof Settings */
|
|
1136
1164
|
let vibrateEnable = 1;
|
|
@@ -1139,21 +1167,25 @@ let vibrateEnable = 1;
|
|
|
1139
1167
|
// Audio settings
|
|
1140
1168
|
|
|
1141
1169
|
/** All audio code can be disabled and removed from build
|
|
1170
|
+
* @type {Boolean}
|
|
1142
1171
|
* @default
|
|
1143
1172
|
* @memberof Settings */
|
|
1144
1173
|
let soundEnable = 1;
|
|
1145
1174
|
|
|
1146
1175
|
/** Volume scale to apply to all sound, music and speech
|
|
1176
|
+
* @type {Number}
|
|
1147
1177
|
* @default
|
|
1148
1178
|
* @memberof Settings */
|
|
1149
1179
|
let soundVolume = .5;
|
|
1150
1180
|
|
|
1151
1181
|
/** Default range where sound no longer plays
|
|
1182
|
+
* @type {Number}
|
|
1152
1183
|
* @default
|
|
1153
1184
|
* @memberof Settings */
|
|
1154
1185
|
let soundDefaultRange = 40;
|
|
1155
1186
|
|
|
1156
1187
|
/** Default range percent to start tapering off sound (0-1)
|
|
1188
|
+
* @type {Number}
|
|
1157
1189
|
* @default
|
|
1158
1190
|
* @memberof Settings */
|
|
1159
1191
|
let soundDefaultTaper = .7;
|
|
@@ -1162,27 +1194,32 @@ let soundDefaultTaper = .7;
|
|
|
1162
1194
|
// Medals settings
|
|
1163
1195
|
|
|
1164
1196
|
/** How long to show medals for in seconds
|
|
1197
|
+
* @type {Number}
|
|
1165
1198
|
* @default
|
|
1166
1199
|
* @memberof Settings */
|
|
1167
1200
|
let medalDisplayTime = 5;
|
|
1168
1201
|
|
|
1169
1202
|
/** How quickly to slide on/off medals in seconds
|
|
1203
|
+
* @type {Number}
|
|
1170
1204
|
* @default
|
|
1171
1205
|
* @memberof Settings */
|
|
1172
1206
|
let medalDisplaySlideTime = .5;
|
|
1173
1207
|
|
|
1174
1208
|
/** Size of medal display
|
|
1175
|
-
* @
|
|
1209
|
+
* @type {Vector2}
|
|
1210
|
+
* @default Vector2(640,80)
|
|
1176
1211
|
* @memberof Settings */
|
|
1177
1212
|
let medalDisplaySize = vec2(640, 80);
|
|
1178
1213
|
|
|
1179
1214
|
/** Size of icon in medal display
|
|
1215
|
+
* @type {Number}
|
|
1180
1216
|
* @default
|
|
1181
1217
|
* @memberof Settings */
|
|
1182
1218
|
let medalDisplayIconSize = 50;
|
|
1183
1219
|
|
|
1184
1220
|
/** Set to stop medals from being unlockable (like if cheats are enabled)
|
|
1185
|
-
* @
|
|
1221
|
+
* @type {Boolean}
|
|
1222
|
+
* @default 0
|
|
1186
1223
|
* @memberof Settings */
|
|
1187
1224
|
let medalsPreventUnlock;
|
|
1188
1225
|
/*
|
|
@@ -1219,15 +1256,15 @@ let medalsPreventUnlock;
|
|
|
1219
1256
|
class EngineObject
|
|
1220
1257
|
{
|
|
1221
1258
|
/** Create an engine object and adds it to the list of objects
|
|
1222
|
-
* @param {Vector2} [position=
|
|
1223
|
-
* @param {Vector2} [size=
|
|
1259
|
+
* @param {Vector2} [position=Vector2()] - World space position of the object
|
|
1260
|
+
* @param {Vector2} [size=Vector2(1,1)] - World space size of the object
|
|
1224
1261
|
* @param {Number} [tileIndex=-1] - Tile to use to render object (-1 is untextured)
|
|
1225
1262
|
* @param {Vector2} [tileSize=tileSizeDefault] - Size of tile in source pixels
|
|
1226
1263
|
* @param {Number} [angle=0] - Angle the object is rotated by
|
|
1227
|
-
* @param {Color} [color]
|
|
1264
|
+
* @param {Color} [color=Color()] - Color to apply to tile when rendered
|
|
1228
1265
|
* @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
|
|
1229
1266
|
*/
|
|
1230
|
-
constructor(pos=vec2(), size=
|
|
1267
|
+
constructor(pos=vec2(), size=vec2(1), tileIndex=-1, tileSize=tileSizeDefault, angle=0, color, renderOrder=0)
|
|
1231
1268
|
{
|
|
1232
1269
|
// set passed in params
|
|
1233
1270
|
ASSERT(isVector2(pos) && isVector2(size)); // ensure pos and size are vec2s
|
|
@@ -1264,7 +1301,7 @@ class EngineObject
|
|
|
1264
1301
|
this.gravityScale = 1;
|
|
1265
1302
|
/** @property {Number} [renderOrder=0] - Objects are sorted by render order */
|
|
1266
1303
|
this.renderOrder = renderOrder;
|
|
1267
|
-
/** @property {Vector2} [velocity=
|
|
1304
|
+
/** @property {Vector2} [velocity=Vector2()] - Velocity of the object */
|
|
1268
1305
|
this.velocity = new Vector2();
|
|
1269
1306
|
/** @property {Number} [angleVelocity=0] - Angular velocity of the object */
|
|
1270
1307
|
this.angleVelocity = 0;
|
|
@@ -1507,7 +1544,7 @@ class EngineObject
|
|
|
1507
1544
|
|
|
1508
1545
|
/** Attaches a child to this with a given local transform
|
|
1509
1546
|
* @param {EngineObject} child
|
|
1510
|
-
* @param {Vector2} [localPos=
|
|
1547
|
+
* @param {Vector2} [localPos=Vector2()]
|
|
1511
1548
|
* @param {Number} [localAngle=0] */
|
|
1512
1549
|
addChild(child, localPos=vec2(), localAngle=0)
|
|
1513
1550
|
{
|
|
@@ -1641,15 +1678,15 @@ const worldToScreen = (worldPos)=>
|
|
|
1641
1678
|
}
|
|
1642
1679
|
|
|
1643
1680
|
/** Draw textured tile centered in world space, with color applied if using WebGL
|
|
1644
|
-
* @param {Vector2} pos
|
|
1645
|
-
* @param {Vector2} [size=
|
|
1646
|
-
* @param {Number} [tileIndex=-1]
|
|
1647
|
-
* @param {Vector2} [tileSize=tileSizeDefault]
|
|
1648
|
-
* @param {Color} [color=
|
|
1649
|
-
* @param {Number} [angle=0]
|
|
1650
|
-
* @param {Boolean} [mirror=0]
|
|
1651
|
-
* @param {Color} [additiveColor=
|
|
1652
|
-
* @param {Boolean} [useWebGL=glEnable]
|
|
1681
|
+
* @param {Vector2} pos - Center of the tile in world space
|
|
1682
|
+
* @param {Vector2} [size=Vector2(1,1)] - Size of the tile in world space
|
|
1683
|
+
* @param {Number} [tileIndex=-1] - Tile index to use, negative is untextured
|
|
1684
|
+
* @param {Vector2} [tileSize=tileSizeDefault] - Tile size in source pixels
|
|
1685
|
+
* @param {Color} [color=Color()] - Color to modulate with
|
|
1686
|
+
* @param {Number} [angle=0] - Angle to rotate by
|
|
1687
|
+
* @param {Boolean} [mirror=0] - If true image is flipped along the Y axis
|
|
1688
|
+
* @param {Color} [additiveColor=Color(0,0,0,0)] - Additive color to be applied
|
|
1689
|
+
* @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
1653
1690
|
* @memberof Draw */
|
|
1654
1691
|
function drawTile(pos, size=vec2(1), tileIndex=-1, tileSize=tileSizeDefault, color=new Color, angle=0, mirror,
|
|
1655
1692
|
additiveColor=new Color(0,0,0,0), useWebGL=glEnable)
|
|
@@ -1704,8 +1741,8 @@ function drawTile(pos, size=vec2(1), tileIndex=-1, tileSize=tileSizeDefault, col
|
|
|
1704
1741
|
|
|
1705
1742
|
/** Draw colored rect centered on pos
|
|
1706
1743
|
* @param {Vector2} pos
|
|
1707
|
-
* @param {Vector2} [size=
|
|
1708
|
-
* @param {Color} [color=
|
|
1744
|
+
* @param {Vector2} [size=Vector2(1,1)]
|
|
1745
|
+
* @param {Color} [color=Color()]
|
|
1709
1746
|
* @param {Number} [angle=0]
|
|
1710
1747
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1711
1748
|
* @memberof Draw */
|
|
@@ -1716,13 +1753,13 @@ function drawRect(pos, size, color, angle, useWebGL)
|
|
|
1716
1753
|
|
|
1717
1754
|
/** Draw textured tile centered on pos in screen space
|
|
1718
1755
|
* @param {Vector2} pos - Center of the tile
|
|
1719
|
-
* @param {Vector2} [size=
|
|
1756
|
+
* @param {Vector2} [size=Vector2(1,1)] - Size of the tile
|
|
1720
1757
|
* @param {Number} [tileIndex=-1] - Tile index to use, negative is untextured
|
|
1721
1758
|
* @param {Vector2} [tileSize=tileSizeDefault] - Tile size in source pixels
|
|
1722
|
-
* @param {Color} [color=
|
|
1759
|
+
* @param {Color} [color=Color()]
|
|
1723
1760
|
* @param {Number} [angle=0]
|
|
1724
1761
|
* @param {Boolean} [mirror=0]
|
|
1725
|
-
* @param {Color} [additiveColor=
|
|
1762
|
+
* @param {Color} [additiveColor=Color(0,0,0,0)]
|
|
1726
1763
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1727
1764
|
* @memberof Draw */
|
|
1728
1765
|
function drawTileScreenSpace(pos, size=vec2(1), tileIndex, tileSize, color, angle, mirror, additiveColor, useWebGL)
|
|
@@ -1732,8 +1769,8 @@ function drawTileScreenSpace(pos, size=vec2(1), tileIndex, tileSize, color, angl
|
|
|
1732
1769
|
|
|
1733
1770
|
/** Draw colored rectangle in screen space
|
|
1734
1771
|
* @param {Vector2} pos
|
|
1735
|
-
* @param {Vector2} [size=
|
|
1736
|
-
* @param {Color} [color=
|
|
1772
|
+
* @param {Vector2} [size=Vector2(1,1)]
|
|
1773
|
+
* @param {Color} [color=Color()]
|
|
1737
1774
|
* @param {Number} [angle=0]
|
|
1738
1775
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1739
1776
|
* @memberof Draw */
|
|
@@ -1746,7 +1783,7 @@ function drawRectScreenSpace(pos, size, color, angle, useWebGL)
|
|
|
1746
1783
|
* @param {Vector2} posA
|
|
1747
1784
|
* @param {Vector2} posB
|
|
1748
1785
|
* @param {Number} [thickness=.1]
|
|
1749
|
-
* @param {Color} [color=
|
|
1786
|
+
* @param {Color} [color=Color()]
|
|
1750
1787
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1751
1788
|
* @memberof Draw */
|
|
1752
1789
|
function drawLine(posA, posB, thickness=.1, color, useWebGL)
|
|
@@ -1794,9 +1831,9 @@ function setBlendMode(additive, useWebGL=glEnable)
|
|
|
1794
1831
|
* @param {String} text
|
|
1795
1832
|
* @param {Vector2} pos
|
|
1796
1833
|
* @param {Number} [size=1]
|
|
1797
|
-
* @param {Color} [color=
|
|
1834
|
+
* @param {Color} [color=Color()]
|
|
1798
1835
|
* @param {Number} [lineWidth=0]
|
|
1799
|
-
* @param {Color} [lineColor=
|
|
1836
|
+
* @param {Color} [lineColor=Color(0,0,0)]
|
|
1800
1837
|
* @param {String} [textAlign='center']
|
|
1801
1838
|
* @memberof Draw */
|
|
1802
1839
|
function drawTextScreen(text, pos, size=1, color=new Color, lineWidth=0, lineColor=new Color(0,0,0), textAlign='center', font=fontDefault, context=overlayContext)
|
|
@@ -1823,18 +1860,20 @@ function drawTextScreen(text, pos, size=1, color=new Color, lineWidth=0, lineCol
|
|
|
1823
1860
|
* @param {String} text
|
|
1824
1861
|
* @param {Vector2} pos
|
|
1825
1862
|
* @param {Number} [size=1]
|
|
1826
|
-
* @param {Color} [color=
|
|
1863
|
+
* @param {Color} [color=Color()]
|
|
1827
1864
|
* @param {Number} [lineWidth=0]
|
|
1828
|
-
* @param {Color} [lineColor=
|
|
1865
|
+
* @param {Color} [lineColor=Color(0,0,0)]
|
|
1829
1866
|
* @param {String} [textAlign='center']
|
|
1830
1867
|
* @memberof Draw */
|
|
1831
|
-
function drawText(text, pos, size=1, color, lineWidth, lineColor, textAlign, font)
|
|
1868
|
+
function drawText(text, pos, size=1, color, lineWidth=0, lineColor, textAlign, font)
|
|
1832
1869
|
{
|
|
1833
1870
|
drawTextScreen(text, worldToScreen(pos), size*cameraScale, color, lineWidth*cameraScale, lineColor, textAlign, font, mainContext);
|
|
1834
1871
|
}
|
|
1835
1872
|
|
|
1836
1873
|
///////////////////////////////////////////////////////////////////////////////
|
|
1837
1874
|
|
|
1875
|
+
let engineFontImage;
|
|
1876
|
+
|
|
1838
1877
|
/**
|
|
1839
1878
|
* Font Image Object - Draw text on a 2D canvas by using characters in an image
|
|
1840
1879
|
* <br> - 96 characters (from space to tilde) are stored in an image
|
|
@@ -1847,10 +1886,6 @@ function drawText(text, pos, size=1, color, lineWidth, lineColor, textAlign, fon
|
|
|
1847
1886
|
* // draw text
|
|
1848
1887
|
* font.drawTextScreen("LittleJS\nHello World!", vec2(200, 50));
|
|
1849
1888
|
*/
|
|
1850
|
-
|
|
1851
|
-
// default font image created by engine
|
|
1852
|
-
let engineFontImage;
|
|
1853
|
-
|
|
1854
1889
|
class FontImage
|
|
1855
1890
|
{
|
|
1856
1891
|
/** Create an image font
|
|
@@ -1981,18 +2016,21 @@ const keyWasReleased = (key, device=0)=> inputData[device] && inputData[device][
|
|
|
1981
2016
|
const clearInput = ()=> inputData = [[]];
|
|
1982
2017
|
|
|
1983
2018
|
/** Returns true if mouse button is down
|
|
2019
|
+
* @function
|
|
1984
2020
|
* @param {Number} button
|
|
1985
2021
|
* @return {Boolean}
|
|
1986
2022
|
* @memberof Input */
|
|
1987
2023
|
const mouseIsDown = keyIsDown;
|
|
1988
2024
|
|
|
1989
2025
|
/** Returns true if mouse button was pressed
|
|
2026
|
+
* @function
|
|
1990
2027
|
* @param {Number} button
|
|
1991
2028
|
* @return {Boolean}
|
|
1992
2029
|
* @memberof Input */
|
|
1993
2030
|
const mouseWasPressed = keyWasPressed;
|
|
1994
2031
|
|
|
1995
2032
|
/** Returns true if mouse button was released
|
|
2033
|
+
* @function
|
|
1996
2034
|
* @param {Number} button
|
|
1997
2035
|
* @return {Boolean}
|
|
1998
2036
|
* @memberof Input */
|
|
@@ -2009,14 +2047,17 @@ let mousePos = vec2();
|
|
|
2009
2047
|
let mousePosScreen = vec2();
|
|
2010
2048
|
|
|
2011
2049
|
/** Mouse wheel delta this frame
|
|
2050
|
+
* @type {Number}
|
|
2012
2051
|
* @memberof Input */
|
|
2013
2052
|
let mouseWheel = 0;
|
|
2014
2053
|
|
|
2015
2054
|
/** Returns true if user is using gamepad (has more recently pressed a gamepad button)
|
|
2055
|
+
* @type {Boolean}
|
|
2016
2056
|
* @memberof Input */
|
|
2017
2057
|
let isUsingGamepad = 0;
|
|
2018
2058
|
|
|
2019
2059
|
/** Prevents input continuing to the default browser handling (false by default)
|
|
2060
|
+
* @type {Boolean}
|
|
2020
2061
|
* @memberof Input */
|
|
2021
2062
|
let preventDefaultInput = 0;
|
|
2022
2063
|
|
|
@@ -2192,7 +2233,6 @@ const vibrateStop = ()=> vibrate(0);
|
|
|
2192
2233
|
// Touch input
|
|
2193
2234
|
|
|
2194
2235
|
/** True if a touch device has been detected
|
|
2195
|
-
* @const {Boolean}
|
|
2196
2236
|
* @memberof Input */
|
|
2197
2237
|
const isTouchDevice = window.ontouchstart !== undefined;
|
|
2198
2238
|
|
|
@@ -2522,7 +2562,7 @@ class Music
|
|
|
2522
2562
|
{
|
|
2523
2563
|
if (!soundEnable) return;
|
|
2524
2564
|
|
|
2525
|
-
this.source = playSamples(this.cachedSamples, volume, 1, 0, loop);
|
|
2565
|
+
return this.source = playSamples(this.cachedSamples, volume, 1, 0, loop);
|
|
2526
2566
|
}
|
|
2527
2567
|
|
|
2528
2568
|
/** Stop the music */
|
|
@@ -2863,6 +2903,7 @@ function zzfxM(instruments, patterns, sequence, BPM = 125)
|
|
|
2863
2903
|
'use strict';
|
|
2864
2904
|
|
|
2865
2905
|
/** The tile collision layer array, use setTileCollisionData and getTileCollisionData to access
|
|
2906
|
+
* @type {Array}
|
|
2866
2907
|
* @memberof TileCollision */
|
|
2867
2908
|
let tileCollision = [];
|
|
2868
2909
|
|
|
@@ -2898,7 +2939,7 @@ const getTileCollisionData = (pos)=>
|
|
|
2898
2939
|
|
|
2899
2940
|
/** Check if collision with another object should occur
|
|
2900
2941
|
* @param {Vector2} pos
|
|
2901
|
-
* @param {Vector2} [size=
|
|
2942
|
+
* @param {Vector2} [size=Vector2(1,1)]
|
|
2902
2943
|
* @param {EngineObject} [object]
|
|
2903
2944
|
* @return {Boolean}
|
|
2904
2945
|
* @memberof TileCollision */
|
|
@@ -2966,11 +3007,11 @@ function tileCollisionRaycast(posStart, posEnd, object)
|
|
|
2966
3007
|
class TileLayerData
|
|
2967
3008
|
{
|
|
2968
3009
|
/** Create a tile layer data object, one for each tile in a TileLayer
|
|
2969
|
-
* @param {Number} [tile]
|
|
2970
|
-
* @param {Number} [direction=0]
|
|
2971
|
-
* @param {Boolean} [mirror=0]
|
|
2972
|
-
* @param {Color} [color=
|
|
2973
|
-
constructor(tile, direction=0, mirror=0, color=new Color)
|
|
3010
|
+
* @param {Number} [tile] - The tile to use, untextured if undefined
|
|
3011
|
+
* @param {Number} [direction=0] - Integer direction of tile, in 90 degree increments
|
|
3012
|
+
* @param {Boolean} [mirror=0] - If the tile should be mirrored along the x axis
|
|
3013
|
+
* @param {Color} [color=Color()] - Color of the tile */
|
|
3014
|
+
constructor(tile, direction=0, mirror=0, color=new Color())
|
|
2974
3015
|
{
|
|
2975
3016
|
/** @property {Number} - The tile to use, untextured if undefined */
|
|
2976
3017
|
this.tile = tile;
|
|
@@ -3001,10 +3042,10 @@ class TileLayerData
|
|
|
3001
3042
|
class TileLayer extends EngineObject
|
|
3002
3043
|
{
|
|
3003
3044
|
/** Create a tile layer object
|
|
3004
|
-
* @param {Vector2} [position=
|
|
3045
|
+
* @param {Vector2} [position=Vector2()] - World space position
|
|
3005
3046
|
* @param {Vector2} [size=tileCollisionSize] - World space size
|
|
3006
3047
|
* @param {Vector2} [tileSize=tileSizeDefault] - Size of tiles in source pixels
|
|
3007
|
-
* @param {Vector2} [scale=
|
|
3048
|
+
* @param {Vector2} [scale=Vector2(1,1)] - How much to scale this layer when rendered
|
|
3008
3049
|
* @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
|
|
3009
3050
|
*/
|
|
3010
3051
|
constructor(pos, size=tileCollisionSize, tileSize=tileSizeDefault, scale=vec2(1), renderOrder=0)
|
|
@@ -3156,10 +3197,10 @@ constructor(pos, size=tileCollisionSize, tileSize=tileSizeDefault, scale=vec2(1)
|
|
|
3156
3197
|
|
|
3157
3198
|
/** Draw a tile directly onto the layer canvas
|
|
3158
3199
|
* @param {Vector2} pos
|
|
3159
|
-
* @param {Vector2} [size=
|
|
3200
|
+
* @param {Vector2} [size=Vector2(1,1)]
|
|
3160
3201
|
* @param {Number} [tileIndex=-1]
|
|
3161
3202
|
* @param {Vector2} [tileSize=tileSizeDefault]
|
|
3162
|
-
* @param {Color} [color=
|
|
3203
|
+
* @param {Color} [color=Color()]
|
|
3163
3204
|
* @param {Number} [angle=0]
|
|
3164
3205
|
* @param {Boolean} [mirror=0] */
|
|
3165
3206
|
drawTile(pos, size=vec2(1), tileIndex=-1, tileSize=tileSizeDefault, color=new Color, angle, mirror)
|
|
@@ -3185,8 +3226,8 @@ constructor(pos, size=tileCollisionSize, tileSize=tileSizeDefault, scale=vec2(1)
|
|
|
3185
3226
|
|
|
3186
3227
|
/** Draw a rectangle directly onto the layer canvas
|
|
3187
3228
|
* @param {Vector2} pos
|
|
3188
|
-
* @param {Vector2} [size=
|
|
3189
|
-
* @param {Color} [color=
|
|
3229
|
+
* @param {Vector2} [size=Vector2(1,1)]
|
|
3230
|
+
* @param {Color} [color=Color()]
|
|
3190
3231
|
* @param {Number} [angle=0] */
|
|
3191
3232
|
drawRect(pos, size, color, angle)
|
|
3192
3233
|
{ this.drawTile(pos, size, -1, 0, color, angle); }
|
|
@@ -3227,11 +3268,11 @@ class ParticleEmitter extends EngineObject
|
|
|
3227
3268
|
* @param {Number} [emitRate=100] - How many particles per second to spawn, does not emit if 0
|
|
3228
3269
|
* @param {Number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
|
|
3229
3270
|
* @param {Number} [tileIndex=-1] - Index into tile sheet, if <0 no texture is applied
|
|
3230
|
-
* @param {Vector2} [tileSize=tileSizeDefault]
|
|
3231
|
-
* @param {Color} [colorStartA=
|
|
3232
|
-
* @param {Color} [colorStartB=
|
|
3233
|
-
* @param {Color} [colorEndA=
|
|
3234
|
-
* @param {Color} [colorEndB=
|
|
3271
|
+
* @param {Vector2} [tileSize=tileSizeDefault] - Tile size for particles
|
|
3272
|
+
* @param {Color} [colorStartA=Color()] - Color at start of life 1, randomized between start colors
|
|
3273
|
+
* @param {Color} [colorStartB=Color()] - Color at start of life 2, randomized between start colors
|
|
3274
|
+
* @param {Color} [colorEndA=Color(1,1,1,0)] - Color at end of life 1, randomized between end colors
|
|
3275
|
+
* @param {Color} [colorEndB=Color(1,1,1,0)] - Color at end of life 2, randomized between end colors
|
|
3235
3276
|
* @param {Number} [particleTime=.5] - How long particles live
|
|
3236
3277
|
* @param {Number} [sizeStart=.1] - How big are particles at start
|
|
3237
3278
|
* @param {Number} [sizeEnd=1] - How big are particles at end
|
|
@@ -3511,6 +3552,7 @@ class Particle extends EngineObject
|
|
|
3511
3552
|
'use strict';
|
|
3512
3553
|
|
|
3513
3554
|
/** List of all medals
|
|
3555
|
+
* @type {Array}
|
|
3514
3556
|
* @memberof Medals */
|
|
3515
3557
|
const medals = [];
|
|
3516
3558
|
|
|
@@ -4062,12 +4104,13 @@ function glDraw(x, y, sizeX, sizeY, angle, uv0X, uv0Y, uv1X, uv1Y, rgba, rgbaAdd
|
|
|
4062
4104
|
///////////////////////////////////////////////////////////////////////////////
|
|
4063
4105
|
// post processing - can be enabled to pass other canvases through a final shader
|
|
4064
4106
|
|
|
4065
|
-
let glPostShader, glPostArrayBuffer, glPostTexture;
|
|
4107
|
+
let glPostShader, glPostArrayBuffer, glPostTexture, glPostIncludeOverlay;
|
|
4066
4108
|
|
|
4067
4109
|
/** Set up a post processing shader
|
|
4068
4110
|
* @param {String} shaderCode
|
|
4111
|
+
* @param {Boolean} includeOverlay
|
|
4069
4112
|
* @memberof WebGL */
|
|
4070
|
-
function glInitPostProcess(shaderCode)
|
|
4113
|
+
function glInitPostProcess(shaderCode, includeOverlay)
|
|
4071
4114
|
{
|
|
4072
4115
|
ASSERT(!glPostShader); // can only have 1 post effects shader
|
|
4073
4116
|
|
|
@@ -4096,6 +4139,7 @@ function glInitPostProcess(shaderCode)
|
|
|
4096
4139
|
// create buffer and texture
|
|
4097
4140
|
glPostArrayBuffer = glContext.createBuffer();
|
|
4098
4141
|
glPostTexture = glCreateTexture();
|
|
4142
|
+
glPostIncludeOverlay = includeOverlay;
|
|
4099
4143
|
|
|
4100
4144
|
// hide the original 2d canvas
|
|
4101
4145
|
mainCanvas.style.visibility = 'hidden';
|
|
@@ -4116,6 +4160,13 @@ function glRenderPostProcess()
|
|
|
4116
4160
|
else // set viewport
|
|
4117
4161
|
glContext.viewport(0, 0, glCanvas.width = mainCanvas.width, glCanvas.height = mainCanvas.height);
|
|
4118
4162
|
|
|
4163
|
+
if (glPostIncludeOverlay)
|
|
4164
|
+
{
|
|
4165
|
+
// copy overlay canvas so it will be included in post processing
|
|
4166
|
+
mainContext.drawImage(overlayCanvas, 0, 0);
|
|
4167
|
+
overlayCanvas.width |= 0;
|
|
4168
|
+
}
|
|
4169
|
+
|
|
4119
4170
|
// setup shader program to draw one triangle
|
|
4120
4171
|
glContext.useProgram(glPostShader);
|
|
4121
4172
|
glContext.disable(gl_BLEND);
|
|
@@ -4199,43 +4250,71 @@ gl_VERTEX_BUFFER_SIZE = gl_MAX_BATCH * gl_VERTICES_PER_QUAD * gl_VERTEX_BYTE_STR
|
|
|
4199
4250
|
- Call engineInit() to start it up!
|
|
4200
4251
|
*/
|
|
4201
4252
|
|
|
4253
|
+
/**
|
|
4254
|
+
* LittleJS Engine Globals
|
|
4255
|
+
* @namespace Engine
|
|
4256
|
+
*/
|
|
4257
|
+
|
|
4202
4258
|
'use strict';
|
|
4203
4259
|
|
|
4204
|
-
/** Name of engine
|
|
4260
|
+
/** Name of engine
|
|
4261
|
+
* @type {String}
|
|
4262
|
+
* @default
|
|
4263
|
+
* @memberof Engine */
|
|
4205
4264
|
const engineName = 'LittleJS';
|
|
4206
4265
|
|
|
4207
|
-
/** Version of engine
|
|
4208
|
-
|
|
4266
|
+
/** Version of engine
|
|
4267
|
+
* @type {String}
|
|
4268
|
+
* @default
|
|
4269
|
+
* @memberof Engine */
|
|
4270
|
+
const engineVersion = '1.5.1';
|
|
4209
4271
|
|
|
4210
4272
|
/** Frames per second to update objects
|
|
4211
|
-
* @
|
|
4273
|
+
* @type {Number}
|
|
4274
|
+
* @default
|
|
4275
|
+
* @memberof Engine */
|
|
4212
4276
|
const frameRate = 60;
|
|
4213
4277
|
|
|
4214
4278
|
/** How many seconds each frame lasts, engine uses a fixed time step
|
|
4215
|
-
* @
|
|
4279
|
+
* @type {Number}
|
|
4280
|
+
* @default 1/60
|
|
4281
|
+
* @memberof Engine */
|
|
4216
4282
|
const timeDelta = 1/frameRate;
|
|
4217
4283
|
|
|
4218
|
-
/** Array containing all engine objects
|
|
4284
|
+
/** Array containing all engine objects
|
|
4285
|
+
* @type {Array}
|
|
4286
|
+
* @memberof Engine */
|
|
4219
4287
|
let engineObjects = [];
|
|
4220
4288
|
|
|
4221
|
-
/** Array containing only objects that are set to collide with other objects this frame (for optimization)
|
|
4289
|
+
/** Array containing only objects that are set to collide with other objects this frame (for optimization)
|
|
4290
|
+
* @type {Array}
|
|
4291
|
+
* @memberof Engine */
|
|
4222
4292
|
let engineObjectsCollide = [];
|
|
4223
4293
|
|
|
4224
|
-
/** Current update frame, used to calculate time
|
|
4294
|
+
/** Current update frame, used to calculate time
|
|
4295
|
+
* @type {Number}
|
|
4296
|
+
* @memberof Engine */
|
|
4225
4297
|
let frame = 0;
|
|
4226
4298
|
|
|
4227
|
-
/** Current engine time since start in seconds, derived from frame
|
|
4299
|
+
/** Current engine time since start in seconds, derived from frame
|
|
4300
|
+
* @type {Number}
|
|
4301
|
+
* @memberof Engine */
|
|
4228
4302
|
let time = 0;
|
|
4229
4303
|
|
|
4230
|
-
/** Actual clock time since start in seconds (not affected by pause or frame rate clamping)
|
|
4304
|
+
/** Actual clock time since start in seconds (not affected by pause or frame rate clamping)
|
|
4305
|
+
* @type {Number}
|
|
4306
|
+
* @memberof Engine */
|
|
4231
4307
|
let timeReal = 0;
|
|
4232
4308
|
|
|
4233
|
-
/** Is the game paused? Causes time and objects to not be updated
|
|
4309
|
+
/** Is the game paused? Causes time and objects to not be updated
|
|
4310
|
+
* @type {Boolean}
|
|
4311
|
+
* @default 0
|
|
4312
|
+
* @memberof Engine */
|
|
4234
4313
|
let paused = 0;
|
|
4235
4314
|
|
|
4236
4315
|
/** Set if game is paused
|
|
4237
4316
|
* @param {Boolean} paused
|
|
4238
|
-
*/
|
|
4317
|
+
* @memberof Engine */
|
|
4239
4318
|
function setPaused(_paused) { paused = _paused; }
|
|
4240
4319
|
|
|
4241
4320
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -4247,7 +4326,7 @@ function setPaused(_paused) { paused = _paused; }
|
|
|
4247
4326
|
* @param {Function} gameRender - Called before objects are rendered, draw any background effects that appear behind objects
|
|
4248
4327
|
* @param {Function} gameRenderPost - Called after objects are rendered, draw effects or hud that appear above all objects
|
|
4249
4328
|
* @param {String} [tileImageSource] - Tile image to use, everything starts when the image is finished loading
|
|
4250
|
-
*/
|
|
4329
|
+
* @memberof Engine */
|
|
4251
4330
|
function engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, tileImageSource)
|
|
4252
4331
|
{
|
|
4253
4332
|
// init engine when tiles load or fail to load
|
|
@@ -4411,7 +4490,8 @@ function enginePreRender()
|
|
|
4411
4490
|
glEnable && glPreRender();
|
|
4412
4491
|
}
|
|
4413
4492
|
|
|
4414
|
-
/** Update each engine object, remove destroyed objects, and update time
|
|
4493
|
+
/** Update each engine object, remove destroyed objects, and update time
|
|
4494
|
+
* @memberof Engine */
|
|
4415
4495
|
function engineObjectsUpdate()
|
|
4416
4496
|
{
|
|
4417
4497
|
// get list of solid objects for physics optimzation
|
|
@@ -4437,7 +4517,8 @@ function engineObjectsUpdate()
|
|
|
4437
4517
|
time = ++frame / frameRate;
|
|
4438
4518
|
}
|
|
4439
4519
|
|
|
4440
|
-
/** Destroy and remove all objects
|
|
4520
|
+
/** Destroy and remove all objects
|
|
4521
|
+
* @memberof Engine */
|
|
4441
4522
|
function engineObjectsDestroy()
|
|
4442
4523
|
{
|
|
4443
4524
|
for (const o of engineObjects)
|
|
@@ -4449,7 +4530,8 @@ function engineObjectsDestroy()
|
|
|
4449
4530
|
* @param {Vector2} [pos] - Center of test area
|
|
4450
4531
|
* @param {Number} [size] - Radius of circle if float, rectangle size if Vector2
|
|
4451
4532
|
* @param {Function} [callbackFunction] - Calls this function on every object that passes the test
|
|
4452
|
-
* @param {Array} [objects=engineObjects] - List of objects to check
|
|
4533
|
+
* @param {Array} [objects=engineObjects] - List of objects to check
|
|
4534
|
+
* @memberof Engine */
|
|
4453
4535
|
function engineObjectsCallback(pos, size, callbackFunction, objects=engineObjects)
|
|
4454
4536
|
{
|
|
4455
4537
|
if (!pos) // all objects
|