added attacks and dynamic enemy spawning
Signed-off-by: Pascal Syma <pascal@syma.dev>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user