aboutsummaryrefslogtreecommitdiffstats
path: root/src/drawables/TopBar.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/drawables/TopBar.ts')
-rw-r--r--src/drawables/TopBar.ts23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/drawables/TopBar.ts b/src/drawables/TopBar.ts
index d92db07..4bd525a 100644
--- a/src/drawables/TopBar.ts
+++ b/src/drawables/TopBar.ts
@@ -10,13 +10,17 @@ export class TopBar extends Drawable {
lives = 0;
rolls = 0;
highscore = 0;
+ shootedDown = 0;
+ bgd = 0;
constructor() {
super(0, 0)
}
- setData(score: number, lives: number, rolls: number, highscore?: number | string) {
+ setData(score: number, lives: number, rolls: number, bgd: number, shootedDown: number, highscore?: number | string) {
this.score = score
this.lives = lives
this.rolls = rolls
+ this.bgd = bgd
+ this.shootedDown = shootedDown
if (highscore) {
if (typeof highscore === "string") highscore = parseInt(highscore)
this.highscore = highscore
@@ -26,7 +30,6 @@ export class TopBar extends Drawable {
if (this.sprite.src == null) this.sprite = IMGS.topbar;
ctx.drawImage(this.sprite, 0, 0);
[...this.score.toString().padStart(7, '0')].forEach((char, i) => {
- ctx.imageSmoothingEnabled = false
ctx.drawImage(IMGS.font.small.white[char], 24 + i * 8, 8)
});
for (let i = 0; i < this.lives; i++) {
@@ -36,9 +39,23 @@ export class TopBar extends Drawable {
ctx.drawImage(IMGS.rollIcon, 177 + i * 8, 9)
}
[...this.highscore.toString().padStart(7, '0')].forEach((char, i) => {
- ctx.imageSmoothingEnabled = false
ctx.drawImage(IMGS.font.small.white[char], 240 + i * 8, 8)
});
+ if (this.bgd >= 2580) {
+ // 9 41
+ [..."shooting down ".split(''), ...(this.shootedDown / 32).toFixed(0).toString().padStart(3, '0').split(''), '%'].forEach((char, i) => {
+ ctx.drawImage(IMGS.font.white[char], 9 + i * 17, 41, 15, 8)
+ });
+ [..."bonus".split('')].forEach((char, i) => {
+ ctx.drawImage(IMGS.font.white[char], 110 + i * 17, 94, 15, 8)
+ });
+ [...(this.lives * 500).toString().padStart(5, '0'), ..." pts".split('')].forEach((char, i) => {
+ ctx.drawImage(IMGS.font.white[char], 77 + i * 17, 108, 15, 8)
+ });
+ [...'rx1000=', ...(this.rolls * 1000).toString().padStart(4, '0'), ..." pts"].forEach((char, i) => {
+ ctx.drawImage(IMGS.font.yellow[char], 43 + i * 17, 147, 15, 8)
+ });
+ }
}
}