-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
170 additions
and
615 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[*.{js,ts}] | ||
indent_style = space | ||
indent_size = 4 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { Container, Loader, Sprite, Texture } from "pixi.js"; | ||
import { Assets, Container, Sprite, Texture } from "pixi.js"; | ||
|
||
export default class Background { | ||
public readonly sprite: Container; | ||
private readonly texture: Texture; | ||
|
||
constructor(loader: Loader) { | ||
this.texture = loader.resources.atlas.textures!['BG.png']; | ||
constructor() { | ||
this.texture = Assets.get("atlas").textures["BG.png"]; | ||
this.sprite = new Sprite(this.texture); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,39 @@ | ||
import { Application, Loader as PixiLoader, Text, TextStyle } from "pixi.js" | ||
import { Application, Assets, Text, TextStyle } from "pixi.js" | ||
|
||
export default class Loader { | ||
public loader: PixiLoader; | ||
private loadingScreen: Text; | ||
private app: Application; | ||
|
||
constructor(app: Application, onAssetsLoaded: () => void) { | ||
this.loader = app.loader; | ||
this.loadAssets(); | ||
this.loader.load(() => { | ||
app.stage.removeChild(this.loadingScreen); | ||
onAssetsLoaded(); | ||
}); | ||
this.generateLoadingScreen(app.screen.width, app.screen.height); | ||
app.stage.addChild(this.loadingScreen); | ||
constructor(app: Application) { | ||
this.app = app; | ||
this.loadingScreen = this.createLoadingScreen(app.screen.width, app.screen.height); | ||
} | ||
|
||
public showLoadingScreen() { | ||
this.app.stage.addChild(this.loadingScreen); | ||
} | ||
|
||
public hideLoadingScreen() { | ||
this.app.stage.removeChild(this.loadingScreen); | ||
} | ||
|
||
private loadAssets() { | ||
this.loader.add('atlas', './assets/atlas.json'); | ||
public async loadAssets() { | ||
this.showLoadingScreen(); | ||
Assets.add({ alias: "atlas", src: "./assets/atlas.json" }); | ||
await Assets.load(["atlas"]); | ||
this.hideLoadingScreen(); | ||
} | ||
|
||
private generateLoadingScreen(appWidth: number, appHeight: number) { | ||
private createLoadingScreen(appWidth: number, appHeight: number): Text { | ||
const style = new TextStyle({ | ||
fontFamily: 'Arial', | ||
fontFamily: "Arial", | ||
fontSize: 36, | ||
fontWeight: 'bold', | ||
fill: '#ffffff', | ||
fontWeight: "bold", | ||
fill: "#ffffff", | ||
}); | ||
const playText = new Text('Loading...', style); | ||
const playText = new Text({ text: "Loading...", style }); | ||
playText.x = (appWidth - playText.width) / 2; | ||
playText.y = (appHeight - playText.height) / 2; | ||
this.loadingScreen = playText; | ||
return playText; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Game from "./core/Game"; | ||
|
||
declare global { | ||
interface Window { | ||
game: Game; | ||
} | ||
} | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import Game from './core/Game'; | ||
import Game from "./core/Game"; | ||
|
||
new Game(); | ||
const game = new Game(); | ||
game.init(); | ||
window.game = game; |