Some nice rounding in float representation
This commit is contained in:
parent
1982eb5e4e
commit
997e3c0982
6 changed files with 33 additions and 9 deletions
|
|
@ -19,7 +19,12 @@ script/source = "extends Label
|
|||
@onready var ship: Ship = get_parent().get_parent().get_parent()
|
||||
|
||||
func _process(_delta):
|
||||
text = unformatted_text.format([ship.hull.hp, ship.hull.max_hp, ship.shield.capacity, ship.shield.max_capacity])
|
||||
text = unformatted_text.format([
|
||||
round(ship.hull.hp * 100) / 100.0,
|
||||
ship.hull.max_hp,
|
||||
round(ship.shield.capacity * 100) / 100.0,
|
||||
ship.shield.max_capacity
|
||||
])
|
||||
"
|
||||
|
||||
[node name="KamikazeShip" type="Node2D"]
|
||||
|
|
|
|||
|
|
@ -20,7 +20,12 @@ script/source = "extends Label
|
|||
@onready var ship: Ship = get_parent().get_parent().get_parent()
|
||||
|
||||
func _process(_delta):
|
||||
text = unformatted_text.format([ship.hull.hp, ship.hull.max_hp, ship.shield.capacity, ship.shield.max_capacity])
|
||||
text = unformatted_text.format([
|
||||
round(ship.hull.hp * 100) / 100.0,
|
||||
ship.hull.max_hp,
|
||||
round(ship.shield.capacity * 100) / 100.0,
|
||||
ship.shield.max_capacity
|
||||
])
|
||||
"
|
||||
|
||||
[node name="ShooterShip" type="Node2D"]
|
||||
|
|
|
|||
|
|
@ -45,7 +45,10 @@ script/source = "extends Label
|
|||
@onready var ship: PlayerShip = get_parent().get_parent()
|
||||
|
||||
func _process(_delta):
|
||||
text = unformatted_text.format([ship.hull.hp, ship.hull.max_hp])
|
||||
text = unformatted_text.format([
|
||||
round(ship.hull.hp * 100) / 100.0,
|
||||
ship.hull.max_hp
|
||||
])
|
||||
"
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_q1sx2"]
|
||||
|
|
@ -58,7 +61,10 @@ script/source = "extends Label
|
|||
@onready var ship: PlayerShip = get_parent().get_parent()
|
||||
|
||||
func _process(_delta):
|
||||
text = unformatted_text.format([ship.shield.capacity, ship.shield.max_capacity])
|
||||
text = unformatted_text.format([
|
||||
round(ship.shield.capacity * 100) / 100.0,
|
||||
ship.shield.max_capacity
|
||||
])
|
||||
"
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_rrgab"]
|
||||
|
|
@ -72,7 +78,7 @@ script/source = "extends Label
|
|||
|
||||
func _process(_delta):
|
||||
var format = [
|
||||
ship.hull.ammunition[\"Laser Energy\"],
|
||||
round(ship.hull.ammunition[\"Laser Energy\"] * 100) / 100.0,
|
||||
ship.hull.max_ammunition[\"Laser Energy\"],
|
||||
ship.hull.ammunition[\"Rockets\"],
|
||||
ship.hull.max_ammunition[\"Rockets\"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue