excalibur 0.26.0-alpha.310 → 0.26.0-alpha.311

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/CHANGELOG.md +8 -2
  2. package/build/dist/Actor.js +3 -1
  3. package/build/dist/Actor.js.map +1 -1
  4. package/build/dist/Debug/Debug.d.ts +16 -0
  5. package/build/dist/Debug/Debug.js +35 -0
  6. package/build/dist/Debug/Debug.js.map +1 -1
  7. package/build/dist/Drawing/Animation.js +10 -1
  8. package/build/dist/Drawing/Animation.js.map +1 -1
  9. package/build/dist/Drawing/Polygon.js +11 -1
  10. package/build/dist/Drawing/Polygon.js.map +1 -1
  11. package/build/dist/Drawing/Sprite.js +24 -25
  12. package/build/dist/Drawing/Sprite.js.map +1 -1
  13. package/build/dist/Drawing/Texture.js +25 -36
  14. package/build/dist/Drawing/Texture.js.map +1 -1
  15. package/build/dist/Engine.d.ts +34 -1
  16. package/build/dist/Engine.js +114 -60
  17. package/build/dist/Engine.js.map +1 -1
  18. package/build/dist/EntityComponentSystem/SystemManager.d.ts +6 -0
  19. package/build/dist/EntityComponentSystem/SystemManager.js +12 -5
  20. package/build/dist/EntityComponentSystem/SystemManager.js.map +1 -1
  21. package/build/dist/Graphics/Animation.js +7 -1
  22. package/build/dist/Graphics/Animation.js.map +1 -1
  23. package/build/dist/Graphics/Canvas.js +5 -1
  24. package/build/dist/Graphics/Canvas.js.map +1 -1
  25. package/build/dist/Graphics/Circle.js +5 -1
  26. package/build/dist/Graphics/Circle.js.map +1 -1
  27. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js +4 -4
  28. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js.map +1 -1
  29. package/build/dist/Graphics/Font.js +14 -2
  30. package/build/dist/Graphics/Font.js.map +1 -1
  31. package/build/dist/Graphics/GraphicsComponent.js +6 -3
  32. package/build/dist/Graphics/GraphicsComponent.js.map +1 -1
  33. package/build/dist/Graphics/GraphicsGroup.js +4 -1
  34. package/build/dist/Graphics/GraphicsGroup.js.map +1 -1
  35. package/build/dist/Graphics/ImageSource.js +25 -36
  36. package/build/dist/Graphics/ImageSource.js.map +1 -1
  37. package/build/dist/Graphics/Polygon.js +5 -1
  38. package/build/dist/Graphics/Polygon.js.map +1 -1
  39. package/build/dist/Graphics/Rectangle.js +6 -1
  40. package/build/dist/Graphics/Rectangle.js.map +1 -1
  41. package/build/dist/Graphics/Sprite.js +6 -1
  42. package/build/dist/Graphics/Sprite.js.map +1 -1
  43. package/build/dist/Graphics/SpriteSheet.js +2 -2
  44. package/build/dist/Graphics/SpriteSheet.js.map +1 -1
  45. package/build/dist/Loader.d.ts +4 -1
  46. package/build/dist/Loader.js +31 -31
  47. package/build/dist/Loader.js.map +1 -1
  48. package/build/dist/Particles.js +1 -1
  49. package/build/dist/Particles.js.map +1 -1
  50. package/build/dist/Resources/Gif.js +8 -19
  51. package/build/dist/Resources/Gif.js.map +1 -1
  52. package/build/dist/Resources/Sound/Sound.js +42 -59
  53. package/build/dist/Resources/Sound/Sound.js.map +1 -1
  54. package/build/dist/Scene.js +1 -0
  55. package/build/dist/Scene.js.map +1 -1
  56. package/build/dist/Screen.js +3 -3
  57. package/build/dist/Screen.js.map +1 -1
  58. package/build/dist/ScreenElement.js +1 -1
  59. package/build/dist/ScreenElement.js.map +1 -1
  60. package/build/dist/Trigger.js +4 -1
  61. package/build/dist/Trigger.js.map +1 -1
  62. package/build/dist/Util/Clock.d.ts +117 -0
  63. package/build/dist/Util/Clock.js +209 -0
  64. package/build/dist/Util/Clock.js.map +1 -0
  65. package/build/dist/Util/Decorators.js +7 -2
  66. package/build/dist/Util/Decorators.js.map +1 -1
  67. package/build/dist/Util/Fps.d.ts +40 -0
  68. package/build/dist/Util/Fps.js +47 -0
  69. package/build/dist/Util/Fps.js.map +1 -0
  70. package/build/dist/Util/Util.d.ts +6 -1
  71. package/build/dist/Util/Util.js +9 -3
  72. package/build/dist/Util/Util.js.map +1 -1
  73. package/build/dist/Util/WebAudio.js.map +1 -1
  74. package/build/dist/excalibur.js +699 -306
  75. package/build/dist/excalibur.js.map +1 -1
  76. package/build/dist/excalibur.min.js +1 -1
  77. package/build/dist/excalibur.min.js.LICENSE.txt +1 -1
  78. package/build/dist/excalibur.min.js.map +1 -1
  79. package/build/dist/index.d.ts +3 -0
  80. package/build/dist/index.js +5 -2
  81. package/build/dist/index.js.map +1 -1
  82. package/build/esm/Debug/Debug.d.ts +16 -0
  83. package/build/esm/Engine.d.ts +34 -1
  84. package/build/esm/EntityComponentSystem/SystemManager.d.ts +6 -0
  85. package/build/esm/Loader.d.ts +4 -1
  86. package/build/esm/Util/Clock.d.ts +117 -0
  87. package/build/esm/Util/Fps.d.ts +40 -0
  88. package/build/esm/Util/Util.d.ts +6 -1
  89. package/build/esm/excalibur.js +705 -307
  90. package/build/esm/excalibur.js.map +1 -1
  91. package/build/esm/excalibur.min.js +1 -1
  92. package/build/esm/excalibur.min.js.LICENSE.txt +1 -1
  93. package/build/esm/excalibur.min.js.map +1 -1
  94. package/build/esm/index.d.ts +3 -0
  95. package/package.json +1 -1
  96. package/wallaby.js +1 -0
@@ -55,4 +55,7 @@ export * from './Util/Observable';
55
55
  export * from './Util/Log';
56
56
  export * from './Util/SortedList';
57
57
  export * from './Util/Pool';
58
+ export * from './Util/Fps';
59
+ export * from './Util/Clock';
60
+ export * from './Util/WebAudio';
58
61
  export * from './Promises';
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * The current Excalibur version string
3
- * @description `'0.26.0-alpha.310+5f94c2f'` gets replaced by Webpack on build
3
+ * @description `'0.26.0-alpha.311+c19e8da'` gets replaced by Webpack on build
4
4
  */
5
- export const EX_VERSION = '0.26.0-alpha.310+5f94c2f';
5
+ export const EX_VERSION = '0.26.0-alpha.311+c19e8da';
6
6
  import { polyfill } from './Polyfill';
7
7
  polyfill();
8
8
  // This file is used as the bundle entry point and exports everything
@@ -64,6 +64,9 @@ export * from './Util/Observable';
64
64
  export * from './Util/Log';
65
65
  export * from './Util/SortedList';
66
66
  export * from './Util/Pool';
67
+ export * from './Util/Fps';
68
+ export * from './Util/Clock';
69
+ export * from './Util/WebAudio';
67
70
  // ex.Deprecated
68
71
  export * from './Promises';
69
72
  // import * as deprecated from './Deprecated';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,QAAQ,EAAE,CAAC;AAEX,qEAAqE;AACrE,oDAAoD;AACpD,cAAc,SAAS,CAAC;AACxB,cAAc,MAAM,CAAC;AACrB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,KAAK,EAAa,MAAM,SAAS,CAAC;AAC3C,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClF,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAqC,WAAW,EAAE,MAAM,aAAa,CAAC;AACxG,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAyB,MAAM,WAAW,CAAC;AACjE,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,iBAAiB,CAAC;AACh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Ac,+BAA+B,CAAC;AAE9C,cAAc,SAAS,CAAC;AAExB,cAAc,kBAAkB,CAAC;AAEjC,sBAAsB;AACtB,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,CAAC;AAE5B,qBAAqB;AACrB,OAAO,KAAK,KAAK,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,sBAAsB;AACtB,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,CAAC;AAE5B,qBAAqB;AACrB,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;AACxB,OAAO,EACL,KAAK,EACL,KAAK,EACL,SAAS,EACT,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAEtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAEhC,gBAAgB;AAChB,cAAc,YAAY,CAAC;AAC3B,8CAA8C;AAC9C,uCAAuC;AACvC,gCAAgC"}
@@ -2,6 +2,7 @@ import { DebugFlags, ColorBlindFlags } from './DebugFlags';
2
2
  import { Engine } from '../Engine';
3
3
  import { Color } from '../Color';
4
4
  import { CollisionContact } from '../Collision/Detection/CollisionContact';
5
+ import { StandardClock, TestClock } from '..';
5
6
  /**
6
7
  * Debug stats containing current and previous frame statistics
7
8
  */
@@ -129,6 +130,21 @@ export interface GraphicsStatistics {
129
130
  export declare class Debug implements DebugFlags {
130
131
  private _engine;
131
132
  constructor(engine: Engine);
133
+ /**
134
+ * Switch the current excalibur clock with the [[TestClock]] and return
135
+ * it in the same running state.
136
+ *
137
+ * This is useful when you need to debug frame by frame.
138
+ */
139
+ useTestClock(): TestClock;
140
+ /**
141
+ * Switch the current excalibur clock with the [[StandardClock]] and
142
+ * return it in the same runnign state.
143
+ *
144
+ * This is useful when you need to switch back to normal mode after
145
+ * debugging.
146
+ */
147
+ useStandardClock(): StandardClock;
132
148
  /**
133
149
  * Performance statistics
134
150
  */
@@ -18,6 +18,7 @@ import * as Input from './Input/Index';
18
18
  import * as Events from './Events';
19
19
  import { BrowserEvents } from './Util/Browser';
20
20
  import { ExcaliburGraphicsContext } from './Graphics';
21
+ import { Clock } from './Util/Clock';
21
22
  /**
22
23
  * Enum representing the different mousewheel event bubble prevention
23
24
  */
@@ -124,6 +125,13 @@ export interface EngineOptions {
124
125
  * Optionally set the background color
125
126
  */
126
127
  backgroundColor?: Color;
128
+ /**
129
+ * Optionally set the maximum fps if not set Excalibur will go as fast as the device allows.
130
+ *
131
+ * You may want to constrain max fps if your game cannot maintain fps consistenly, it can look and feel better to have a 30fps game than
132
+ * one that bounces between 30fps and 60fps
133
+ */
134
+ maxFps?: number;
127
135
  }
128
136
  /**
129
137
  * The Excalibur Engine
@@ -154,6 +162,17 @@ export declare class Engine extends Class implements CanInitialize, CanUpdate, C
154
162
  * Direct access to the canvas element ID, if an ID exists
155
163
  */
156
164
  canvasElementId: string;
165
+ /**
166
+ * Optionally set the maximum fps if not set Excalibur will go as fast as the device allows.
167
+ *
168
+ * You may want to constrain max fps if your game cannot maintain fps consistenly, it can look and feel better to have a 30fps game than
169
+ * one that bounces between 30fps and 60fps
170
+ */
171
+ maxFps: number;
172
+ /**
173
+ * Direct access to the excalibur clock
174
+ */
175
+ clock: Clock;
157
176
  /**
158
177
  * The width of the game canvas in pixels (physical width component of the
159
178
  * resolution of the canvas element)
@@ -276,7 +295,6 @@ export declare class Engine extends Class implements CanInitialize, CanUpdate, C
276
295
  private _compatible;
277
296
  private _timescale;
278
297
  private _loader;
279
- private _isLoading;
280
298
  private _isInitialized;
281
299
  private _deferredGoTo;
282
300
  on(eventName: Events.initialize, handler: (event: Events.InitializeEvent<Engine>) => void): void;
@@ -555,13 +573,28 @@ export declare class Engine extends Class implements CanInitialize, CanUpdate, C
555
573
  * Returns true when loading is totally complete and the player has clicked start
556
574
  */
557
575
  get loadingComplete(): boolean;
576
+ private _isReady;
577
+ get ready(): boolean;
578
+ private _isReadyResolve;
579
+ private _isReadyPromise;
580
+ isReady(): Promise<void>;
558
581
  /**
559
582
  * Starts the internal game loop for Excalibur after loading
560
583
  * any provided assets.
561
584
  * @param loader Optional [[Loader]] to use to load resources. The default loader is [[Loader]], override to provide your own
562
585
  * custom loader.
586
+ *
587
+ * Note: start() only resolves AFTER the user has clicked the play button
563
588
  */
564
589
  start(loader?: Loader): Promise<void>;
590
+ private _mainloop;
591
+ /**
592
+ *
593
+ * @param game
594
+ * @param raf
595
+ * @param nowFn
596
+ * @deprecated Use [[Clock]] to run the mainloop, will be removed in v0.26.0
597
+ */
565
598
  static createMainLoop(game: Engine, raf: (func: Function) => number, nowFn: () => number): () => void;
566
599
  /**
567
600
  * Stops Excalibur's main loop, useful for pausing the game.
@@ -34,6 +34,12 @@ export declare class SystemManager<ContextType> {
34
34
  * @param system
35
35
  */
36
36
  removeSystem(system: System<any, ContextType>): void;
37
+ /**
38
+ * Initialize all systems in the manager
39
+ *
40
+ * Systems added after initialize() will be initialized on add
41
+ */
42
+ initialize(): void;
37
43
  /**
38
44
  * Updates all systems
39
45
  * @param type whether this is an update or draw system
@@ -154,9 +154,12 @@ export declare class Loader extends Class implements Loadable<Loadable<any>[]> {
154
154
  dispose(): void;
155
155
  update(_engine: Engine, _delta: number): void;
156
156
  data: Loadable<any>[];
157
+ private _isLoadedResolve;
158
+ private _isLoadedPromise;
159
+ areResourcesLoaded(): Promise<void>;
157
160
  /**
158
161
  * Begin loading all of the supplied resources, returning a promise
159
- * that resolves when loading of all is complete
162
+ * that resolves when loading of all is complete AND the user has clicked the "Play button"
160
163
  */
161
164
  load(): Promise<Loadable<any>[]>;
162
165
  markResourceComplete(): void;
@@ -0,0 +1,117 @@
1
+ import { FpsSampler } from './Fps';
2
+ export interface ClockOptions {
3
+ /**
4
+ * Define the function you'd like the clock to tick when it is started
5
+ */
6
+ tick: (elapsedMs: number) => any;
7
+ /**
8
+ * Optionally define the fatal exception handler, used if an error is thrown in tick
9
+ */
10
+ onFatalException?: (e: unknown) => any;
11
+ /**
12
+ * Optionally limit the maximum FPS of the clock
13
+ */
14
+ maxFps?: number;
15
+ }
16
+ /**
17
+ * Abstract Clock is the base type of all Clocks
18
+ *
19
+ * It has a few opinions
20
+ * 1. It manages the calculation of what "elapsed" time means and thus maximum fps
21
+ * 2. The default timing api is implemented in now()
22
+ *
23
+ * To implement your own clock, extend Clock and override start/stop to start and stop the clock, then call update() with whatever
24
+ * method is unique to your clock implementation.
25
+ */
26
+ export declare abstract class Clock {
27
+ protected tick: (elapsedMs: number) => any;
28
+ private _onFatalException;
29
+ private _maxFps;
30
+ private _lastTime;
31
+ fpsSampler: FpsSampler;
32
+ private _options;
33
+ private _elapsed;
34
+ private _scheduledCbs;
35
+ private _totalElapsed;
36
+ constructor(options: ClockOptions);
37
+ /**
38
+ * Get the elapsed time for the last completed frame
39
+ */
40
+ elapsed(): number;
41
+ /**
42
+ * Get the current time in milliseconds
43
+ */
44
+ now(): number;
45
+ toTestClock(): TestClock;
46
+ toStandardClock(): StandardClock;
47
+ /**
48
+ * Schedule a callback to fire given a timeout in milliseconds using the excalibur [[Clock]]
49
+ *
50
+ * This is useful to use over the built in browser `setTimeout` because callbacks will be tied to the
51
+ * excalibur update clock, instead of browser time, this means that callbacks wont fire if the game is
52
+ * stopped or paused.
53
+ *
54
+ * @param cb callback to fire
55
+ * @param timeoutMs Optionally specify a timeout in milliseconds from now, default is 0ms which means the next possible tick
56
+ */
57
+ schedule(cb: () => any, timeoutMs?: number): void;
58
+ private _runScheduledCbs;
59
+ protected update(overrideUpdateMs?: number): void;
60
+ /**
61
+ * Returns if the clock is currently running
62
+ */
63
+ abstract isRunning(): boolean;
64
+ /**
65
+ * Start the clock, it will then periodically call the tick(elapsedMilliseconds) since the last tick
66
+ */
67
+ abstract start(): void;
68
+ /**
69
+ * Stop the clock, tick() is no longer called
70
+ */
71
+ abstract stop(): void;
72
+ }
73
+ /**
74
+ * The [[StandardClock]] implements the requestAnimationFrame browser api to run the tick()
75
+ */
76
+ export declare class StandardClock extends Clock {
77
+ private _running;
78
+ private _requestId;
79
+ constructor(options: ClockOptions);
80
+ isRunning(): boolean;
81
+ start(): void;
82
+ stop(): void;
83
+ }
84
+ export interface TestClockOptions {
85
+ /**
86
+ * Specify the update milliseconds to use for each manual step()
87
+ */
88
+ defaultUpdateMs: number;
89
+ }
90
+ /**
91
+ * The TestClock is meant for debugging interactions in excalibur that require precise timing to replicate or test
92
+ */
93
+ export declare class TestClock extends Clock {
94
+ private _logger;
95
+ private _updateMs;
96
+ private _running;
97
+ private _currentTime;
98
+ constructor(options: ClockOptions & TestClockOptions);
99
+ /**
100
+ * Get the current time in milliseconds
101
+ */
102
+ now(): number;
103
+ isRunning(): boolean;
104
+ start(): void;
105
+ stop(): void;
106
+ /**
107
+ * Manually step the clock forward 1 tick, optionally specify an elapsed time in milliseconds
108
+ * @param overrideUpdateMs
109
+ */
110
+ step(overrideUpdateMs?: number): void;
111
+ /**
112
+ * Run a number of steps that tick the clock, optionally specify an elapsed time in milliseconds
113
+ * @param numberOfSteps
114
+ * @param overrideUpdateMs
115
+ */
116
+ run(numberOfSteps: number, overrideUpdateMs?: number): void;
117
+ }
@@ -0,0 +1,40 @@
1
+ export interface FpsSamplerOptions {
2
+ /**
3
+ * Specify the sampling period in milliseconds (default 100)
4
+ */
5
+ samplePeriod?: number;
6
+ /**
7
+ * Specify the initial FPS
8
+ */
9
+ initialFps: number;
10
+ /**
11
+ * Specify the function used to return the current time (in millseconds)
12
+ */
13
+ nowFn: () => number;
14
+ }
15
+ export declare class FpsSampler {
16
+ private _fps;
17
+ private _samplePeriod;
18
+ private _currentFrameTime;
19
+ private _frames;
20
+ private _previousSampleTime;
21
+ private _beginFrameTime;
22
+ private _nowFn;
23
+ constructor(options: FpsSamplerOptions);
24
+ /**
25
+ * Start of code block to sample FPS for
26
+ */
27
+ start(): void;
28
+ /**
29
+ * End of code block to sample FPS for
30
+ */
31
+ end(): void;
32
+ /**
33
+ * Return the currenty sampled fps over the last sample period, by default every 100ms
34
+ */
35
+ get fps(): number;
36
+ /**
37
+ * Return the instantanteous fps, this can be less useful because it will fluctuate given the current frames time
38
+ */
39
+ get instant(): number;
40
+ }
@@ -1,6 +1,7 @@
1
1
  import { Vector } from '../Math/vector';
2
2
  import { Random } from '../Math/Random';
3
3
  import { Side } from '../Collision/Side';
4
+ import { Clock } from '..';
4
5
  /**
5
6
  * Two PI constant
6
7
  */
@@ -157,6 +158,10 @@ export declare function fail(message: never): never;
157
158
  export declare const range: (from: number, to: number) => number[];
158
159
  /**
159
160
  * Create a promise that resolves after a certain number of milliseconds
161
+ *
162
+ * It is strongly recommended you pass the excalibur clock so delays are bound to the
163
+ * excalibur clock which would be unaffected by stop/pause.
160
164
  * @param milliseconds
165
+ * @param clock
161
166
  */
162
- export declare function delay(milliseconds: number): Promise<void>;
167
+ export declare function delay(milliseconds: number, clock?: Clock): Promise<void>;