diff --git a/cat.html b/cat.html index ad3b1b2..fae64ca 100644 --- a/cat.html +++ b/cat.html @@ -593,14 +593,14 @@ function isvalidpath(mypath) { if (!gcount) { return false; } - } else if ((thisone.type == "curtain") && (dirtonext == 0)) { - // upwards from a curtain is okay. + } else if (thisone.type == "curtain") { + // anywhere from a curtain is okay. (direction checked in canextendpath()) } else if ((i == 0) && (thisone.type == "cat") && (nextone.type == "food")) { // first cat -> food is ok } else if ((i == 0) && (thisone.type == "cat") && (nextone.type == "toad")) { // first cat -> toad is ok - } else if ((i == 0) && (thisone.type == "cat") && (nextone.type == "curtain") && (dirtonext == 0)) { - // first cat -> curtain is ok if we're going UP only + } else if ((i == 0) && (thisone.type == "cat") && (nextone.type == "curtain")) { + // first cat -> curtain is ok if we're going UP/DOWN only } else if ((i == 0) && (thisone.type == "cat") && (nextone.type == "whitecat")) { // first cat -> whitecat is ok } else if ((i != 0) && firstcat && (ccount == 0) && (thisone.type == "food") && (nextone.type == "food")) { @@ -1861,7 +1861,7 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio); this.addlevelgoals("food", 25); this.addlevel(21, false); // oooooooooooo - this.addlevelallowedthings("cat", "food"); + this.addlevelallowedthings("curtain"); this.addlevelforcethings("curtain", 2); this.addlevelgoals("curtain", 2); this.addlevelgoals("cat", 30); @@ -2066,6 +2066,10 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio); col = "#00ff00"; texttodraw = "CAT PARADE!"; break; + case "climb": + col = "#00ff00"; + texttodraw = "Climb"; + break; case "chomp": col = "#00cc00"; texttodraw = "Chomp!"; @@ -5118,7 +5122,7 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio); 'cat1', 'catfull1', 'catscared1', 'llama', 'cheese', 'title', 'goat', 'lock','catwalkl','catwalkr','goatwalkl','goatwalkr', - 'starfull','starempty', 'curtain','curtainshred', + 'starfull','starempty', 'curtain','curtainshred', 'curtainfall', 'door', 'sunlight', 'toad', 'whitecat', // special things 'brick', // obstacles 'bag', 'bagpop', 'fez', 'pow', 'brickpop', // effects @@ -5274,6 +5278,19 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio); curtaindie = true; } } + + // first cat swaps places with last object + curpath[0].pushpath(curpath[curpath.length-1].x, curpath[curpath.length-1].y); + curpath[0].state = "swapping"; + curpath[0].counter = 1; + // ...then becomes sleepy + curpath[0].sleepy = true; + + + curpath[curpath.length-1].pushpath(curpath[0].x, curpath[0].y); + curpath[curpath.length-1].state = "swapping"; + + if (curtaindie) { // if any curtains died, _all_ curtains die for (i = 1; i < curpath.length-1; i++) { @@ -5281,16 +5298,6 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio); curpath[i].losehp(); } } - // move cat up so it'll fall - curpath[0].setgridxy(curpath[curpath.length-2].gridx, curpath[curpath.length-2].gridy); - } else { - // first cat swaps places with last object - curpath[0].pushpath(curpath[curpath.length-1].x, curpath[curpath.length-1].y); - curpath[0].state = "swapping"; - curpath[0].counter = 1; - - curpath[curpath.length-1].pushpath(curpath[0].x, curpath[0].y); - curpath[curpath.length-1].state = "swapping"; } break; case "slap": // toad drops down. @@ -5450,7 +5457,7 @@ function collectprize(bag) { case "tissues": // all sleepy cats wake up for (i = 0; i < things.length; i++) { if (things[i].type == "cat") { - things[i].eaten = false; + things[i].sleepy = false; } } break; @@ -5525,6 +5532,7 @@ function getrandomtype() { if (dodb) console.log("specials are possible"); thinglist.push({ type: 'special', pct: 5 } ); } + if (!game.isbanned(curlevel, 'curtain')) thinglist.push({ type: 'curtain', pct: 5 } ); if (!game.isbanned(curlevel, 'goat')) thinglist.push({ type: 'goat', pct: 10 } ); if (!game.isbanned(curlevel, 'llama')) thinglist.push({ type: 'llama', pct: 10 } ); if (!game.isbanned(curlevel, 'food')) thinglist.push({ type: 'food', pct: 40 } ); @@ -5749,6 +5757,9 @@ function thing(gridx, gridy, type, text, col) { if (this.type == "bagpop") { this.yspeed = 0 - rndfloat(8); this.xspeed = 0 - rndfloat(16) - 1; + } else if (this.type == "curtainfall") { + this.yspeed = 0 - rndfloat(8); + this.xspeed = rndfloat(8) - 4; } else if (this.type == "brickpop") { this.yspeed = 0 - rndfloat(8); this.xspeed = rndfloat(32) - 16; @@ -5769,7 +5780,7 @@ function thing(gridx, gridy, type, text, col) { this.path = []; this.pathspeed = PARADESPEED; - this.eaten = false; + this.sleepy = false; if (this.type == "text" ) { this.x = gridx * GRIDSIZE + (GRIDSIZE/2); @@ -5793,7 +5804,7 @@ function thing(gridx, gridy, type, text, col) { this.issleepy = function() { if (this.type == "cat") { - if (this.eaten == true) { + if (this.sleepy == true) { return true; } else if (isadjacenttotype(this, "sunlight")) { return true; @@ -6176,7 +6187,7 @@ function thing(gridx, gridy, type, text, col) { } else { ctx.fillStyle = "black"; ctx.fillText(this.name, BOARDX + this.x + 10, BOARDY + this.y + (THINGSIZE/2)); - ctx.fillText(this.eaten ? "FULL" : "", BOARDX + this.x + 10, BOARDY + this.y + (THINGSIZE/2) + 10); + ctx.fillText(this.sleepy ? "FULL" : "", BOARDX + this.x + 10, BOARDY + this.y + (THINGSIZE/2) + 10); } */ @@ -6240,11 +6251,26 @@ function thing(gridx, gridy, type, text, col) { } this.getstoppedbelowthing = function() { - var bt; + var bt,i; bt = getgridthing(this.gridx, this.gridy + 1); if (bt && bt.state != "fall") { return bt; } + // look for things movng to the place below. + for (i = 0; i < things.length; i += 1) { + if (things[i] != this && things[i].state == "swapping" && things[i].path != undefined) { + var n; + for (n = 0; n < things[i].path.length; n++) { + var gx,gy; + gx = Math.floor(things[i].path[n].x / GRIDSIZE); + gy = Math.floor(things[i].path[n].y / GRIDSIZE); + // get grid coords + if (gx == this.gridx && gy == this.gridy + 1) { + return things[i]; + } + } + } + } return null; } @@ -6353,7 +6379,7 @@ function thing(gridx, gridy, type, text, col) { food.startexplode("chomp"); // mark that we've eaten something - this.eaten = true; + this.sleepy = true; console.log("chomp"); } @@ -6363,12 +6389,24 @@ function thing(gridx, gridy, type, text, col) { if (this.type == "firework") return true; if (this.type == "bagpop") return true; if (this.type == "brickpop") return true; + if (this.type == "curtainfall") return true; if (this.state == "explode") return true; if (this.state == "shrink") return true; if (this.state == "parade") return true; return false; } + this.shredcurtain = function() { + var i,nshards = 7; + for (i = 0; i < nshards; i++) { + things.push(new thing(this.gridx, this.gridy, "curtainfall")); + } + + this.givepoints(); + this.addabove(); + this.kill(); + } + this.breakbrick = function() { var i,nshards = 7; for (i = 0; i < nshards; i++) { @@ -6388,8 +6426,7 @@ function thing(gridx, gridy, type, text, col) { if (this.type == "brick") { this.breakbrick(); } else { - this.addabove(); - this.startexplode(); + this.shredcurtain(); } } else { // add a slash from a random x/y to a random x/y @@ -6475,7 +6512,7 @@ function thing(gridx, gridy, type, text, col) { if (this.type == "firework" && this.delay > 0) { this.delay--; - } else if ((this.type == "bagpop") || (this.type == "brickpop") || (this.type == "firework")) { + } else if ((this.type == "bagpop") || (this.type == "brickpop") || (this.type == "firework") || (this.type == "curtainfall")) { game.dirty = true; // need to redraw // regular gravity diff --git a/images/curtainfall.png b/images/curtainfall.png new file mode 100644 index 0000000..ece32d4 Binary files /dev/null and b/images/curtainfall.png differ diff --git a/todo b/todo index 4a53667..fcd158b 100644 --- a/todo +++ b/todo @@ -1,10 +1,5 @@ http://www.w3schools.com/games/tryit.asp?filename=trygame_default_gravity -*don't draw fireworks on gameover screen. -*randomised goat on title screen. - - - phone fixes as per http://www.html5rocks.com/en/mobile/touch/ ---------------------------- @@ -15,6 +10,8 @@ https://www.smashingmagazine.com/2012/10/design-your-own-mobile-game/ ------------------- +*things shouldn't all if something is swapping to underneath them!. + new door fell down on top of new goat!! (or the other way around ??) check code for doors falling when off the top of the screen. @@ -23,26 +20,50 @@ new door fell down on top of new goat!! change 'thing' to have a constructor!! then remove dupe hp code -curtain - *can only drag a cat UP onto a curtain. - *cat UP onto curtain = lose 1 hp - *clime multi curtain - *if ANY curtains are shredded, all are. - *shred all curtains climed - normal chance for curtain (5% ???) - curtain shred explosion + +curtain + *normal chance for curtain (5%) + *allowing climbing over to curtain from any dir + *becomesleepy after climb + *curtain shred explosion help (lev21) + cats can climb across curtains in any direction. + + this damages the curtains, and swaps places with + something else. + + + -------> + ca CU CU ch + + to + + ------------| + | V + ch CU- CU- ca + ^ | + ------------- + + After being climbed twice, curtains are shredded. + + ch ca + + CU- ----> POP ----> ca + + ca ch ch + remaining levels. *19/20 - more with brick patterns - 22/23/24 - curtains + 22/23/24 - curtains (shred 2, 4, 6) 24/25/26 - boxes 26/27/28 - cat toys 29/30 - ??? goal: x parades of y length!!! +random levels.