Don't allow scrolling to next screen of levels until you've unlocked it.

This commit is contained in:
Rob Pearce 2016-09-09 18:23:23 +10:00
parent d0cb78a843
commit 8f6db7d752
1 changed files with 44 additions and 10 deletions

View File

@ -1709,7 +1709,7 @@ var game = {
min = mm[0];
max = mm[1];
console.log("genrandomlev() - lev " + lev + " goal " + i + " type=" + game.levels[lev].goals[i].type + " min="+min + " max=" + max);
//console.log("genrandomlev() - lev " + lev + " goal " + i + " type=" + game.levels[lev].goals[i].type + " min="+min + " max=" + max);
count = min + Math.floor((game.levels[lev].goals[i].count / 100) * (max - min))
@ -1827,7 +1827,7 @@ console.log("genrandomlev() - lev " + lev + " goal " + i + " type=" + game.leve
}
}
if (newy != -1) {
console.log(" " + brickpos[i].x + "," + brickpos[i].y + " flipped to " + brickpos[i].x + "," + newy);
//console.log(" " + brickpos[i].x + "," + brickpos[i].y + " flipped to " + brickpos[i].x + "," + newy);
game.addlevelbricks(brickpos[i].x, newy);
totbricks++;
}
@ -5220,9 +5220,16 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
ctx.stroke();
*/
ctx.drawImage(image['nextlev'],
LEVSEL_X + x + GRIDSIZE/2 - nextsize/2, LEVSEL_Y + y + GRIDSIZE/2 - nextsize/2,
nextsize,nextsize);
if ( !this.levellocked(levnum)) {
ctx.drawImage(image['nextlev'],
LEVSEL_X + x + GRIDSIZE/2 - nextsize/2, LEVSEL_Y + y + GRIDSIZE/2 - nextsize/2,
nextsize,nextsize);
} else {
console.log("levle " + (levnum) + " is locked!");
}
/*
ctx.textAlign = "center";
ctx.textBaseline = "middle";
@ -5232,6 +5239,9 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
continue;
}
//if (this.levelexists(levnum)) {
// create it if required.
if (!game.levelexists(levnum)) {
@ -5245,7 +5255,7 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
}
randomlev = game.levels[levnum].random;
//if (this.levelexists(levnum)) {
ctx.beginPath();
ctx.lineWidth = 3;
ctx.strokeStyle = gridcol;
@ -5656,7 +5666,11 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
console.log("cheat() - finishingl level");
} else if (ch == 'u') {
game.cheat = 1;
playerdata.settotstars(9999);
if (playerdata.totstars < 43) {
playerdata.settotstars(43);
} else {
playerdata.settotstars(85);
}
console.log("cheat() - set tot stars to " + playerdata.totstars);
}
},
@ -5750,11 +5764,31 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
game.resetcount = 0;
}
} else if ((gridx == LEVSELGRIDW-1) && (gridy == LEVSELGRIDH - 1)) {
var inc,nextlev;
// "next"
game.levseloff += ((LEVSELGRIDW*LEVSELGRIDH)-1);
if (game.levseloff == 0) {
inc = ((LEVSELGRIDW*LEVSELGRIDH)-1);
} else {
inc = ((LEVSELGRIDW*LEVSELGRIDH)-2);
}
nextlev = curlevel + game.levseloff + inc;
if (!game.levellocked(nextlev)) {
game.levseloff += inc;
} else {
console.log("level " + nextlev + " locked = " + game.levellocked(nextlev));
}
} else if (game.levseloff > 0 && gridx == 0 && gridy == 0) {
// "next"
game.levseloff -= ((LEVSELGRIDW*LEVSELGRIDH)-1);
var dec;
// "prev"
if (game.levseloff == 29) {
dec = ((LEVSELGRIDW*LEVSELGRIDH)-1);
} else {
dec = ((LEVSELGRIDW*LEVSELGRIDH)-2);
}
game.levseloff -= dec;
if (game.levseloff < 0) game.levseloff = 0;
} else {