Skip to content

Commit

Permalink
WIP on phaser version update
Browse files Browse the repository at this point in the history
  • Loading branch information
mipearson committed Nov 16, 2019
1 parent f24fb45 commit 714eb99
Show file tree
Hide file tree
Showing 7 changed files with 3,118 additions and 74,349 deletions.
5,791 changes: 3,101 additions & 2,690 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"dependencies": {
"dungeon-factory": "^1.0.6",
"mrpas": "^1.2.1",
"parcel": "^1.9.7",
"phaser": "^3.13.0",
"typescript": "^3.0.3"
"parcel": "^1.12.4",
"phaser": "^3.20.1",
"typescript": "^3.7.2"
}
}
2 changes: 1 addition & 1 deletion src/entities/Map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export default class Map {
}
}
wallLayer.setCollisionBetween(0, 256);
this.tilemap.convertLayerToStatic(groundLayer);
this.wallLayer = this.tilemap.convertLayerToStatic(wallLayer);
// this.tilemap.convertLayerToStatic(groundLayer);
}

tileAt(x: number, y: number): Tile | null {
Expand Down
23 changes: 4 additions & 19 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,15 @@ import ReferenceScene from "./scenes/ReferenceScene";
import DungeonScene from "./scenes/DungeonScene";
import InfoScene from "./scenes/InfoScene";

const game = new Phaser.Game({
new Phaser.Game({
type: Phaser.WEBGL,
// TODO: OnResize
width: window.innerWidth,
height: window.innerHeight,
render: { pixelArt: true },
physics: { default: "arcade", arcade: { debug: false, gravity: { y: 0 } } },
scene: [DungeonScene, InfoScene, ReferenceScene]
});

function setUpHotReload() {
// @ts-ignore
if (module.hot) {
// @ts-ignore
module.hot.accept(() => {});
// @ts-ignore
module.hot.dispose(() => {
window.location.reload();
});
}
}

setUpHotReload();

window.addEventListener("resize", () => {
game.resize(window.innerWidth, window.innerHeight);
});
// window.addEventListener("resize", () => {
// game.resize(window.innerWidth, window.innerHeight);
// });
1 change: 1 addition & 0 deletions src/scenes/DungeonScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default class DungeonScene extends Phaser.Scene {
});

this.input.keyboard.on("keydown_R", () => {
console.log("keydown_r");
this.scene.stop("InfoScene");
this.scene.start("ReferenceScene");
});
Expand Down
9 changes: 8 additions & 1 deletion src/scenes/ReferenceScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ export default class ReferenceScene extends Phaser.Scene {
group: Phaser.GameObjects.Group | null;
map: Phaser.Tilemaps.Tilemap | null;
title: Phaser.GameObjects.Text | null;
metrics: object | null;

constructor() {
super("ReferenceScene");
this.index = 0;
this.group = null;
this.map = null;
this.title = null;
this.metrics = null;
}

preload(): void {
tilesets.forEach(t => this.load.image(t.name, t.file));
}

create(): void {
console.log("create referencescene");
this.title = this.add.text(20, 10, "", { fontSize: 14 });
this.previewTileset();
this.input.keyboard.on("keydown_N", () => {
Expand Down Expand Up @@ -88,9 +91,13 @@ export default class ReferenceScene extends Phaser.Scene {
this.map.tileToWorldY(y),
idx.toString(16),
{
fontSize: 14
fontSize: 14,
metrics: this.metrics
}
);
if (!this.metrics) {
this.metrics = text.getTextMetrics();
}
text.setDepth(10);
this.group.add(text);
layer.putTileAt(idx, x, y);
Expand Down
Loading

0 comments on commit 714eb99

Please sign in to comment.