diff --git a/README.md b/README.md new file mode 100644 index 0000000..2978ad3 --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Jump + +Jump is an A-Frame component that allows a player to jump on keypress. + +## Installation + +Include the component file in the head of your HTML document: + +```html + +``` + +## Usage + +```html + + +``` + +## Parameters + +| Parameter | Default | Description | +|--------------------|---------|-------------| +| **height** | 5 | The height your player will jump| +| **interval** | 1000 | The total time of the jump (in milliseconds)| +| **timingFunction** | linear | The timing function used to control the jump.| + +## Example + +![](jump.gif) + +## Contributing +Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. + + +## License +[MIT](https://choosealicense.com/licenses/mit/) diff --git a/index.html b/index.html index 9bfbb49..299610e 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ - + diff --git a/jump.gif b/jump.gif new file mode 100644 index 0000000..37b0e7d Binary files /dev/null and b/jump.gif differ diff --git a/jump.js b/jump.js index 46b7446..d335081 100644 --- a/jump.js +++ b/jump.js @@ -1,6 +1,6 @@ const JUMP_KEY = ' '; -AFRAME.registerComponent('jump-refined', { +AFRAME.registerComponent('jump', { schema: { height: { type: 'number', @@ -15,7 +15,7 @@ AFRAME.registerComponent('jump-refined', { init: function() { document.addEventListener('keydown', e => { if (e.key != JUMP_KEY) return; - + const upInterval = setInterval(() => this.el.object3D.position.y += this.data.height / this.data.interval, 10); setTimeout(() => {