Skip to content

Commit

Permalink
Merge pull request #60 from adventureboss/timer_ui
Browse files Browse the repository at this point in the history
Round timer UI
  • Loading branch information
SteveHNH authored Dec 20, 2023
2 parents 0679e5f + 879d894 commit 172f674
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion scenes/world.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extends Node2D

@onready var multiplayer_manager : MultiplayerManager = get_tree().get_first_node_in_group("MultiplayerManager")
@onready var round_timer = $RoundTimer

@onready var round_timer_ui = $RoundTimerUI/Time

# Called when the node enters the scene tree for the first time.
func _ready():
Expand All @@ -23,6 +23,16 @@ func _ready():

round_timer.start()

func _process(delta):
if round_timer and round_timer_ui:
var time_elapsed = round_timer.time_left
round_timer_ui.text = format_seconds_to_string(time_elapsed)

func format_seconds_to_string(seconds: float):
var minutes = floor(seconds / 60)
var remaining_seconds = seconds - (minutes * 60)
return str(minutes) + ":" + ("%02d" % floor(remaining_seconds))

func _on_round_timer_timeout():
for player in get_tree().get_nodes_in_group("player"):
player.process_mode = Node.PROCESS_MODE_DISABLED
Expand Down
12 changes: 11 additions & 1 deletion scenes/world.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[ext_resource type="Script" path="res://scenes/world.gd" id="1_2r7ig"]
[ext_resource type="Texture2D" uid="uid://bee43w1v6ob6t" path="res://assets/environment/terrainTiles_default.png" id="1_jft5n"]
[ext_resource type="PackedScene" uid="uid://bam04hog13mtt" path="res://scenes/game_object/player/player.tscn" id="2_kcqh6"]
[ext_resource type="AudioStream" uid="uid://djf04umoxsx8s" path="res://assets/audio/music/KTANKBYE_MAP_TRACK.mp3" id="3_ecdtc"]
[ext_resource type="AudioStream" uid="uid://hh6feddnwr4j" path="res://assets/audio/music/KTANKBYE_MAP_TRACK.mp3" id="3_ecdtc"]
[ext_resource type="PackedScene" uid="uid://b7ukeajhup4b5" path="res://scenes/component/consumable_spawn_component.tscn" id="4_68m35"]
[ext_resource type="Texture2D" uid="uid://o3jfx650hwjl" path="res://assets/environment/onlyObjects_default.png" id="5_0cr42"]
[ext_resource type="PackedScene" uid="uid://b1oeve68we6sd" path="res://scenes/game_object/collectible/rapid_fire_pickup.tscn" id="5_26hcn"]
Expand Down Expand Up @@ -432,6 +432,16 @@ PlayerScene = ExtResource("2_kcqh6")
wait_time = 300.0
one_shot = true

[node name="RoundTimerUI" type="CanvasLayer" parent="."]

[node name="Time" type="RichTextLabel" parent="RoundTimerUI"]
offset_left = 1186.0
offset_top = 15.0
offset_right = 1226.0
offset_bottom = 55.0
theme_override_colors/default_color = Color(0, 0, 0, 1)
text = "TIME"

[node name="TileMap" type="TileMap" parent="."]
position = Vector2(2, 1)
scale = Vector2(2, 2)
Expand Down

0 comments on commit 172f674

Please sign in to comment.