Browse Source

Removing Cell Size inputs and adding Generation Speed

master v1.5
Ryan Reed 1 year ago
parent
commit
3cb0d0e7ae
2 changed files with 23 additions and 30 deletions
  1. +8
    -5
      world.gd
  2. +15
    -25
      world.tscn

+ 8
- 5
world.gd View File

@ -21,10 +21,9 @@ enum CellStates {
@onready var generation_ui: MarginContainer = $UI/WorldGeneration
@onready var generation_seed: LineEdit = $UI/WorldGeneration/VBoxContainer/Seed/Input
@onready var generation_speed: HSlider = $UI/WorldGeneration/VBoxContainer/GenerationSpeed/Input
@onready var generation_world_size_x: LineEdit = $UI/WorldGeneration/VBoxContainer/WorldSize/Input_x
@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
@onready var messages_label: Label = $UI/Messages/Label
@ -58,6 +57,8 @@ var previous_generation_count: int = 10 # Number of generations to check for evo
# 4 Collisions out of 10 previous_generation_count seems reasonable although it may not be quite enough
var collision_count_limit: int = 4
var timer_speeds: Array = [0.1, 0.08, 0.05, 0.03, 0.01] # The speeds for the generation_timer for selection from the UI
func _ready() -> void:
update_generation_ui()
@ -96,8 +97,6 @@ func update_generation_ui() -> void:
generation_seed.text = str(randi())
generation_world_size_x.text = str(world_size.x)
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
@ -282,6 +281,11 @@ func _on_generation_timer_timeout() -> void:
generation_timer.start()
func _on_generation_speed_drag_ended(value_changed: bool) -> void:
var speed = generation_speed.value - 1
if value_changed:
generation_timer.wait_time = timer_speeds[speed]
func _on_quit_button_pressed() -> void:
get_tree().quit()
@ -291,7 +295,6 @@ func _on_run_button_pressed() -> void:
else:
world_seed = randi()
world_size = Vector2(int(generation_world_size_x.text), int(generation_world_size_y.text))
cell_size = Vector2(int(generation_cell_size_x.text), int(generation_cell_size_y.text))
debug_ui.visible = true
generation_ui.visible = false


+ 15
- 25
world.tscn View File

@ -139,41 +139,30 @@ text = "32"
max_length = 4
select_all_on_focus = true
[node name="CellSize" type="HBoxContainer" parent="UI/WorldGeneration/VBoxContainer"]
[node name="GenerationSpeed" type="HBoxContainer" parent="UI/WorldGeneration/VBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 6
[node name="Label" type="Label" parent="UI/WorldGeneration/VBoxContainer/CellSize"]
custom_minimum_size = Vector2(120, 0)
[node name="Label" type="Label" parent="UI/WorldGeneration/VBoxContainer/GenerationSpeed"]
layout_mode = 2
text = "Cell Size"
text = "Generation Speed"
[node name="Padding" type="VSeparator" parent="UI/WorldGeneration/VBoxContainer/CellSize"]
[node name="Padding" type="VSeparator" parent="UI/WorldGeneration/VBoxContainer/GenerationSpeed"]
modulate = Color(1, 1, 1, 0)
layout_mode = 2
size_flags_horizontal = 3
[node name="Label_x" type="Label" parent="UI/WorldGeneration/VBoxContainer/CellSize"]
layout_mode = 2
text = "X:"
[node name="Input_x" type="LineEdit" parent="UI/WorldGeneration/VBoxContainer/CellSize"]
custom_minimum_size = Vector2(20, 0)
layout_mode = 2
text = "16"
max_length = 4
select_all_on_focus = true
[node name="Label_y" type="Label" parent="UI/WorldGeneration/VBoxContainer/CellSize"]
[node name="Input" type="HSlider" parent="UI/WorldGeneration/VBoxContainer/GenerationSpeed"]
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
text = "Y:"
tooltip_text = "The higher the speed, the less time between generations.
[node name="Input_y" type="LineEdit" parent="UI/WorldGeneration/VBoxContainer/CellSize"]
custom_minimum_size = Vector2(20, 0)
layout_mode = 2
text = "16"
max_length = 4
select_all_on_focus = true
Slowest: 0.1/s
Fastest: 0.01/s"
min_value = 1.0
max_value = 5.0
value = 3.0
tick_count = 5
ticks_on_borders = true
[node name="FinalRow" type="HBoxContainer" parent="UI/WorldGeneration/VBoxContainer"]
layout_mode = 2
@ -214,6 +203,7 @@ layout_mode = 2
[connection signal="timeout" from="GenerationTimer" to="." method="_on_generation_timer_timeout"]
[connection signal="pressed" from="UI/WorldGeneration/VBoxContainer/Seed/Generate" to="." method="_on_world_seed_generate_pressed"]
[connection signal="drag_ended" from="UI/WorldGeneration/VBoxContainer/GenerationSpeed/Input" to="." method="_on_generation_speed_drag_ended"]
[connection signal="toggled" from="UI/WorldGeneration/VBoxContainer/FinalRow/StartPausedButton" to="." method="_on_start_paused_button_toggled"]
[connection signal="pressed" from="UI/WorldGeneration/VBoxContainer/FinalRow/RunButton" to="." method="_on_run_button_pressed"]
[connection signal="pressed" from="UI/WorldGeneration/VBoxContainer/FinalRow/QuitButton" to="." method="_on_quit_button_pressed"]

Loading…
Cancel
Save