Skip to content

Commit

Permalink
Added README, fixed bug with component name, added GIF.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-schroeder-dev committed Oct 4, 2020
1 parent ce16e58 commit 3194c3e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
<script type="text/javascript" src="jump.js"></script>
```

## Usage

```html
<a-camera
jump="
height: 5;
interval: 2000;
timingFunction;
"
>
</a-camera>
```

## 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/)
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<body>
<a-scene>

<a-camera jump="height: 4; interval: 1000;" wasd-controls="acceleration: 1000">
<a-camera jump="height: 8; interval: 2000;" wasd-controls="acceleration: 1000">
<a-cursor></a-cursor>
</a-camera>

Expand Down
Binary file added jump.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions jump.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const JUMP_KEY = ' ';

AFRAME.registerComponent('jump-refined', {
AFRAME.registerComponent('jump', {
schema: {
height: {
type: 'number',
Expand All @@ -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(() => {
Expand Down

0 comments on commit 3194c3e

Please sign in to comment.