Adding Gameplay (Weapon Logic)


The idea with this set of features is getting some real gameplay which aligns with the Game Idea.

So the goal is to get some targets to shot at in the game. This is the target for the next version 0.0.5 I’m aiming for.

To reach that goal I will need to implement the following features

  • A weapon to shot targets
    • A simple laser weapon
    • Make sure the weapon is using power and produces heat
    • Projectiles do make damage on the health components
  • Shotable targets
  • An end game screen if you died

This post will mainly focus on the first idea, implementing a weapon to shot enemies.

So what need’s to be done?

  • [x] Implement a weapon component
  • [x] Implement a weapon configuration
  • [x] Implement some target to shoot
  • [x] Make everything visible and somewhat pleasant to look at.

Implementing a weapon component

This part did sound easy. I just created a base object which does some basic stuff every weapon properly will need.

This is some mechanic to ensure some “cooldown” between each shot, managing power consumption and heat if fired. To do so the component can produce some heat while being idle and more if you fire it. Same goes for the power consumption, there is some consumption if idle and more if fired.

The component will also take care of spawning the projectile and make a sound if it was fired.

Even if the requirement did sound easy it wasn’t that easy to prevent a projectile spawn if the fire command was send, but the generator + battery array does not provide enough energy. But it was solvable.

Implementing a weapon configuration

This was easy for the weapon I do implement as a first component. It’s a simple configuration file allowing me to set time between shots, damage, sound to play, projectile to spawn, consumption and heat.

Additional this config does implement everything needed by a component like a name, icon, description and so on.

After the implementation was done the weapon component was changed to used this dynamic configuration instead of fixed values.

Implementing a shootable target

To implement a shootable target and test the weapon as well as the health mechanic I create a new scene. I wasted a lot of time getting the collision between the projectile and the shootable target done. Maybe I shouldn’t have disabled the collision box for testing purpose …

After adding a health component and some wiring of the components and a health bar the target was destroyable. I refactored some code to make the targets you need to fly through and the shootable ones based on the same object, this does implement some kind of target trigger logic allowing me to queue some targets to be solved one after another.

To extend on this feature I added a new multi target script, which adds a number of n targets which get active at the same time as soon as the multi target is getting triggered. After you “solved” all the sub targets the multi targets completes and triggers a finish action, just like the fly through and shootable targets.

Make everything better looking and sounding

The last step was adding a sound if you shot and improve the graphic a little bit to make it look less blocky …

I started with the sound and implementing a basic shooting sound was easy. Sadly the sound is only playing if no input is triggered on the ship. Lucky me writing this post, rethinking what I have done did give me an idea on how to fix the issue, and it worked right away! I also implemented an audio manager which should be able to manage sound played at the same time.

I also found a whole lot of small bugs I fixed while trying to solve this.

I replaced the shot image and added some menus to allow the dead of a player.

Whats next?

The next goal will be adding some enemies which try to collide with the player, dealing damage. As the game starts to be more of a gem instead of a tech demo this means I will properly need to redesign the current scene where you have to fly through the targets.

Get Space Survivor

Leave a comment

Log in with itch.io to leave a comment.