Skip to content

Commit

Permalink
Background ceiling layers
Browse files Browse the repository at this point in the history
  • Loading branch information
Matojeje committed Aug 21, 2024
1 parent f596eb9 commit 257baa9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/assets/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ const images: Image[] = [
image('backgrounds/grid3', 'grid3'),
image('backgrounds/grid4', 'grid4'),

// Background tops
image('backgrounds/grid1-top', 'grid1-top'),
image('backgrounds/grid2-top', 'grid2-top'),
image('backgrounds/grid3-top', 'grid3-top'),
image('backgrounds/grid4-top', 'grid4-top'),

// Cutscenes
image('cutscenes/dummy1', 'cutscene_dummy1'),
image('cutscenes/dummy2', 'cutscene_dummy2'),
Expand Down
Binary file added src/assets/images/backgrounds/grid1-top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/backgrounds/grid2-top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/backgrounds/grid3-top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/backgrounds/grid4-top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/scenes/GameScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum GameState {

export class GameScene extends BaseScene {
private background: Phaser.GameObjects.Image;
private backgroundTop: Phaser.GameObjects.Image;
private board: Board;
private stations: Station[];
private employees: Employee[];
Expand Down Expand Up @@ -160,6 +161,11 @@ export class GameScene extends BaseScene {
this.background = this.add.image(0, 0, "grid1");
this.background.setOrigin(0);
this.fitToScreen(this.background);

this.backgroundTop = this.add.image(0, 0, "grid1-top");
this.backgroundTop.setOrigin(0);
this.backgroundTop.setDepth(50);
this.fitToScreen(this.backgroundTop);

this.board = new Board(this, this.CX, this.CY, 6, 4, 100);

Expand Down Expand Up @@ -415,6 +421,16 @@ export class GameScene extends BaseScene {
const level = LevelData[id];

this.background.setTexture(level.background);
const topKey = `${level.background}-top`;

if (this.textures.exists(topKey)) {
this.backgroundTop.setVisible(true);
this.backgroundTop.setTexture(topKey);
// this.backgroundTop.setTint(0xff0000); // Debug
} else {
this.backgroundTop.setVisible(false);
}

this.board.resize(level.width, level.height, level.cellSize);

// Clear all stations, employees, and customers
Expand Down

0 comments on commit 257baa9

Please sign in to comment.