loading...
Cover image for Adding Health & Fuel Resources to my Game

Adding Health & Fuel Resources to my Game

rcarlson profile image Robert Carlson ・3 min read

Hey Guys! Time for another devlog update on my Asteroids Clone. Last week I talked about ditching my core mechanic (gravity) in favor or a more simple shooter with lasers. This week I want to talk about some new gameplay mechanics I've added. Lets begin!

By the way, I still don't have a name for this game, so if you have any suggestions please leave a comment below.

Adding a Spawner

To help make the level more configurable, I created a spawner object that is responsible for spawning all objects for the level. The spawner has 2 configurable properties: 1) total number of asteroids and 2) delay between spawns. For my first level I have it set to 10 asteroids spawning 1 second apart from each other. This will result in asteroids slowly coming in over 10 seconds.
Alt Text

Adding Object Tracking

After playing the game for a while and struggling with hitting the asteroids I decided to add an asteroid tracking mechanic to the laser. I figured in a world of space lasers chances are your ship would be able to track the target :)
Alt Text

I'm still not entirely sure how I feel about this mechanic, but I left it in my latest build for you to see. If you want to learn more about my decision, I wrote a dedicated article talking about it:

Making it About The Resources

I wanted to make my Asteroids clone a little more difficult by adding a resource component to the game. Right now I have fuel and health as the primary resources the player needs to worry about. To keep this simple I added HP and Fuel spawns to my existing spawner.

Losing HP

The player now starts the game with 30 hp. Any collision with an asteroid reduces the players total HP by 5. To help the player manage their health I added a bar on the bottom of the screen that changes colors depending on how close to death they are (Green to Yellow to Red).

Alt Text

Note: To make the impact stand out more I added a red and white flicker to highlight the impact moment.

Replenishing HP

To help replenish health, I spawn in health canisters that the player can collect. I'm still tweaking the rate these spawn and how much they heal. Right now these canisters spawn once per level and replenish the players hp to 30 (full).

Alt Text
That asteroid almost took me out!

Conserving Fuel

I took a similar approach with Fuel, depleting it every time you use a thruster and spawning in fuel canisters the player can collect to replenish their fuel supply.

Alt Text

Pre-Alpha Build

As I promised, here is a playable build for download. It's not quite ready to be considered 'alpha' but it works!

https://www.dropbox.com/s/p2bor48ekqirbkr/2D%20Gravity%20Prototype.rar?dl=0

Whats Next?

My plan for next week is to add level progression. With each level the asteroid spawner will spawn more asteroids. After that I want to add a score and level indicator so the player knows how far they've gotten. Then finally I need a level restart when the player dies or when they run out of fuel. After that I should have everything I need for the game. Then comes tuning and tweaking!

Posted on by:

rcarlson profile

Robert Carlson

@rcarlson

Husband, Father, Coder, Gamer, Co-Founder LetsBuild.gg

Discussion

markdown guide
 

It's looking good! Keep up the good work!

What would you say you've learned most so far while building this game?

 

This game was a great opportunity for me to learn how to apply forces to objects and work with vectors.

 

The object tracking looks great! I love the animation of the asteroid heating up until it explodes.

 

I plan on adding an effect where your ship heats up if you leave the laser on too long! Should have that in my next build :)