Captcha Your Imagination: Comatile Mom
I've started making quick prototypes of games out of captchas, because really, "why not?"Â A general post mortem follows.
First, for a general idea of what this series of blog posts is about, see the general Captcha Your Imagination page. Also, my plan is to go through and comment my code sometime within the next day or two, and once I do, the source files will be available for the curious.
Goal: 4 hours. Actual Elapsed Time: 4 hours 31 Minutes
The Brain Storm
My first thought was that comatile probably isn't a real word. So I just started thinking about it as "comatose" (after briefly considering doing something with tile-based gameplay). This lead me to the concept of mom being asleep (rather than in a coma, which is a bit darker than I wanted to go with the project), and then the further inspiration of kids misbehaving while trying to avoid waking her. So it seemed as if I'd make a stealth game. The problem: If she's asleep, I can't do vision based stealth.  So the thought process turned to audio-based stealth gameplay, but I lacked the critical component of a massive sound library sitting on my PC for me to utilize. Considering I was trying to to finish the prototype in 4 hours, I didn't want to go on a sound hunt.  (As an aside, if you have links to any good free and legal sound libraries online, please share).
So I went back to the brainstorm, and starting picturing some stereotypical sleep imagery: Counting sheep. Catching Zees. Sawing Logs. This lead me to a rough concept of some sort of game where the player was a sheep, chasing Zees, while avoiding saws and/or falling logs. With this idea percolating (about 3 minutes into my timelimit) I move from conceptualizing and into the first stages of actual production.
Time Wasted Because I'm Dumb
After building the classes for the basic structure (start screen, actual game, game over screen), I move into work on the first of my game objects: The sheep. One of my big goals for these projects is to not care about art at all, and just use placeholder programmer art for everything, because I am not an artist. So what do I do? Waste about an hour and a half messing with the art tools in Flash trying to get a sheep that looks at least slightly respectable, and putting animations on it.  Why? See the heading for this section. On the bright side, with frame labels and the way I've constructed the Sheep's code, some far more competent artist could actually update the anims without me needing to recode anything.
I realize quickly that with so much time spent on the sheep (mostly: figuring out how to use the art side of Flash, everything I usually do is in the Actionscript part!), I don't have time to create any cool animated log sawing action. My game concept is crashing and burning. This realization leads to a shift in direction. What if we're not so much catching Zees as herding them? It's always fun to do some inversion of expectations, so I decide to have the sheep shepherding the Zees. To a larger sleeping sheep (mom). Everything is coming together.
Fast Forward Through About An Hour or So
I get the basic idea coded up and functional pretty quickly. The player controls a lamb that moves with simple acceleration/deceleration on a 2D plane. In the center, mom sleeps. Around the stage, Zees spawn in (the fade you see isn't animation, it's code controlled, I learned my lesson about trying to animate). Their position is determined randomly. They drift in a randomly determined linear direction, unless the player gets close enough to them, at which point they move away from the player. When a Zee hits mom, she gets more sleep.
Testing and Iterating
In an early version, if the player got too close to mom, she woke up. With the relatively restricted size of the stage, this made the game pretty impossibly difficult. So that went away. To compensate for that, Mom is always slowly waking up, and her need for Zees increases the more she gets (which kind of makes her sound like a heroin addict, but that isn't the intention). Her Zee need increases exponentially as the player "levels up" (there is no indication to the player that this has occurred, at this point). The spawn rate of Zees also increases on level up, but only linearly. Of course, this means that mom will inevitably wake up. I generally can make to about midway through level 4. I also just noticed there is a bug in the reporting of how many Zees get caught. Great.
Ideas I didn't get to add
Due to some issues figuring out font troubles and the new text engine in CS5 (which I ended up not using, because I was over my time limit, so I just switched back to the other type), I ran out of time before I had a chance to add a couple other ideas I had.
- Multiple types of Zees - I wanted to add another color or two of Zees. They would likely exhibit pretty much identical behavior, just with different parameters. My plan was for a weaker Zee that rather than running from the player, followed him. I also wanted one that was worth more, but tried to dodge the player. I considered some speed changes happening on these (or other Zees) as well.
- Hazards - I wanted to introduce a hazard or two into the game. The two ideas I had were for an object that moved through the level and "stole" Zees. I hadn't yet decided if it could be defeated to regain the stolen Zees, or if the player just had to herd them away from it. The other was for some sort of extra powerful Zee, that if it got too close to the player, put the player to sleep for X amount of time. It would be a double edged sword, of course, as if the player herded it without falling asleep, it would be a big boost to mom's sleep somehow.
Thoughts on Herding
My herding sucks.  Here's the code for it, as it stands:
var xDist:Number = this.x - lamb.x;
var yDist:Number = this.y - lamb.y;
this.radians = Math.atan2(yDist, xDist);
this.fleeVx = Math.cos(radians);
this.fleeVy = Math.sin(radians);
fleeCount++;
this.x += this.fleeVx;
this.y += this.fleeVy;
Ignoring the fleeCount thing for the moment (cheesy/quick way to decelerate the Zee once it's out of herding range), what I don't like about this code is that it just has the Zee move in a direct line away from the center of the player. The sheep aren't being herded, they're being repulsed. Thinking about it after the fact, I would do one of two things to fix this:
- In a quick prototype sort of situation, moving linearly away from the player based on which "quadrant" they are in would work better. That is, draw an X centered on the player. If the Zee is in between the two left facing rays of the X, it moves straight to the left. Thus, all sheep generally to my left would move straight left. Ok, not straight left, as that would be a bit too restricting, but embellish the x-dimensional left movement over the vertical movement. Similar embellishment would occur in the other four quadrants.
- A better solution would be to have the Zees actually move like a herd. That is,when a Zee has to flee from the player, it should look for any other nearby Zees that are also fleeing from the player, and match that Zee's movement (essentially, name that Zee as its leader). This would get rid of the "spreading" effect that occurs now (and irks me so much). Zees fleeing from the player would, instead, consolidate into masses heading generally away from the player. This would both look better and be a gameplay boon, as the player would be more easily able to direct the Zees towards their target.
var xDist:Number = this.x - lamb.x;
var yDist:Number = this.y - lamb.y;
this.radians = Math.atan2(yDist, xDist);
this.fleeVx = Math.cos(radians);
this.fleeVy = Math.sin(radians);
fleeCount++;
this.x += this.fleeVx;
var xDist:Number = this.x - lamb.x;
var yDist:Number = this.y - lamb.y;
this.radians = Math.atan2(yDist, xDist);
this.fleeVx = Math.cos(radians);
this.fleeVy = Math.sin(radians);
fleeCount++;
this.x += this.fleeVx;
this.y += this.fleeVy; Â Â Â Â Â Â Â Â Â Â Â Â Â this.y += this.fleeVy;
Tags: Actionscript, captcha, captcha your imagination, comatile mom, Development, flash, prototypes, sheep, zee