|
|
@ -25,6 +25,7 @@ enum CellStates { |
|
|
|
@onready var generation_world_size_y: LineEdit = $UI/WorldGeneration/VBoxContainer/WorldSize/Input_y |
|
|
|
@onready var generation_cell_size_x: LineEdit = $UI/WorldGeneration/VBoxContainer/CellSize/Input_x |
|
|
|
@onready var generation_cell_size_y: LineEdit = $UI/WorldGeneration/VBoxContainer/CellSize/Input_y |
|
|
|
@onready var start_paused_button: CheckBox = $UI/WorldGeneration/VBoxContainer/FinalRow/StartPausedButton |
|
|
|
|
|
|
|
## Other |
|
|
|
@onready var camera: Camera2D = $Camera2D |
|
|
@ -52,15 +53,15 @@ func _ready() -> void: |
|
|
|
|
|
|
|
func _input(event: InputEvent) -> void: |
|
|
|
if event.is_action_pressed("Pause"): |
|
|
|
if is_paused: generation_timer.start() |
|
|
|
else: generation_timer.stop() |
|
|
|
is_paused = !is_paused |
|
|
|
background_ui.visible = is_paused |
|
|
|
toggle_pause() |
|
|
|
if is_paused and event.is_action_pressed("Next Generation"): |
|
|
|
process_generation() |
|
|
|
debug_generation_counter.text = "Generation: %s" % generation |
|
|
|
debug_living_cells_counter.text = "Living Cells: %s" % total_living |
|
|
|
if event.is_action_pressed("Menu"): |
|
|
|
is_paused = true |
|
|
|
background_ui.visible = true |
|
|
|
generation_ui.visible = true |
|
|
|
toggle_pause() |
|
|
|
update_generation_ui() |
|
|
|
generation_ui.visible = is_paused |
|
|
|
|
|
|
|
|
|
|
|
# |
|
|
@ -76,17 +77,22 @@ func update_generation_ui() -> void: |
|
|
|
generation_world_size_y.text = str(world_size.y) |
|
|
|
generation_cell_size_x.text = str(cell_size.x) |
|
|
|
generation_cell_size_y.text = str(cell_size.y) |
|
|
|
start_paused_button.button_pressed = false |
|
|
|
|
|
|
|
|
|
|
|
# |
|
|
|
# Conway Specific |
|
|
|
# |
|
|
|
func start_conway() -> void: |
|
|
|
generation = 1 |
|
|
|
debug_world_seed.text = "World Seeed: %s" % world_seed |
|
|
|
is_paused = false |
|
|
|
debug_generation_counter.text = "Generation: %s" % generation |
|
|
|
|
|
|
|
generate_world() |
|
|
|
generation_timer.start() |
|
|
|
|
|
|
|
debug_living_cells_counter.text = "Living Cells: %s" % total_living |
|
|
|
|
|
|
|
if not is_paused: generation_timer.start() |
|
|
|
|
|
|
|
# Center the camera on the world |
|
|
|
camera.position.x = world_size.x * cell_size.x / 2 |
|
|
@ -152,6 +158,13 @@ func process_generation() -> void: |
|
|
|
|
|
|
|
cell_states = new_states |
|
|
|
|
|
|
|
## Toggle Pause UI and Start/Stop Generation Timer |
|
|
|
func toggle_pause() -> void: |
|
|
|
if is_paused: generation_timer.start() |
|
|
|
else: generation_timer.stop() |
|
|
|
is_paused = !is_paused |
|
|
|
background_ui.visible = is_paused |
|
|
|
|
|
|
|
|
|
|
|
## Create the cell using the rendering server |
|
|
|
## This is only performed on initial world generation |
|
|
@ -212,5 +225,8 @@ func _on_run_button_pressed() -> void: |
|
|
|
|
|
|
|
start_conway() |
|
|
|
|
|
|
|
func _on_start_paused_button_toggled(button_pressed: bool) -> void: |
|
|
|
is_paused = button_pressed |
|
|
|
|
|
|
|
func _on_world_seed_generate_pressed() -> void: |
|
|
|
generation_seed.text = str(randi()) |