+class Door extends Phaser.TileSprite {
+ constructor(x, y, name, rotation, vector, longpanel) {
+ super(game, x, y, 64, 64, 'objects');
+ this.name = name;
+ if (!longpanel) {
+ this.anchor = new Phaser.Point(0.5, 0.5);
+ this.tilePosition = new Phaser.Point(-64, -64);
+ this.openvector = Phaser.Point.multiply(vector, new Phaser.Point(56, 56));
+ }
+ else {
+ this.width *= 2;
+ this.anchor = new Phaser.Point(0.75, 0.5);
+ this.tilePosition = new Phaser.Point(0, -64);
+ this.openvector = Phaser.Point.multiply(vector, new Phaser.Point(116, 116));
+ }
+ this.rotation = rotation * (Math.PI / 180);
+ console.log("Calculated vector:", this.openvector);
+ this.closetween = game.add.tween(this).to({ x: this.position.x, y: this.position.y }, 1000, Phaser.Easing.Sinusoidal.InOut, false, 0, 0, false);
+ this.openposition = Phaser.Point.add(this.position, this.openvector);
+ this.opentween = game.add.tween(this).to({ x: this.openposition.x, y: this.openposition.y }, 1000, Phaser.Easing.Sinusoidal.InOut, false, 0, 0, false);
+ this.isOpen = false;
+ }
+
+ open() {
+ if (!this.isOpen) {
+ this.opentween.start();
+ this.isOpen = true;
+ }
+ }
+
+ close() {
+ if (this.isOpen) {
+ this.closetween.start();
+ this.isOpen = false;
+ }
+ }
+}
+