aboutsummaryrefslogtreecommitdiff
path: root/lib/components
diff options
context:
space:
mode:
Diffstat (limited to 'lib/components')
-rw-r--r--lib/components/angle.js4
-rw-r--r--lib/components/body.js2
-rw-r--r--lib/components/control_map.js57
-rw-r--r--lib/components/dash.js51
-rw-r--r--lib/components/elastic.js12
-rw-r--r--lib/components/force.js43
-rw-r--r--lib/components/max_velocity.js25
7 files changed, 191 insertions, 3 deletions
diff --git a/lib/components/angle.js b/lib/components/angle.js
index 4de9764..65feeab 100644
--- a/lib/components/angle.js
+++ b/lib/components/angle.js
@@ -13,9 +13,9 @@ export default class AngleComponent extends Component {
super(config);
/**
- * The properthy that holds the pixi container
+ * The properthy that holds the angle
*
- * @property {external:MatterJs.Angle} angle
+ * @property {number} angle
* @instance
* @memberof AngleComponent
*/
diff --git a/lib/components/body.js b/lib/components/body.js
index 7438dc3..fc17e17 100644
--- a/lib/components/body.js
+++ b/lib/components/body.js
@@ -13,7 +13,7 @@ export default class BodyComponent extends Component {
super(config);
/**
- * The properthy that holds the pixi container
+ * The properthy that holds the matterjs body
*
* @property {external:MatterJs.Body} body
* @instance
diff --git a/lib/components/control_map.js b/lib/components/control_map.js
new file mode 100644
index 0000000..cb447d0
--- /dev/null
+++ b/lib/components/control_map.js
@@ -0,0 +1,57 @@
+import { Component } from '@serpentity/serpentity';
+
+/**
+ * The contorl mapping object, holds a source and target for the action.
+ *
+ * @typedef tControlMap
+ * @type object
+ *
+ * @property {tControlSource} source the source input for the action
+ * @property {tControlTarget} target the target property for the action
+ */
+
+/**
+ * The definition of an input source
+ *
+ * @typedef tControlSource
+ * @type object
+ *
+ * @property {string} type type of input, can be keyboard or gamepad (only keyboard supported atm)
+ * @property {number} gamepadNumber the number of gamepad to use (unsupported)
+ * @property {string} gamepadInputSource either axes or buttons
+ * @property {number} index the input index or keycode
+ */
+
+/**
+ * The definition of an input target
+ *
+ * @typedef tControlTarget
+ * @type object
+ *
+ * @property {external:Serpentity:Component} component the component affected by this
+ * @property {string} property property to affect. For nested properties use dot.notation
+ * @property {[function]} value a function that takes in the input and outputs a transformed value
+ */
+
+/**
+ * Component that stores the state of motion controls to properties
+ *
+ * @extends {external:Serpentity.Component}
+ * @class ControlMapComponent
+ * @param {object} config a configuration object to extend.
+ */
+export default class ControlMapComponent extends Component {
+ constructor(config) {
+
+ super(config);
+
+ /**
+ * The map of actions and controls. An array of mappings
+ *
+ * @property {Array<tControlMap>} map
+ * @instance
+ * @memberof ControlMapComponent
+ */
+ this.map = this.map || [];
+ }
+};
diff --git a/lib/components/dash.js b/lib/components/dash.js
new file mode 100644
index 0000000..de1fe2c
--- /dev/null
+++ b/lib/components/dash.js
@@ -0,0 +1,51 @@
+import { Component } from '@serpentity/serpentity';
+
+/**
+ * Component that stores a dash skill
+ *
+ * @extends {external:Serpentity.Component}
+ * @class DashComponent
+ * @param {object} config a configuration object to extend.
+ */
+export default class DashComponent extends Component {
+ constructor(config) {
+
+ super(config);
+
+ /**
+ * The properthy that holds the dash state
+ *
+ * @property {boolean} dashing
+ * @instance
+ * @memberof DashComponent
+ */
+ this.dashing = this.dashing || false;
+
+ /**
+ * Whether the dash is locked from occuring
+ *
+ * @property {boolean} locked
+ * @instance
+ * @memberof DashComponent
+ */
+ this.locked = this.locked || false;
+
+ /**
+ * Cooldown before lock is removed
+ *
+ * @property {number} cooldown
+ * @instance
+ * @memberof DashComponent
+ */
+ this.cooldown = this.cooldown || 4000;
+
+ /**
+ * Current cooldown
+ *
+ * @property {number} currentCooldown
+ * @instance
+ * @memberof DashComponent
+ */
+ this.currentCooldown = 0;
+ }
+};
diff --git a/lib/components/elastic.js b/lib/components/elastic.js
new file mode 100644
index 0000000..ee41cf8
--- /dev/null
+++ b/lib/components/elastic.js
@@ -0,0 +1,12 @@
+import { Component } from '@serpentity/serpentity';
+
+/**
+ * Component that stores elastic properties
+ *
+ * @extends {external:Serpentity.Component}
+ * @class ElasticComponent
+ * @param {object} config a configuration object to extend.
+ */
+export default class ElasticComponent extends Component {
+};
+
diff --git a/lib/components/force.js b/lib/components/force.js
new file mode 100644
index 0000000..f0e460c
--- /dev/null
+++ b/lib/components/force.js
@@ -0,0 +1,43 @@
+import { Component } from '@serpentity/serpentity';
+
+/**
+ * Component that stores a force vector
+ *
+ * @extends {external:Serpentity.Component}
+ * @class ForceComponent
+ * @param {object} config a configuration object to extend.
+ */
+export default class ForceComponent extends Component {
+ constructor(config) {
+
+ super(config);
+
+ /**
+ * The properthy that holds the x component of the vector
+ *
+ * @property {number} x
+ * @instance
+ * @memberof AngleComponent
+ */
+ this.x = this.x || 0;
+
+ /**
+ * The properthy that holds the y component of the vector
+ *
+ * @property {number} y
+ * @instance
+ * @memberof AngleComponent
+ */
+
+ this.y = this.y || 0;
+ /**
+ * The properthy that holds the z component of the vector
+ *
+ * @property {number} z
+ * @instance
+ * @memberof AngleComponent
+ */
+ this.z = this.z || 0;
+ }
+};
+
diff --git a/lib/components/max_velocity.js b/lib/components/max_velocity.js
new file mode 100644
index 0000000..70bf343
--- /dev/null
+++ b/lib/components/max_velocity.js
@@ -0,0 +1,25 @@
+import { Component } from '@serpentity/serpentity';
+
+/**
+ * Component that stores max velocity constraint
+ *
+ * @extends {external:Serpentity.Component}
+ * @class MaxVelocityComponent
+ * @param {object} config a configuration object to extend.
+ */
+export default class MaxVelocityComponent extends Component {
+ constructor(config) {
+
+ super(config);
+
+ /**
+ * The properthy that holds the max velocity
+ *
+ * @property {number} maxVelocity
+ * @instance
+ * @memberof MaxVelocityComponent
+ */
+ this.maxVelocity = this.maxVelocity || 20;
+ }
+};
+