added win screen and level system

Signed-off-by: Pascal Syma <pascal@syma.dev>
This commit is contained in:
2020-07-17 03:20:59 +02:00
parent cea1740792
commit 13e7c24b65
16 changed files with 404 additions and 87 deletions
+15 -3
View File
@@ -39,14 +39,14 @@ export default class Player extends Entity {
interact(item) {
if (item instanceof Item) {
if (this.items.length >= 1) {
if (this.items.length >= 2) {
this.items.shift().setPosition(this.x, this.y).drop();
}
item.interact();
this.items[0] = item;
this.items[this.items.length] = item;
} else if (item instanceof Chest) {
item.interact();
}
@@ -119,10 +119,22 @@ export default class Player extends Entity {
c.update()
});
this.items.forEach(i => i.setPosition(this.body.x, this.body.y - 16));
if (this.items.length >= 1)
this.items[0].setPosition(this.body.x, this.body.y - 16);
if (this.items.length >= 2)
this.items[1].setPosition(this.body.x + 32, this.body.y - 16);
if (this.scene.keyAction1.isDown && this.items.length >= 1) {
this.items.shift().use(this);
this.scene.keyAction1.reset();
}
if (this.scene.keyAction2.isDown && this.items.length >= 2) {
this.items.pop().use(this);
this.scene.keyAction2.reset();
}
}