Pages

Wednesday, July 17, 2013

Snake : The Hunt Begins

So, last post we discussed the controls of the snake game. In response to the post, I received a comment on how to improve the (rather terrible) controller support. Basically, instead of limiting the controls to four general directions, I've changed it so that the 'target angle' of the snake is whatever angle the thumb pad is currently facing. Brilliant and simple!

Moving on, I've finished implementing the AI of the mice/food. "AI? Why would completely immobile pellets of food need AI?" You ask? Well, I felt keeping the food immobile would be a waste of such a fun movement mechanic. So, the mice move, giving a level of difficulty to the chase.

So, I wanted the natural behavior of the mouse to be 'skittish', so they alternate between two states. They will first choose a random direction, and move at their Speed in that direction. They will move this way until their WalkTime is up, and will then not move for . . well, the duration of their PauseTime. Once that runs up, they'll choose another random direction and repeat the process.

Their behavior changes, however, if the head of the snake gets within a distance less than their "AwarenessDistance". They immediately move at their Speed times the RunSpeedMultiplier (which will always make them run faster) in a direction directly away from the snake head. Their direction will constantly update, so they're always running directly away from you. They will continue like this, until they reach a distance away from you equal to their AwarenessDistance times the DropMultiplier, or are chased out of the map (Mice who are being chased can escape the map. If they notice a snake is there, they're going to get out of there!).

Now, the values of all these attributes are randomized per mouse, so when mice spawn (more spawn the longer your body is) you'll get fast and slow ones, some stupid (won't run until you're on top of them) or smart (see you coming miles away), which provides an interesting twist to each game. On top of this, the values scale with the length of the snake, the longer you are, the faster the mice will be. At the beginning you're much faster than the mice, and can easily out-maneuver them, however as time progresses, it get's impossible to catch them by just chasing. This brings to light another gameplay element I'm quite proud of.

As seen in the picture from the last post, I've made it so the snake doesn't collide with himself. This allows you, as you get longer, to trap the mice. They run directly away from your head . . . so if you loop around before going in to strike them, you can catch them in the curves of your body.

Cool! And to demonstrate this, I've made a video! You'll see the three stages of the game here, the beginning, when you easily catch mice, the mid-game, where they're getting hard to chase down but you're not quite long enough to wrap around them, and the late-game, where strategy and planning are needed to capture those tasty mice.

First thing you might notice, is not terrible graphics! Thanks to Erika for doing the art.

Another interesting thing to note, is that at almost every stage of the game, mice were still smart/lucky enough to escape, leaving an element of difficulty at all points.

However, the issue still stands that, as is, it's pretty much impossible to lose. The only obstacles are the walls which, honestly, can be easily avoided. Mice respawn when chased out of the map, so you'll always be able to get bigger. There's some level of challenge to chasing the mice, but outside of that it gets boring. I already have two more mechanics designed to fix this, but that'll have to wait for another time!