diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-02-09 00:05:05 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-02-09 00:05:05 -0500 |
| commit | 46d7e793031a4ac534aa50da43408f4330abe8dc (patch) | |
| tree | adfcf6211c15e1fe0b1e8cc6e8431655aea05d3c /racing/load.gd | |
| parent | 2ce58f86aa74f1fd904690cb3ba3438bee4b765f (diff) | |
| download | lingo-race-46d7e793031a4ac534aa50da43408f4330abe8dc.tar.gz lingo-race-46d7e793031a4ac534aa50da43408f4330abe8dc.tar.bz2 lingo-race-46d7e793031a4ac534aa50da43408f4330abe8dc.zip | |
Timer
Diffstat (limited to 'racing/load.gd')
| -rw-r--r-- | racing/load.gd | 25 |
1 files changed, 25 insertions, 0 deletions
| diff --git a/racing/load.gd b/racing/load.gd index cd60c65..1455171 100644 --- a/racing/load.gd +++ b/racing/load.gd | |||
| @@ -29,14 +29,23 @@ func _load(): | |||
| 29 | label.align = Label.ALIGN_RIGHT | 29 | label.align = Label.ALIGN_RIGHT |
| 30 | label.valign = Label.VALIGN_TOP | 30 | label.valign = Label.VALIGN_TOP |
| 31 | 31 | ||
| 32 | var timer_label = Label.new() | ||
| 33 | timer_label.set_name("timer_label") | ||
| 34 | timer_label.margin_left = 20.0 | ||
| 35 | timer_label.margin_top = 20.0 | ||
| 36 | timer_label.align = Label.ALIGN_LEFT | ||
| 37 | timer_label.valign = Label.VALIGN_TOP | ||
| 38 | |||
| 32 | var dynamic_font = DynamicFont.new() | 39 | var dynamic_font = DynamicFont.new() |
| 33 | dynamic_font.font_data = load("res://fonts/Lingo.ttf") | 40 | dynamic_font.font_data = load("res://fonts/Lingo.ttf") |
| 34 | dynamic_font.size = 36 | 41 | dynamic_font.size = 36 |
| 35 | dynamic_font.outline_color = Color(0, 0, 0, 1) | 42 | dynamic_font.outline_color = Color(0, 0, 0, 1) |
| 36 | dynamic_font.outline_size = 2 | 43 | dynamic_font.outline_size = 2 |
| 37 | label.add_font_override("font", dynamic_font) | 44 | label.add_font_override("font", dynamic_font) |
| 45 | timer_label.add_font_override("font", dynamic_font) | ||
| 38 | 46 | ||
| 39 | add_child(label) | 47 | add_child(label) |
| 48 | add_child(timer_label) | ||
| 40 | 49 | ||
| 41 | var panel_script = load("res://nodes/panel_1.tscn") | 50 | var panel_script = load("res://nodes/panel_1.tscn") |
| 42 | var victory_panel = panel_script.instance() | 51 | var victory_panel = panel_script.instance() |
| @@ -56,6 +65,13 @@ func _load(): | |||
| 56 | "MeshInstance5" | 65 | "MeshInstance5" |
| 57 | ) | 66 | ) |
| 58 | 67 | ||
| 68 | var timer = Timer.new() | ||
| 69 | timer.name = "Timer" | ||
| 70 | timer.set_wait_time(0.03) | ||
| 71 | timer.set_one_shot(false) | ||
| 72 | timer.connect("timeout", self, "bump_timer") | ||
| 73 | add_child(timer) | ||
| 74 | |||
| 59 | global._print("Hooked Load Stop") | 75 | global._print("Hooked Load Stop") |
| 60 | 76 | ||
| 61 | ._load() | 77 | ._load() |
| @@ -66,6 +82,7 @@ func _load(): | |||
| 66 | 82 | ||
| 67 | 83 | ||
| 68 | func victory(): | 84 | func victory(): |
| 85 | get_node("Timer").stop() | ||
| 69 | get_node("Multiplayer").player_victory() | 86 | get_node("Multiplayer").player_victory() |
| 70 | ingame_achieve("Victory!") | 87 | ingame_achieve("Victory!") |
| 71 | 88 | ||
| @@ -76,3 +93,11 @@ func set_gridmap_tile(x, y, z, tile): | |||
| 76 | var mapvec = gridmap.world_to_map(gridmap.to_local(Vector3(x, y, z))) | 93 | var mapvec = gridmap.world_to_map(gridmap.to_local(Vector3(x, y, z))) |
| 77 | 94 | ||
| 78 | gridmap.set_cell_item(mapvec.x, mapvec.y, mapvec.z, mesh_library.find_item_by_name(tile)) | 95 | gridmap.set_cell_item(mapvec.x, mapvec.y, mapvec.z, mesh_library.find_item_by_name(tile)) |
| 96 | |||
| 97 | |||
| 98 | func bump_timer(): | ||
| 99 | var race_manager = global.get_node("RaceManager") | ||
| 100 | var elapsed = float(Time.get_ticks_msec() - race_manager.started_time) / 1000.0 | ||
| 101 | get_node("timer_label").text = ( | ||
| 102 | "%d:%02d:%02.2f" % [int(elapsed) / 60 / 60, int(elapsed) / 60 % 60, fmod(elapsed, 60.0)] | ||
| 103 | ) | ||
