Cats Versus Mice!
Click the above-left picture of Cats Versus Mice applet to start the game full screen.
Cat Versus Mice
Like 99.99% of all adolescent males who learn to use computers, I dreamt of creating my own video games. Though, along the way, I managed to acquire several real-life concerns: wife, child, mortgage, something-like-a-job, tower defense addiction, etc., that interferred with my ability to see those dreams come to fruition, I never really gave them up.
A little while ago, I created a truly bad model-builder that made me think that my game creation dream could possibly still live. I decided to create a game using cat and mouse models in the tradition of whack-a-mole. I figured that this was half a step up from pong and within my reach. My real intent was to create zillions of variations of this thrilling game: dog versus cats, cowboy versus cows, cops versus robbers, etc. to appeal to every possible whack-a-mole niche in existence.
I had a few problems along the way. Insisting on using my model-builder's models for the characters, I wrote a shape-engine that would draw the models from code at runtime. Unfortunately, I soon discovred that I needed to reverse one of the models horizontally. This is one of those things that is so simple to do in the Flash IDE, I just imagined that there had to be an easy way to do so in code. Apparently, there isn't. Flash requires that an affine transformation be done to flip, invert, skew, etc. an object at runtime. But, the location of the registration point, upper left, center, middle right, etc., makes a huge difference in the final result. Oh, and apparently, you can't determine the original registration point from actionscript. Done wrong, the symbol gets flipped or rotated but ends up somewhere other than where it started. My solution, knowing the original registration point, was to move the object to the origin, perform the transform, then move it back where it came from. This certainly helps, but if your application requires that the registration point is somewhere other than the center of the symbol, as mine did, then you'll still have trouble.
BTW, senocular.com gives a great tutorial on affine transformation.
I've heard of someone's pixel perfect collision detection involving bitmaps and I think that it must be possible to determine the original RP by a similar method. If I understood the collision detection method correctly, then the RP detection method would probably go something like this:
I think. And I'm going to get on that right way, as soon as I finish my other million ToDos.
MP3 vs. WAV
Another issue I ran into dealt with latency in mp3 file playing. Still hoping to create the many versions of the game, I want to be able to read in the appropriate sound files like I do with the models, but apparently, AS3 only has native support to read mp3 files which demonstrate a horrible lag each time I go to play them. This is especially noticable because I've got very short sounds associated with almost every mouse click. What I really want to do is load wav files that have no compression and therefore don't have the same lag. Apparently, someone has created a queue loader that will handle wav files, but I never got around to it. Instead, I've got cat and mouse sounds that seem mildly disconnected from the original clicks -- substantially laggy.
UPDATE: Silly Rabbit! Stupid mistakes are for somebody else. Well, it seems that the lag I experienced was because I was using the debug-enabled version of the Flash player. The production version of the Flash player plays the sounds great whether they are loaded as MP3s or embedded as WAVs. So, please ignore all the nonsense I spoke about lagginess.
Done The Wrong Way
Ok. So in a very "one-of" style, I've recreated the same game (with a few improvements) that uses wav files instead. This version is slightly larger, about 64k rather than the mp3 version's 59k size. But substantially improved playability using the wavs instead. Of course, I would have to import all the sounds separately for each version, so it pretty much loses all its advantage of coding so as to create multiple versions.
BTW, I can make it to level 119 with approximately 32k score. Send me an image if you're better.