diff options
author | ClarkeCode <33846391+ClarkeCode@users.noreply.github.com> | 2023-02-13 17:04:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-13 17:04:22 +0100 |
commit | 6a0158e625eaffbae0f214620a1d728728934033 (patch) | |
tree | c3af6ac753b8b3c177d1e9a41e94017c1c2afbd0 /game/src/SampleGame.gd | |
parent | c0d8a4ac3723021c95da9674c3bc0eea511ee3a0 (diff) | |
parent | a4f213bf923b79674b8dcef4c35f0f79329ffc80 (diff) |
Merge pull request #8 from OpenVic2Project/dev-trailblazing-cpp
Exploration of uniting Godot UI with Stateful C++ Objects via GDExtension
Diffstat (limited to 'game/src/SampleGame.gd')
-rw-r--r-- | game/src/SampleGame.gd | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/game/src/SampleGame.gd b/game/src/SampleGame.gd new file mode 100644 index 0000000..0e3a61d --- /dev/null +++ b/game/src/SampleGame.gd @@ -0,0 +1,40 @@ +extends Control + +var selectedId = 0 + +# Called when the node enters the scene tree for the first time. +func _ready(): + updateVisibleInfo() + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + + +func updateVisibleInfo(): + $CenterContainer/VBoxContainer2/GridContainer/ProvinceNumDisplay.text = str(selectedId) + $CenterContainer/VBoxContainer2/GridContainer/ProvinceSizeDisplay.text = str(Simulation.queryProvinceSize(selectedId)) + + +func _on_pass_time_button_pressed(): + Simulation.conductSimulationStep() + updateVisibleInfo() + + +func _on_next_prov_button_pressed(): + selectedId = (selectedId + 1) % 10 + updateVisibleInfo() + + +func _on_prev_prov_button_pressed(): + if selectedId == 0: + selectedId = 9 + else: + selectedId -= 1 + updateVisibleInfo() + + +func _on_to_main_menu_pressed(): + get_tree().change_scene_to_file("res://src/MainMenu.tscn") |