Skip to content

Commit

Permalink
Added Win amount to the Scoreboard
Browse files Browse the repository at this point in the history
  • Loading branch information
asiryk committed Sep 15, 2020
1 parent 4f2f160 commit 6a0d413
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/core/Scoreboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import * as PIXI from 'pixi.js';
export default class Scoreboard {
public container: PIXI.Container;
public outOfMoney = false;
private winAmountText: PIXI.Text;
private moneyText: PIXI.Text;
private winAmount: number = 0;
private money: number = 100;
private bet: number = 5;

Expand All @@ -25,6 +27,8 @@ export default class Scoreboard {
increment() {
this.money += this.bet * 2;
this.moneyText.text = `money: $${this.money}`;
this.winAmount += this.bet;
this.winAmountText.text = `win: $${this.winAmount}`;
if (this.outOfMoney) this.outOfMoney = false;
}

Expand All @@ -41,15 +45,19 @@ export default class Scoreboard {
const betText = new PIXI.Text(`bet: $${this.bet}`, style);
betText.y = this.moneyText.height + 10;

betText.x = this.moneyText.x = 10;
this.winAmountText = new PIXI.Text(`win: $${this.winAmount}`, style);
this.winAmountText.y = betText.y + betText.height + 5;

betText.x = this.moneyText.x = this.winAmountText.x = 10;

const rect = new PIXI.Graphics();
rect.beginFill(0x02474E, 0.8);
rect.drawRect(0, 0, 160, this.moneyText.height + betText.height + 20);
const rectHeight = this.moneyText.height + betText.height + this.winAmountText.height + 25;
rect.drawRect(0, 0, 160, rectHeight);
rect.endFill();

this.container.x = appWidth - rect.width - 7;
this.container.y = appHeight / 2 + 70;
this.container.addChild(rect, this.moneyText, betText);
this.container.addChild(rect, this.moneyText, betText, this.winAmountText);
}
}

0 comments on commit 6a0d413

Please sign in to comment.