added Storage and ControlsSettings
Signed-off-by: Pascal Syma <pascal@syma.dev>
This commit is contained in:
+18
-30
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Pascal Syma <pascal@syma.dev>
|
||||
* Copyright (c) 2020. Antonio Martinez Casadesus and Pascal Syma.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
import Player from "../entities/Player";
|
||||
import Bat from "../entities/Enemys/Bat";
|
||||
import Item from "../entities/Item";
|
||||
import Storage from "../Storage";
|
||||
|
||||
export default class Game extends Phaser.Scene {
|
||||
|
||||
@@ -153,12 +154,12 @@ export default class Game extends Phaser.Scene {
|
||||
let bat = new Bat(this, s);
|
||||
bat.fly(s.type === "" ? 90 : parseInt(s.type));
|
||||
this.enemys.add(bat)
|
||||
})
|
||||
});
|
||||
|
||||
map.objects[0].objects.filter(obj => obj.name === "item").forEach(s => {
|
||||
let item = new Item(this, s);
|
||||
this.items.add(item)
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
this.worldLayer.setCollisionByProperty({collides: true});
|
||||
@@ -167,7 +168,7 @@ export default class Game extends Phaser.Scene {
|
||||
bottom: false,
|
||||
right: false,
|
||||
left: false
|
||||
})
|
||||
});
|
||||
|
||||
this.physics.world.bounds.width = this.backLayer.width;
|
||||
this.physics.world.bounds.height = this.backLayer.height;
|
||||
@@ -185,21 +186,18 @@ export default class Game extends Phaser.Scene {
|
||||
if (h.getData('active') && h.overlap !== undefined) {
|
||||
h.overlap(b);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
this.keyW = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.W);
|
||||
this.keyS = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.S);
|
||||
this.keyA = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.A);
|
||||
this.keyD = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.D);
|
||||
this.keySpace = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE);
|
||||
this.keyUp = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.UP);
|
||||
this.keyLeft = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.LEFT);
|
||||
this.keyRight = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.RIGHT);
|
||||
this.keyDown = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.DOWN);
|
||||
let controls = Storage.get().controls;
|
||||
|
||||
this.keyW = this.input.keyboard.addKey(controls.jump.bind);
|
||||
this.keyA = this.input.keyboard.addKey(controls.w_left.bind);
|
||||
this.keyD = this.input.keyboard.addKey(controls.w_right.bind);
|
||||
this.keySpace = this.input.keyboard.addKey(controls.attack.bind);
|
||||
// this.keyDie = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.C);
|
||||
this.keyPickup = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.C);
|
||||
this.keyAction1 = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q);
|
||||
this.keyAction2 = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E);
|
||||
this.keyPickup = this.input.keyboard.addKey(controls.pickup.bind);
|
||||
this.keyAction1 = this.input.keyboard.addKey(controls.use_left.bind);
|
||||
this.keyAction2 = this.input.keyboard.addKey(controls.use_right.bind);
|
||||
|
||||
this.physics.add.overlap(this.player, this.items, (p, i) => {
|
||||
if (this.keyPickup.isDown && i.canPickup()) {
|
||||
@@ -217,28 +215,18 @@ export default class Game extends Phaser.Scene {
|
||||
|
||||
}
|
||||
|
||||
dieActive() {
|
||||
return false;
|
||||
// return this.keyDie.isDown;
|
||||
}
|
||||
|
||||
rightActive() {
|
||||
return this.keyRight.isDown || this.keyD.isDown/* || (this.game.input.activePointer.isDown &&
|
||||
return /*this.keyRight.isDown || */this.keyD.isDown/* || (this.game.input.activePointer.isDown &&
|
||||
this.game.input.activePointer.x > 2*this.game.config.width/3)*/;
|
||||
}
|
||||
|
||||
leftActive() {
|
||||
return this.keyLeft.isDown || this.keyA.isDown/* || (this.game.input.activePointer.isDown &&
|
||||
return /*this.keyLeft.isDown || */this.keyA.isDown/* || (this.game.input.activePointer.isDown &&
|
||||
this.game.input.activePointer.x < this.game.config.width/3)*/;
|
||||
}
|
||||
|
||||
downActive() {
|
||||
return this.keyDown.isDown || this.keyS.isDown/* || (this.game.input.activePointer.isDown &&
|
||||
this.game.input.activePointer.y > 2*this.game.config.height/3)*/;
|
||||
}
|
||||
|
||||
upActive() {
|
||||
return this.keyUp.isDown || this.keyW.isDown/* || (this.game.input.activePointer.isDown &&
|
||||
return /*this.keyUp.isDown || */this.keyW.isDown/* || (this.game.input.activePointer.isDown &&
|
||||
this.game.input.activePointer.y < this.game.config.height/3)*/;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user