added win screen and level system
Signed-off-by: Pascal Syma <pascal@syma.dev>
This commit is contained in:
+15
-3
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user