Skip to content

Instantly share code, notes, and snippets.

@vagmi
Last active December 28, 2021 15:22
Show Gist options
  • Save vagmi/1bc229918063cd787cd2229f6c443a01 to your computer and use it in GitHub Desktop.
Save vagmi/1bc229918063cd787cd2229f6c443a01 to your computer and use it in GitHub Desktop.
PrinceJS hacks
(function() {
document.addEventListener("keypress", function(evt) {
console.log(evt.which);
let state = Phaser.GAMES[0].state.getCurrentState();
let player = state.ui.player;
if (evt.which == 116 && player != null) {
player.addLife();
};
if (evt.which == 102 && player != null) {
player.floatFall();
};
if (evt.which == 107) {
let enemy = state.enemies.filter((e) => e.room == state.currentRoom)[0];
if (enemy != undefined) {
enemy.die();
}
}
if (evt.which == 115 && player != null) {
player.gotSword();
}
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment