diff --git a/cat.html b/cat.html
index 16b455c..482647b 100644
--- a/cat.html
+++ b/cat.html
@@ -62,6 +62,15 @@ var GOALVERB = {
var FULLSTAR = "\u2605";
var EMPTYSTAR = "\u2606";
+var DEF_GRIDSIZE = 80;
+var DEF_THINGSIZE = 64;
+var DEF_GRIDW = 5;
+var DEF_GRIDH = 5;
+var GRIDSIZE = null;
+var THINGSIZE = null;
+var GRIDW = null;
+var GRIDH = null;
+
var MAXDIRS = 4;
var DIRXMOD = [ 0, 1, 0, -1 ];
var DIRYMOD = [ -1, 0, 1, 0 ];
@@ -73,8 +82,6 @@ var SCREENW = 480;
var SCREENH = 640;
var GRAVITY = 0.5;
-var GRIDSIZE = 80;
-var THINGSIZE = 64;
var TEXTSIZE = 16; // in points
@@ -112,20 +119,18 @@ var TAPBUTTONSIZE = 26; // game over button
var TAPBUTTONSIZEC = 20; // levcomplete button
var TAPBUTTONSIZESTAR = 26; // levcomplete button
-var PARADESPEED=14;
+var PARADESPEED=12;
var EXPLODETICKS=20;
-var EXPLODEGAIN= (THINGSIZE*2) / EXPLODETICKS;
+var EXPLODEGAIN= (DEF_THINGSIZE*2) / EXPLODETICKS;
var EXPLODEFADESPEED = 1.0 / EXPLODETICKS;
var SHRINKTICKS=20;
-var SHRINKLOSE= (THINGSIZE / SHRINKTICKS);
+var SHRINKLOSE= (DEF_THINGSIZE / SHRINKTICKS);
var LINEWIDTH=2;
var CROSSWIDTH=2;
-var GRIDW = 5;
-var GRIDH = 5;
var LEVSELGRIDW = 5;
var LEVSELGRIDH = 6;
@@ -134,7 +139,7 @@ var PATHARROWSIZE = 10;
var PARADELENGTH = 3;
-var BOARDX = (SCREENW - (GRIDW * GRIDSIZE)) / 2;
+var BOARDX = (SCREENW - (DEF_GRIDW * DEF_GRIDSIZE)) / 2;
var BOARDY = 64;
// 'tap to continue' button
@@ -142,9 +147,9 @@ var tapx,tapy,tapw,taph;
// back to title screen buton
var levsel_contx = BOARDX;
-var levsel_conty = BOARDY + (GRIDSIZE*GRIDH) + GRIDSIZE + GRIDSIZE/4;
+var levsel_conty = BOARDY + (DEF_GRIDSIZE*DEF_GRIDH) + DEF_GRIDSIZE + DEF_GRIDSIZE/4;
var levsel_contw = SCREENW - (BOARDX*2);
-var levsel_conth = (GRIDSIZE/2);
+var levsel_conth = (DEF_GRIDSIZE/2);
var FOODPOINTS = 10;
@@ -948,6 +953,19 @@ var game = {
overdesc = "";
clearpath();
+
+ // set grid size
+ if (game.levels[curlevel].gridsize == undefined) {
+ GRIDSIZE = DEF_GRIDSIZE;
+ THINGSIZE = DEF_THINGSIZE;
+ GRIDW = DEF_GRIDW;
+ GRIDH = DEF_GRIDH;
+ } else {
+ GRIDSIZE = game.levels[curlevel].gridsize;
+ THINGSIZE = game.levels[curlevel].thingsize;
+ GRIDW = game.levels[curlevel].gridw;
+ GRIDH = game.levels[curlevel].gridh;
+ }
},
addlevel : function (lev, hashelp) {
@@ -958,12 +976,28 @@ var game = {
mylevel.thinglist = new Array();
mylevel.forcelist = new Array();
mylevel.allowedthings = new Array();
+ mylevel.gridsize = DEF_GRIDSIZE;
+ mylevel.thingsize = DEF_THINGSIZE;
+ mylevel.gridw = DEF_GRIDW;
+ mylevel.gridh = DEF_GRIDH;
this.levels[lev] = mylevel;
playerdata.levscore[lev] = 0;
},
+ // TODO: specify newwid instead of newgridsize
+ addlevelgridsize: function (lev, newgridsize) {
+ var ratio;
+
+ ratio = newgridsize / DEF_GRIDSIZE;
+
+ this.levels[lev].gridsize = newgridsize;
+ this.levels[lev].thingsize = DEF_THINGSIZE * ratio;
+ this.levels[lev].gridw = (DEF_GRIDW * DEF_GRIDSIZE) / newgridsize;
+ this.levels[lev].gridh = (DEF_GRIDH * DEF_GRIDSIZE) / newgridsize;
+ },
+
// thingtype pct
addlevelthings: function (lev) {
var i,idx;
@@ -1063,7 +1097,7 @@ var game = {
},
calcstarpoints : function( lev ) {
- var i;
+ var i,num;
var min = 0,pointsgoal = false;
// calculate minimum points required to win
// first pass
@@ -1083,7 +1117,13 @@ var game = {
min += GOATPOINTS * this.levels[lev].goals[i].count;
break;
case "turns":
- min += FOODPOINTS * this.levels[lev].goals[i].count;
+ // assume you'll get a parade on most turns.
+ num = (Math.min(CATPOINTS, SLEEPYCATPOINTS) * 3 * this.levels[lev].goals[i].count);
+ if (!game.isbanned(curlevel, "door")) {
+ num *= 1.5;
+ }
+
+ min += num;
break;
case "doors":
// double the value of a minimum-score parade
@@ -1094,7 +1134,12 @@ var game = {
break;
}
}
+
+
+ //
+
// second pass - overrides
+/*
for (i = 0; i < this.levels[lev].goals.length; i++) {
switch (this.levels[lev].goals[i].type) {
case "points":
@@ -1102,7 +1147,18 @@ var game = {
break;
}
}
-
+*/
+
+ // adjust for level size
+ if (this.levels[lev].gridsize != DEF_GRIDSIZE) {
+ var ratio;
+ ratio = (this.levels[lev].gridw * this.levels[lev].gridh) /
+ (DEF_GRIDW * DEF_GRIDH) * 2;
+
+ min *= ratio;
+ }
+
+
this.levels[lev].starpoints = new Array();
this.levels[lev].starpoints[0] = Math.floor(Math.max(min, pointsgoal));
this.levels[lev].starpoints[1] = Math.floor(Math.max(min * 2, pointsgoal*1.5));
@@ -1134,8 +1190,9 @@ var game = {
this.addlevelallowedthings(4, "cat", "food", "llama");
this.addlevel(5, false);
+ this.addlevelgridsize(5, 70);
this.addlevelgoals(5, "turns", 10);
- this.addlevelgoals(5, "points", 600);
+ //this.addlevelgoals(5, "points", 600);
this.addlevelallowedthings(5, "cat", "food", "llama");
// introduce goats!
@@ -1163,7 +1220,7 @@ var game = {
this.addlevel(10, false);
this.addlevelallowedthings(10,"goat", "cat", "food", "llama", "door");
- this.addlevelgoals(10, "points", 2000);
+ //this.addlevelgoals(10, "points", 2000);
this.addlevelgoals(10, "turns", 15);
// introduce sunlight
@@ -2996,6 +3053,12 @@ var game = {
this.winimgsize = 0.1;
//console.log("winimage is " + winimg.src);
} else if (newstate == "levselect") {
+ // reset grid size
+ GRIDSIZE = DEF_GRIDSIZE;
+ THINGSIZE = DEF_THINGSIZE;
+ GRIDW = DEF_GRIDW;
+ GRIDH = DEF_GRIDH;
+
// count player stars
playerdata.settotstars(game.countplayerstars());
}
@@ -3443,6 +3506,10 @@ function thing(gridx, gridy, type, text) {
this.hasvalidmoves = function() {
var i,newx,newy;
+ if (this.gridy < 0) {
+ return false;
+ }
+
if (this.isanimating()) {
return false;
}
@@ -3574,7 +3641,9 @@ function thing(gridx, gridy, type, text) {
if (this.type == "cat") {
var myimage;
- if (isadjacenttotype(this, "llama")) {
+ if (this.state == "parade") {
+ myimage = image['cat'];
+ } else if (isadjacenttotype(this, "llama")) {
myimage = image['catscared'];
} else if (this.issleepy() == true) {
myimage = image['catfull'];
@@ -3679,11 +3748,11 @@ function thing(gridx, gridy, type, text) {
// return TRUE if we did something
this.snaptogrid = function() {
- var snapto = this.gridy * GRIDSIZE + (GRIDSIZE/2) - (THINGSIZE/2);
+ var snapto = Math.floor(this.gridy * GRIDSIZE + (GRIDSIZE/2) - (THINGSIZE/2));
//var snapto = (GRIDSIZE + (GRIDSIZE/2) - (THINGSIZE/2);
//if (this.y % (GRIDSIZE + (GRIDSIZE/2) - (THINGSIZE/2)) != 0) {
if (this.y % snapto != 0) {
- this.y = this.gridy * GRIDSIZE + (GRIDSIZE/2) - (THINGSIZE/2);
+ this.y = snapto;
return true;
}
return false;
@@ -3927,13 +3996,23 @@ function thing(gridx, gridy, type, text) {
// move
this.y += this.yspeed;
+ this.state = "fall";
+
// don't go below bottom of screen
- this.hitBottom();
+ if (this.y > GRIDSIZE * GRIDH) {
+ //this.y = GRIDSIZE * GRIDH;
+ atbottom = true;
+ this.state = "stop";
+ }
// calc new gridx / gridy
this.calcgridxy();
+
+ if ((this.gridy >= GRIDH-1)) {
+ atbottom = true;
+ this.state = "stop";
+ }
- this.state = "fall";
}
// hit something?
@@ -3952,14 +4031,6 @@ function thing(gridx, gridy, type, text) {
}
}
}
-
- this.hitBottom = function() {
- var rockbottom = GRIDSIZE * GRIDH;
- if (this.y > rockbottom) {
- this.y = rockbottom;
- this.yspeed = 0;
- }
- }
}
function mainloop() {
diff --git a/todo b/todo
index 3fdbf9c..4e973a1 100644
--- a/todo
+++ b/todo
@@ -30,23 +30,21 @@ phone fixes as per http://www.html5rocks.com/en/mobile/touch/
https://www.smashingmagazine.com/2012/10/design-your-own-mobile-game/
-*make forcethings actually work
-
-replace points goal with 'survive x turns'
-
-*doors -
-*sunlight
-* - makes nearby cats sleepy
-* - swaps with thing below each turn.
-* - then disappears off the bottom
-
-parademovement bounces up down!
- slow down parades to test.
+*bugfix :parade movement bounces up down!
+*bugfix: another bug with anyvalidmoves() - offscreen things showing up as having moves
+*initial code to make grid size bigger on later levels
+
+
+allow specifying gridw instead of gridsize
+
+make levels default to gridsize of previous one
+
+getting cats with x not aligned to gridx!
+
+finishing a level with no stars should be gameover ???
-still bugs in getarndomtype() ?
-bug with 2 suns above each other
special things - 5% chance of any
{
@@ -56,10 +54,14 @@ special things - 5% chance of any
destroy 9 in a block around.
pow pow cloud.
-
- doona - hide under it in the cold ?
-
mouse toy - match 3 to explode everything ?
+
+ special food that lets you turn corners?
+
+ brush -
+
+ doona - hide under it to avoid llama /sun effects ?
+
}
more goals: