Skip to content

Commit

Permalink
Give the player's ship some shields
Browse files Browse the repository at this point in the history
  • Loading branch information
jspahrsummers committed Jul 5, 2024
1 parent 9dfc7c6 commit e87c01c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ships/corvette01/corvette01.tres
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
script = ExtResource("1_3j2tk")
mass_kg = 10.0
hull = 40.0
shield = 0.0
shield = 80.0
thrust = 200.0
torque = 8.0
hyperspace_arrival_radius = 8.0
energy = 100.0
energy_recharge_rate = 5.0
thrust_energy_consumption = 8.0
turning_energy_consumption = 5.0
shield_recharge_rate = 0.0
shield_recharge_rate = 5.0
weapons = Array[Resource("res://weapons/weapon_def.gd")]([ExtResource("2_paw6l")])
4 changes: 2 additions & 2 deletions ships/ship.gd
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,14 @@ func _physics_process(delta: float) -> void:
self._recharge_shield(delta)

func _recharge_energy(delta: float) -> void:
if is_zero_approx(self.ship_def.energy_recharge_rate) or is_equal_approx(self.energy, self.ship_def.energy):
if self.freeze or is_zero_approx(self.ship_def.energy_recharge_rate) or is_equal_approx(self.energy, self.ship_def.energy):
return

self.energy = minf(self.energy + self.ship_def.energy_recharge_rate * delta, self.ship_def.energy)
self.emit_signal("ship_energy_changed", self)

func _recharge_shield(delta: float) -> void:
if is_zero_approx(self.ship_def.shield_recharge_rate) or is_equal_approx(self.shield, self.ship_def.shield):
if self.freeze or is_zero_approx(self.ship_def.shield_recharge_rate) or is_equal_approx(self.shield, self.ship_def.shield):
return

var recharge := self.ship_def.shield_recharge_rate * delta
Expand Down

0 comments on commit e87c01c

Please sign in to comment.