Roguelike Development with JavaScript by Andre Alves Garzia

Roguelike Development with JavaScript by Andre Alves Garzia

Author:Andre Alves Garzia
Language: eng
Format: epub
ISBN: 9781484260593
Publisher: Apress


if (event.key == "ArrowRight") {

newX += 1

moved = true

}

if (event.key == "ArrowUp") {

newY -= 1

moved = true

}

if (event.key == "ArrowDown") {

newY += 1

moved = true

}

Instead of using this.cursor as in the previous samples, we’re now using the value of event.key to check if any cursor key was pressed. It is quite similar to the previous code, but since all that keyboard input handling logic is now contained in its own function, it becomes easier to maintain. // Execute movement

if (moved) {

this.movementPoints -= 1



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.