Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created October 3, 2020 21:39
Show Gist options
  • Save flushpot1125/5145285ea6a9c65af0e6d28451a3da5d to your computer and use it in GitHub Desktop.
Save flushpot1125/5145285ea6a9c65af0e6d28451a3da5d to your computer and use it in GitHub Desktop.
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