It's been a while since I've posted last, but life has been hectic. Amidst all the chaos, I've managed to find some time to work on my next core mechanic: anxiety!
How the Anxiety Mechanic Works
The anxiety mechanic is easy to understand: get within range of a source of anxiety, and it will make your meter rise! Staying away from all sources of anxiety will lower your anxiety over time, affected by the internal 'courage' value. If your meter reaches the maximum, the anxiety source will push the player away from itself, becoming an obstacle to movement.
This simple-ish mechanic allows for some interesting interactions between two competing sources of anxiety pushing the player around, puzzle-stealthing, and more. Also, inverting the math of
anx_push can make it pull instead, adding a second layer of interactivity with the same mechanic.
The mechanic itself uses a line created between the player and the anxiety source to form the vector that will be followed when pushed by the anxiety source. It took some experimentation to learn how to use
cos(), and friends to get what I was aiming for, but the result was fun!
The meter was another story. In my engine, it's basically a game object that copies the anxiety stats of the player object every frame, then the draw routine handles the visual portion. I find it easier to reason about, despite the inflation in token count. It proved to be challenging to build based on a few sprites, but in the end the effect was great, I think. I have always wanted to build a graphical HUD element that looked good, and this was the first I've pulled off that really feels nice. The style itself is copied from the first three Mega Man X games, but I distinguished it enough to be a riff instead of a rip.
There were a number of other designs I considered:
In the end, the MMX-styled one was too cool, and simple enough to implement in a realistic amount of time. The lower left was my favorite, but I didn't feel like going through the trouble of coding it.
So I iterated for a while:
And made sure it looked good when it was shorter.
So it's great that it was animating correctly, palette swapping, and even pushing! But it was missing something. What conveys anxiety? Usually, it's nervousness or being jittery. Perfect! Let's make the meter shake around! I hooked up
rand() to 4 different single-pixel shaking routines, and hooked it up to a coroutine that only acts when the meter is maxed. Simple enough to get the job done, and has enough variance to seem random instead of a looping animation.
If I were to add anything else to this, it would be something silly or cute, like sweat drop particles being dispersed every few frames, to really sell the feeling.
Once the meter itself worked, and drew in 2 pixel increments like Mega Man X, I started thinking about usability.
In the Mega Man X games, the HUD exists on a layer above the mid-ground sprites where collision happens. I didn't get around to doing layer-based drawing, so I had a few drawing problems. Even without these (minor) issues, however, I don't like when the HUD is covering the action. I like HUDs that are smart, and stay out of the way.
So then, the meter needed to get out of the way. If the player is too far to the left or right side of the screen, the meter will simply switch sides.
Try it Out!
There is still some small polish needed on the meter's behavior -- particularly, it just needs a smooth screen-edge-swapping animation -- but the mechanic itself is ready for more experimentation and level design. I just wanted to share.
For the record, the pink slime has a weaker push, so his influence can be fought via movement. The blue one's is stronger, and you can only pass by him from the upper right to the lower left! This is a proof-of-concept cartridge, so there are no goals or anything fancy. Just a sign of things to come.
NB: There are functions and objects not used in the cartridge that were
#included. Anything produced from this particular cartridge should be made with that in mind and clean up where appropriate.
Let me know what you think!
[Please log in to post a comment]