diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bed4f61..72f5ab0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,6 +24,9 @@ jobs: npm install npm run build # Adjust to your build command + - name: Save commit id to file + run: echo "$(git rev-parse --short HEAD)" >> dist/latest_commit + # Step 4: Deploy to GitHub Pages - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 diff --git a/index.html b/index.html index 9cf28ae..707302d 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,7 @@ + Bastion App diff --git a/public/latest_commit b/public/latest_commit new file mode 100644 index 0000000..6ab709b --- /dev/null +++ b/public/latest_commit @@ -0,0 +1 @@ +2f2a5s \ No newline at end of file diff --git a/src/classes/Assets.ts b/src/classes/Assets.ts index 0bb3833..06a2c74 100644 --- a/src/classes/Assets.ts +++ b/src/classes/Assets.ts @@ -61,6 +61,9 @@ export default class GameAssets { GameAssets.BasicProjectileTexture = await PIXI.Assets.load({ src: '/assets/projectiles/basic_tower.png', }); + await PIXI.Assets.load({ + src: 'https://fonts.googleapis.com/css?family=Aclonica', + }); await this.LoadMissions(); await this.LoadTowers(); diff --git a/src/classes/Bastion.ts b/src/classes/Bastion.ts index 41c0b5f..3b286a7 100644 --- a/src/classes/Bastion.ts +++ b/src/classes/Bastion.ts @@ -17,6 +17,7 @@ export class Globals { public static WaveManager: WaveManager; public static TowerManager: TowerManager; public static GameScene: GameScene; + public static latestCommit: string; } export default class GameMaster { diff --git a/src/main.ts b/src/main.ts index a82bddf..5c9990c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -50,7 +50,7 @@ import { log } from './utils'; app.canvas.style.marginBottom = `0`; // Prevent unnecessary margin app.canvas.style.display = 'block'; // Prevent inline-block spacing issues } - + Globals.latestCommit = await fetch('/latest_commit').then((res) => res.text()); window.addEventListener('resize', resize); resize(); await Assets.LoadAssets(); diff --git a/src/scenes/Main.ts b/src/scenes/Main.ts index 8087807..ca28817 100644 --- a/src/scenes/Main.ts +++ b/src/scenes/Main.ts @@ -8,21 +8,58 @@ export class MainScene extends Scene { public init() { const NewGameButton = { caption: 'New Game', - rect: new PIXI.Rectangle(Globals.WindowWidth / 2 - 300 / 2, Globals.WindowHeight / 2 - 80, 300, 60), - texture: ButtonTexture.Button01, + rect: new PIXI.Rectangle( + Globals.app.canvas.width / 2 - 300 / 2, + Globals.app.canvas.height / 5 + 3 * 80, + 300, + 60 + ), + texture: ButtonTexture.Button02, }; const SettingsButton = { caption: 'Settings', - rect: new PIXI.Rectangle(Globals.WindowWidth / 2 - 300 / 2, Globals.WindowHeight / 2 + 20, 300, 60), - texture: ButtonTexture.Button01, + rect: new PIXI.Rectangle( + Globals.app.canvas.width / 2 - 300 / 2, + Globals.app.canvas.height / 5 + 4 * 80, + 300, + 60 + ), + texture: ButtonTexture.Button02, }; - + let text = new PIXI.Text({ + x: Globals.app.canvas.width / 2 - 300 / 2, + y: Globals.app.canvas.height / 5 + 1 * 80, + text: 'BASTION', + style: { + fill: 0xffaa00, + fontFamily: 'Aclonica', + fontSize: 100, + }, + }); + text.x = text.x - text.width / 5; + Globals.app.stage.addChild(text); + let text2 = new PIXI.Text({ + x: 0, + y: 0, + text: 'Latest commit: ' + Globals.latestCommit, + style: { + fill: 0x000000, + fontSize: 10, + fontWeight: 'bold', + }, + }); + Globals.app.stage.addChild(text2); const button01 = new Button(NewGameButton.rect, NewGameButton.caption, NewGameButton.texture, true); button01.onClick = (e) => { + Globals.app.stage.removeChild(text); + Globals.app.stage.removeChild(text2); Globals.GameMaster.changeScene(new MissionPickerScene()); }; - new Button(SettingsButton.rect, SettingsButton.caption, SettingsButton.texture, true); + let b2 = new Button(SettingsButton.rect, SettingsButton.caption, SettingsButton.texture, true); + b2.onClick = (e) => { + alert('Does nothing for now, just placeholder.'); + }; } } diff --git a/src/scenes/MissionPicker.ts b/src/scenes/MissionPicker.ts index c54b2f4..0023118 100644 --- a/src/scenes/MissionPicker.ts +++ b/src/scenes/MissionPicker.ts @@ -2,11 +2,16 @@ import Assets from '../classes/Assets'; import { Globals } from '../classes/Bastion'; import Button, { ButtonTexture } from '../classes/gui/Button'; import { GameScene } from './Game'; +import { MainScene } from './Main'; import Scene from './Scene'; import * as PIXI from 'pixi.js'; export class MissionPickerScene extends Scene { public init() { + const button = new Button(new PIXI.Rectangle(0, 0, 300, 60), 'Back to main', ButtonTexture.Button01); + button.onClick = (e) => { + Globals.GameMaster.changeScene(new MainScene()); + }; Assets.Missions.forEach((mission, index) => { const button = new Button( new PIXI.Rectangle(