Added commas to score

This commit is contained in:
Rob Pearce 2016-08-21 07:56:41 +10:00
parent 657ca89d4e
commit 5cc296e61f
2 changed files with 31 additions and 11 deletions

View File

@ -503,6 +503,10 @@ function drawline(ctx,x1,y1,x2,y2,col,width) {
ctx.stroke(); ctx.stroke();
} }
function addcommas(num) {
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
function drawarrow(ctx,x1,y1,x2,y2,col,width, arrowsize) { function drawarrow(ctx,x1,y1,x2,y2,col,width, arrowsize) {
drawline(ctx, x1, y1, x2, y2, col, width); drawline(ctx, x1, y1, x2, y2, col, width);
drawarrowhead(ctx, x1, y1, x2, y2, col, arrowsize); drawarrowhead(ctx, x1, y1, x2, y2, col, arrowsize);
@ -690,7 +694,7 @@ var game = {
this.context.textAlign = "left"; this.context.textAlign = "left";
this.context.textBaseline = "top"; this.context.textBaseline = "top";
this.context.fillStyle = "white"; this.context.fillStyle = "white";
this.context.fillText("Score: " + score, 16, 16); this.context.fillText("Score: " + addcommas(score), 16, 16);
switch (thingsmoving()) { switch (thingsmoving()) {
case "parade": case "parade":
@ -722,7 +726,7 @@ var game = {
this.context.textAlign = "center"; this.context.textAlign = "center";
this.context.textBaseline = "top"; this.context.textBaseline = "top";
shadowtext(this.context, "GAME OVER", 20, "red", SCREENW / 2, 5); shadowtext(this.context, "GAME OVER", 20, "red", SCREENW / 2, 5);
shadowtext(this.context, "Final Score: " + score, 16, "white", SCREENW / 2, 35); shadowtext(this.context, "Final Score: " + addcommas(score), 16, "white", SCREENW / 2, 35);
} }
}, },

34
todo
View File

@ -29,18 +29,34 @@ phone fixes as per http://www.html5rocks.com/en/mobile/touch/
https://www.smashingmagazine.com/2012/10/design-your-own-mobile-game/ https://www.smashingmagazine.com/2012/10/design-your-own-mobile-game/
bath time, then next level after getting sufficient llamas *put commas in score
need 5 llamas on first level
then 10, then 15, etc. different levels with goals
new levels: eat x cheese
obstacles get x parades
larger grid get x llamas
new object types ? break x obstacles
get x goats
etc.
later levels have multiple goals
use the bottom of the screen to show level goals
title screen -> level select
certain levels have help screens (ie. lev 1 is initial help)
remember which level you're up to
after each level, show cat picture.
put commas in score sounds:
chomp
catparade (can-can ?)
indy theme - title screen?
(if so, make title text indy themed too)
use the bottom of the screen for something.