Skip to content
Harsh Singh edited this page Jul 22, 2022 · 3 revisions

getDirection

It returns a Vector 2D Object and the movement input from keyboard are mapped to this object.

Example

const direction = Bottlecap.Keyboard.getDirection();

player.position.x += direction.x * SPEED * dt;
player.position.y += direction.y * SPEED * dt;

keyDown

Checks if a key is down

Example

if(Keyboard.keyDown(Keyboard.KEYS.SPACEBAR)) {
  player.jump();
}
Clone this wiki locally