Created
October 3, 2020 21:39
-
-
Save flushpot1125/5145285ea6a9c65af0e6d28451a3da5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { onKeyboardEvent } from "../tools"; | |
export default class PlayerComponent extends Mesh { | |
// ... | |
/* | |
* An example of keycode reference : https://keycode.info/ | |
*/ | |
/** | |
* Moves the player on the left | |
*/ | |
@onKeyboardEvent(65, KeyboardEventTypes.KEYDOWN) | |
protected moveLeft(): void { | |
this.position.z += 5; | |
} | |
/** | |
* Moves the player on the right. | |
*/ | |
@onKeyboardEvent(68, KeyboardEventTypes.KEYDOWN) | |
protected moveRight(): void { | |
this.position.z -= 5; | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment