From f3126f4a2d622856bdd21bba609349a232910bdf Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Fri, 11 Aug 2023 15:29:47 -0400 Subject: [PATCH] Centering camera on world based on world size --- world.gd | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/world.gd b/world.gd index 701c1ff..cdd67c4 100644 --- a/world.gd +++ b/world.gd @@ -11,6 +11,8 @@ enum CellStates { ALIVE, } +@onready var camera: Camera2D = $Camera2D + @onready var generation_counter: Label = $CanvasLayer/Debug/VBoxContainer/GenerationCounter @onready var generation_timer: Timer = $GenerationTimer @onready var living_cells_counter: Label = $CanvasLayer/Debug/VBoxContainer/LivingCellsCounter @@ -35,6 +37,10 @@ func _ready() -> void: generate_world() + # Center the camea on the world + camera.position.x = world_size.x * cell_size.x / 2 + camera.position.y = world_size.y * cell_size.y / 2 + ## Check a cell against the Conway rules and return True if cell shoudl be alive func cell_is_alive(pos: Vector2) -> bool: