Game Dev Diary: Introducing health mechanics & timed effects

By X-51 | Game Dev Diary | 27 Mar 2021


Hey folks, been a while!! I hope some of you are still around.

Before I get to what I want to write about, I'll throw you all a quick catch up....

 

I had a lot going on since the last time I wrote (August, damn, longer than it feels). One of my personal projects I hoped to make money from didn't go anywhere (yet) despite putting in some time and effort, and the other made some progress but has not yet made me any money.

Then the whole Christmas/New Year period where nothing really happened except too much partying, tonsillitis, and a little travel. Soon after my wallet and phone were stolen which took me out of the regular flow of life for a month (and I'm still catching up in some ways), and also cost me more money than I was comfortable losing.

Then I had a not-too-serious case of Covid, but that still took me out for a few weeks more.

That brings us up to recent weeks, when I finally got back to working on Witch's Brew.

 

I guess I had been putting off working on it for a while because the scope of my plans was pretty large and I was unsure of exactly where to start. So I sat down and put a few hours into planning documentation, and this pointed me to a fairly obvious place to start coding again - adding a player health mechanic.

That same evening I started back into the code and pretty quickly had the basics of health in place - the player starts with 100 health and doesn't die when they touch a monster, but they do lose 10 health on a hit instead.

Not long after I had a health bar in place which updates as the player's health changes.

 

Progress was interrupted by the need for some research to figure out why monsters were changing speed and direction when hit (which had to do with how Phaser treats checks for collision between game objects), but then I was back on track....

 

Soon after that another problem presented itself - touching a monster for too long, or touching multiple monsters in quick succession, would still deplete all your health instead of just giving a single hit.

So I introduced a brief (currently 0.6 seconds) invulnerable state after taking damage, and a little "kick" in the direction away from the monster. Bats will also move away from you when hit (but ghosts won't).

I made sure that tracking this damage invulnerability state was added in a reasonably reusable way, which led to me having slow and haste effects not long after. Now when you take damage from a ghost you are also slowed for 4 seconds (but the visual feedback for the slowed state needs work).

The power-up item that gives the haste effect will be added later, and I'm working on an incorporeal state which will make the player temporarily immune to bats (but not ghosts). The power-up that will grant the incorporeal state will also come later.

 

Still no major improvements to gameplay or replayability, they will come later.....

 

So I guess this is now release 0.2!

https://witchs-brew.firedancer-software.com/

 

How do you rate this article?

3


X-51
X-51

Software developer, musician, photographer, traveler, crypto enthusiast


Game Dev Diary
Game Dev Diary

A place for me to document the processes, decisions, challenges, and struggles of creating a video game.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.