Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
create(tilemap, tileset, withTSAnimation)
{
this.keyLeft = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.LEFT);
this.keyRight = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.RIGHT);
this.keyUp = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.UP);
this.keyDown = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.DOWN);
this.withTSAnimation = withTSAnimation;
this.map = this.add.tilemap(tilemap);
this.tileset = this.map.addTilesetImage(tileset);
for(let i=0; i
create(tilemap, tileset, withTSAnimation)
{
this.keyLeft = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.LEFT);
this.keyRight = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.RIGHT);
this.keyUp = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.UP);
this.keyDown = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.DOWN);
this.withTSAnimation = withTSAnimation;
this.map = this.add.tilemap(tilemap);
this.tileset = this.map.addTilesetImage(tileset);
for(let i=0; i
import { log } from "../Utils"
import amber from "../images/amber.png"
import armor from "../images/armor.png"
import cardback from "../images/cardback.jpg" // TODO load via HTTP request
import damage from "../images/damage.png"
import forgedKey from "../images/forgedkey.png"
import unforgedKey from "../images/unforgedkey.png"
import jargogle from "../images/jargogle.png"
import kelifiDragon from "../images/kelifi-dragon.jpg" // TODO
import mantleOfTheZealot from "../images/mantle-of-the-zealot.png"
import power from "../images/power.png"
import safePlace from "../images/safe-place.png"
import stun from "../images/stun.png"
const { KeyCodes } = Phaser.Input.Keyboard
class GameScene extends Phaser.Scene {
// @ts-ignore
root: Phaser.GameObjects.Container
// @ts-ignore
cardHoverImage: Phaser.GameObjects.Image | undefined
// @ts-ignore
creatureMousingOver: Phaser.GameObjects.GameObject | undefined
keysDown: {
[key: string]: boolean
}
constructor() {
super("GameScene")
this.keysDown = {}
}
handleInput(event) {
if (event.keyCode == 9) {
return;
}
let entry = window.chat.querySelector("input[type='text']");
if (event.keyCode == 84) {
if (!window.conversationBoxOpened) {
this.handleConversationBox();
window.conversationBoxOpened = true;
return;
}
}
if (window.conversationBoxOpened) {
if (event.keyCode === Phaser.Input.Keyboard.KeyCodes.ENTER) {
this.player.addMessageBox(entry.value);
if (entry.value === "14") {
this.start_the_game_sound.play();
}
if (entry.value === "9") {
this.ooh_sound.play();
}
window.socket.emit('message', {
x: this.player.x,
y: this.player.y,
message: entry.value
});
window.chat.classList.add('remove');
window.chat.classList.remove('active');
entry.value = '';
window.conversationBoxOpened = false;
if (entry.value === "14") {
this.start_the_game_sound.play();
}
if (entry.value === "9") {
this.ooh_sound.play();
}
window.socket.emit('message', {
x: this.player.x,
y: this.player.y,
message: entry.value
});
window.chat.classList.add('remove');
window.chat.classList.remove('active');
entry.value = '';
window.conversationBoxOpened = false;
} else if (event.keyCode === Phaser.Input.Keyboard.KeyCodes.ESC) {
window.chat.classList.add('remove');
window.chat.classList.remove('active');
entry.value = '';
window.conversationBoxOpened = false;
}
}
if (!window.conversationBoxOpened) {
if (event.key == 'h') {
this.spentMeat();
}
if (event.keyCode == 32) {
this.handleCombat();
}
} else {
protected init() {
this.fillKey = this.scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.F, false);
this.transparentKey = this.scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.R, false);
this.visibilityKey = this.scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.V, false);
this.container = this.scene.add.container(0, 0);
this.container.depth = 1000;
}
protected init() {
this.fillKey = this.scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.F, false);
this.transparentKey = this.scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.R, false);
this.visibilityKey = this.scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.V, false);
this.container = this.scene.add.container(0, 0);
this.container.depth = 1000;
}
setupKeyboardListeners() {
const dispatch = this.data.get("dispatch")
const spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE)
spaceBar.on("up", () => {
dispatch({ type: Event.EndTurn, })
this.render()
})
this.input.keyboard.on("keydown", (e: any) => {
this.keysDown[e.which] = true
})
this.input.keyboard.on("keyup", (e: any) => {
this.keysDown[e.which] = false
let cardID
if (this.creatureMousingOver)
cardID = this.creatureMousingOver.data.get("id")
create(tilemap, tileset, withTSAnimation)
{
this.keyLeft = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.LEFT);
this.keyRight = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.RIGHT);
this.keyUp = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.UP);
this.keyDown = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.DOWN);
this.withTSAnimation = withTSAnimation;
this.map = this.add.tilemap(tilemap);
this.tileset = this.map.addTilesetImage(tileset);
for(let i=0; i {
this.transition = false;
private _inputHander(): void {
const { left, right, up, down } = this.cursorKeys;
if (left.isDown) {
this.hero.move(-1);
} else if (right.isDown) {
this.hero.move(1);
} else {
this.hero.move(0);
}
if (Phaser.Input.Keyboard.JustDown(up)) {
this.hero.jump();
}
}