X-Git-Url: http://git.megabrutal.com/?p=wgj58.git;a=blobdiff_plain;f=wgj58.js;h=e034b01a3eeb3155b41d0c874e1150c64147cc79;hp=d29f4e8fe3f37bf1a4d6f929150055e23071e9b3;hb=a72760aadcd1a753f785ae0e7459b7a8c523e075;hpb=9545ed9488e2af5b42f3d4816a1f0c6b491a5f73 diff --git a/wgj58.js b/wgj58.js index d29f4e8..e034b01 100644 --- a/wgj58.js +++ b/wgj58.js @@ -39,6 +39,14 @@ class Dialogue { } } +class Door extends Phaser.TileSprite { + constructor(x, y, name, vector, longpanel) { + super(game, x, y, 64, 64, 'objects'); + this.tilePosition = new Phaser.Point(-64, -64); + console.log("New door:", this); + } +} + class Player extends Phaser.Sprite { constructor(x, y) { super(game, x, y, 'player'); @@ -381,12 +389,14 @@ class GameLogic { constructor() { this.player = this.clara = this.carlos = this.saiki = this.peter = this.bianca = null; this.gameinterface = new GameInterface(game, game.stage); + //this.doors = game.add.group(game.world, "doors"); this.last_menuselect = 0; } createObject(object) { switch (object.type) { case 'spawnpoint': this.createCharacter(object); break; + case 'door': this.createDoor(object); break; case '': console.error("Object type is empty:", object); break; default: console.error("Unknown object type:", object); } @@ -413,6 +423,19 @@ class GameLogic { console.log(newChar); } + createDoor(object) { + var vector; + switch (object.rotation) { + case undefined: + case 0: vector = new Phaser.Point( -1, 0); break; + case 90: vector = new Phaser.Point( 0, -1); break; + case 180: vector = new Phaser.Point( 1, 0); break; + case 270: vector = new Phaser.Point( 0, 1); break; + default: console.error("Invalid rotation:", object.rotation); + } + this.doors.add(new Door(object.x, object.y, object.name, vector, object.properties.longpanel)); + } + callMenu(menuitem) { console.log("Menu callback received:", menuitem); this.last_menuselect = game.time.now; @@ -493,6 +516,10 @@ class GamePlay extends Phaser.State { map.setCollisionBetween(1, 100, true, this.layer_walls); this.layer_furniture = map.createLayer('furniture'); map.setCollisionBetween(1, 100, true, this.layer_furniture); + + // FIXME: Don't create a group here like this, it's too ugly! Now I have it here due to the display order. + logic.doors = game.add.group(game.world, "doors"); + map.objects['objects'].forEach(function(o) { logic.createObject(o); }); console.log(map.objects);