diff options
| author | Rubén Beltrán del Río <ben@nsovocal.com> | 2018-04-23 07:58:20 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-23 07:58:20 -0500 |
| commit | 6768cd461ec1a8ea87c0f64e1b3c29e36b0b02ed (patch) | |
| tree | a681bf5e89210cc86f8108696e4f51ee16d62ee6 /lib/systems | |
| parent | 7ade6f8d96825386bf2e89dea51f9297cbac8e9c (diff) | |
Draw the Arena (#7)
* Add defaults to config
* Create arena sprite
* Draw the arena
* Draw a face when cooling down the dash
* Correct linter issues
Diffstat (limited to 'lib/systems')
| -rw-r--r-- | lib/systems/dash.js | 2 | ||||
| -rw-r--r-- | lib/systems/draw_dash.js | 107 | ||||
| -rw-r--r-- | lib/systems/render.js | 5 |
3 files changed, 112 insertions, 2 deletions
diff --git a/lib/systems/dash.js b/lib/systems/dash.js index d05e9ea..f648d36 100644 --- a/lib/systems/dash.js +++ b/lib/systems/dash.js @@ -1,7 +1,7 @@ import { System } from '@serpentity/serpentity'; const internals = { - kForce: 10 + kForce: 20 }; import DasherNode from '../nodes/dasher'; diff --git a/lib/systems/draw_dash.js b/lib/systems/draw_dash.js new file mode 100644 index 0000000..118ce1c --- /dev/null +++ b/lib/systems/draw_dash.js @@ -0,0 +1,107 @@ +import { System } from '@serpentity/serpentity'; + +import DrawnDasherNode from '../nodes/drawn_dasher'; + +const internals = { + kBlushRadius: 25 +}; + +/** + * Shows a different graphic during the duration of lock + * + * @extends {external:Serpentity.System} + * @class DrawDashSystem + * @param {object} config a configuration object to extend. + */ +export default class DrawDashSystem extends System { + + constructor(config = {}) { + + super(); + + /** + * The node collection of dashers + * + * @property {external:Serpentity.NodeCollection} drawnDashers + * @instance + * @memberof DrawDashSystem + */ + this.drawnDashers = null; + } + + /** + * Initializes system when added. Requests drawn dasher nodes + * + * @function added + * @memberof DrawDashSystem + * @instance + * @param {external:Serpentity.Engine} engine the serpentity engine to + * which we are getting added + */ + added(engine) { + + this.drawnDashers = engine.getNodes(DrawnDasherNode); + } + + /** + * Clears system resources when removed. + * + * @function removed + * @instance + * @memberof DrawDashSystem + */ + removed() { + + this.drawnDashers = null; + } + + /** + * Runs on every update of the loop. Updates image depending on if + * dash is locked + * + * @function update + * @instance + * @param {Number} currentFrameDuration the duration of the current + * frame + * @memberof DrawDashSystem + */ + update(currentFrameDuration) { + + for (const drawnDasher of this.drawnDashers) { + + const dash = drawnDasher.dash; + const container = drawnDasher.container.container; + + if (dash.locked) { + this._drawDashFace(container); + continue; + } + + this._removeDashFace(container); + } + } + + // Draws the dash face + + _drawDashFace(container) { + + const blush = container.getChildByName('blush'); + const smile = container.getChildByName('smile'); + const frown = container.getChildByName('frown'); + blush.visible = true; + frown.visible = true; + smile.visible = false; + } + + // Removes the dash face + + _removeDashFace(container) { + + const blush = container.getChildByName('blush'); + const smile = container.getChildByName('smile'); + const frown = container.getChildByName('frown'); + blush.visible = false; + frown.visible = false; + smile.visible = true; + } +}; diff --git a/lib/systems/render.js b/lib/systems/render.js index 06d0e60..83c740d 100644 --- a/lib/systems/render.js +++ b/lib/systems/render.js @@ -88,5 +88,8 @@ export default class RenderSystem extends System { * frame * @memberof RenderSystem */ - update(currentFrameDuration) {} + update(currentFrameDuration) { + + this.application.render(); + } }; |