added attacks and dynamic enemy spawning

Signed-off-by: Pascal Syma <pascal@syma.dev>
This commit is contained in:
2020-07-13 16:37:56 +02:00
parent 7c4d08cf8f
commit c2befeaa2b
9 changed files with 80 additions and 16 deletions
+8 -2
View File
@@ -5,6 +5,7 @@
import Entity from "./Entity";
import AttackA from "./Attacks/AttackA";
import AttackB from "./Attacks/AttackB";
export default class Player extends Entity {
@@ -21,8 +22,10 @@ export default class Player extends Entity {
this.play('idle');
this.attackA = new AttackA(this);
this.attackB = new AttackB(this);
this.attackHitbox = this.scene.add.group([
this.attackA
this.attackA,
this.attackB
]);
this.items = [];
@@ -86,7 +89,10 @@ export default class Player extends Entity {
} else if (this.scene.keySpace.isDown) {
// const nextAttack = [this.attackA].sort(() => 0.5 - Math.random())[0];
// nextAttack.start();
this.attackA.start();
if (this.scene.upActive())
this.attackA.start();
else
this.attackB.start();
} else if (this.body.blocked.down) {
if (this.body.velocity.x !== 0) {
this.play('run', true);