Tap 10 times to the right of 'level selection' to clear game data.
Loader will now wait until font is loaded before going to title screen.
This commit is contained in:
parent
5c9cc8d82b
commit
9a86962923
65
cat.html
65
cat.html
|
@ -49,7 +49,7 @@ var FONT = "BlueStone";
|
|||
// canvas style did have : border:1px solid #d3d3d3;
|
||||
|
||||
|
||||
var debug = true;
|
||||
var debug = false;
|
||||
|
||||
// game vars
|
||||
var things = [];
|
||||
|
@ -1230,7 +1230,10 @@ var game = {
|
|||
frameNo: 0,
|
||||
turnsleft: 0,
|
||||
|
||||
fontloaded: false,
|
||||
|
||||
levseloff: 0,
|
||||
resetcount: 0,
|
||||
|
||||
rng: null,
|
||||
|
||||
|
@ -1259,17 +1262,28 @@ var game = {
|
|||
return this.rng.rndrange(min, max);
|
||||
},
|
||||
|
||||
isfontloaded : function() {
|
||||
var tempctx = this.stargoalbanner.getContext("2d");
|
||||
var size;
|
||||
tempctx.font = "50 pt " + FONT;
|
||||
size = tempctx.measureText("wwwww").width;
|
||||
console.log(size);
|
||||
checkfont : function() {
|
||||
var tempctx = this.temp.getContext("2d");
|
||||
var result = false;
|
||||
|
||||
if (size >= 36) {
|
||||
return true;
|
||||
tempctx.font = TITLETEXTSIZE + "pt " + FONT;
|
||||
tempctx.fillText("www", 0, 0);
|
||||
|
||||
try {
|
||||
result = document.fonts.check(TITLETEXTSIZE + "pt " + FONT);
|
||||
}
|
||||
return false;
|
||||
catch(err) {
|
||||
console.log("document.fonts.check() not found, just assuming font is okay.");
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (result) {
|
||||
console.log("font ok");
|
||||
}
|
||||
|
||||
game.fontloaded = result;
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
addfireworks : function() {
|
||||
|
@ -1348,7 +1362,6 @@ var game = {
|
|||
ctx.fillStyle = bgcol;
|
||||
this.context.fillRect(0, 0, this.canvas.width, pct * this.canvas.height);
|
||||
this.dirty = true;
|
||||
console.log("drawing loader");
|
||||
},
|
||||
|
||||
init : function() {
|
||||
|
@ -5726,7 +5739,17 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
|
|||
//gridx = Math.floor((realx - BOARDX) / GRIDSIZE);
|
||||
//gridy = Math.floor((realy - BOARDY) / GRIDSIZE);
|
||||
|
||||
if ((gridx == LEVSELGRIDW-1) && (gridy == LEVSELGRIDH - 1)) {
|
||||
if ((gridy == -1) && (gridx == 4)) {
|
||||
game.resetcount++;
|
||||
console.log(game.resetcount);
|
||||
if (game.resetcount >= 10) {
|
||||
if (confirm("Clear game data?")) {
|
||||
playerdata.clearall();
|
||||
playerdata.load();
|
||||
}
|
||||
game.resetcount = 0;
|
||||
}
|
||||
} else if ((gridx == LEVSELGRIDW-1) && (gridy == LEVSELGRIDH - 1)) {
|
||||
// "next"
|
||||
game.levseloff += ((LEVSELGRIDW*LEVSELGRIDH)-1);
|
||||
} else if (game.levseloff > 0 && gridx == 0 && gridy == 0) {
|
||||
|
@ -5738,13 +5761,14 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
|
|||
levsel = game.levseloff + (gridy*LEVSELGRIDW) + gridx + 1;
|
||||
if (game.levseloff > 0) levsel--;
|
||||
|
||||
//if (game.levelexists(levsel) && !game.levellocked(levsel)) {
|
||||
if (!game.levellocked(levsel)) {
|
||||
if (levsel >= 1) {
|
||||
if (!game.levellocked(levsel)) {
|
||||
|
||||
curlevel = levsel;
|
||||
curlevel = levsel;
|
||||
|
||||
game.initgamevars();
|
||||
game.helporstartlev();
|
||||
game.initgamevars();
|
||||
game.helporstartlev();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5915,6 +5939,9 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
|
|||
|
||||
wipe.start("", "in", 50);
|
||||
} else if (newstate == "levselect") {
|
||||
// reset counters for clearing data
|
||||
game.resetcount = 0;
|
||||
|
||||
// reset grid size
|
||||
GRIDSIZE = DEF_GRIDSIZE;
|
||||
THINGSIZE = DEF_THINGSIZE;
|
||||
|
@ -7786,9 +7813,11 @@ function mainloop() {
|
|||
game.clear();
|
||||
game.drawloader();
|
||||
|
||||
game.checkfont();
|
||||
|
||||
if (nimages >= maximages) {
|
||||
// has font loaded?
|
||||
if (game.isfontloaded()) {
|
||||
if (game.fontloaded) {
|
||||
game.setstate("title");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue