How to use the rot-js.VK_NUMPAD2 function in rot-js

To help you get started, we’ve selected a few rot-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Larkenx / Rotten-Soup / src / assets / js / game / entities / actors / Player.js View on Github external
handleNPCDialogueEvent(evt) {
		let { keyCode } = evt
		// evt.preventDefault()
		const confirm = [ROT.VK_RETURN, ROT.VK_E]
		const up = [ROT.VK_UP, ROT.VK_NUMPAD8, ROT.VK_W, ROT.VK_K]
		const down = [ROT.VK_DOWN, ROT.VK_NUMPAD2, ROT.VK_S, ROT.VK_J]
		const numbers = [ROT.VK_1, ROT.VK_2, ROT.VK_3, ROT.VK_4, ROT.VK_5, ROT.VK_6, ROT.VK_7, ROT.VK_8, ROT.VK_9]
		const dialogue = Game.overlayData.dialogue
		const selectedChoiceIndex = dialogue.selectedChoice // the index of the choice we've selected
		const choices = Game.overlayData.dialogue.getChoices()
		if (confirm.includes(keyCode)) {
			// select that choice and proceed in dialog
			const selectedChoice = choices[selectedChoiceIndex] // the selected choice
			dialogue.selectChoice(selectedChoice)
		} else if (numbers.includes(keyCode)) {
			const index = keyCode - 49 // the key code for 1 starts at 49 leading up to 57
			if (index <= choices.length - 1) {
				dialogue.selectChoice(choices[index])
			}
		} else if (down.includes(keyCode)) {
			if (selectedChoiceIndex < choices.length - 1) Game.overlayData.dialogue.selectedChoice++
		} else if (up.includes(keyCode)) {
github seiyria / Roguathia / src / js / rogue / init / debug.js View on Github external
document.body.addEventListener('keydown', (e) => {

    const offsets = {
      [ROT.VK_W]: { x: 0, y: -1 },
      [ROT.VK_S]: { x: 0, y: 1 },
      [ROT.VK_A]: { x: -1, y: 0 },
      [ROT.VK_D]: { x: 1, y: 0 },

      [ROT.VK_NUMPAD8]: { x: 0, y: -1 },
      [ROT.VK_NUMPAD2]: { x: 0, y: 1 },
      [ROT.VK_NUMPAD4]: { x: -1, y: 0 },
      [ROT.VK_NUMPAD6]: { x: 1, y: 0 },

      [ROT.VK_NUMPAD7]: { x: -1, y: -1 },
      [ROT.VK_NUMPAD3]: { x: 1, y: 1 },
      [ROT.VK_NUMPAD1]: { x: -1, y: 1 },
      [ROT.VK_NUMPAD9]: { x: 1, y: -1 }
    };

    if(!offsets[e.keyCode] || !GameState.manualMove) return;

    const player = GameState.players[0];
    player.moveTo(player.x+offsets[e.keyCode].x, player.y+offsets[e.keyCode].y);
    GameState.game.engine.unlock();
  });
};