Skip to content

Commit

Permalink
Consume energy when firing weapon
Browse files Browse the repository at this point in the history
  • Loading branch information
jspahrsummers committed Jun 27, 2024
1 parent 497aa44 commit 0527434
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ships/corvette01/corvette01.tres
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ energy_recharge_rate = 5.0
thrust_energy_consumption = 8.0
turning_energy_consumption = 5.0
shield_recharge_rate = 0.0
weapon_energy_consumption = 20.0
weapon_energy_consumption = 5.0
6 changes: 6 additions & 0 deletions ships/ship.gd
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ func fire() -> void:
var now := Time.get_ticks_msec()
if now - self._last_fired_msec < self.ship_def.fire_interval_msec:
return

if self.energy < self.ship_def.weapon_energy_consumption:
return

self.energy -= self.ship_def.weapon_energy_consumption
self.emit_signal("ship_energy_changed", self)

var bullet_instance: RigidBody3D = self.bullet.instantiate()
get_parent().add_child(bullet_instance)
Expand Down

0 comments on commit 0527434

Please sign in to comment.