2024-04-18 15:52:41 +02:00
|
|
|
extends Node
|
|
|
|
|
|
|
|
@onready var screen_size = Vector2(ProjectSettings.get("display/window/size/viewport_width"), ProjectSettings.get("display/window/size/viewport_height"))
|
|
|
|
|
|
|
|
# Tower variables
|
|
|
|
# Preload the tower scene
|
|
|
|
# TODO 2
|
|
|
|
@export var tower_density = 250 # How often a tower should be added
|
2024-04-18 17:36:40 +02:00
|
|
|
var last_built = 300 # Helper variable to use the given tower density
|
2024-04-18 15:52:41 +02:00
|
|
|
|
|
|
|
# Build a single tower
|
|
|
|
func build_tower():
|
|
|
|
# Initiate a tower and give it a position
|
|
|
|
# TODO 2
|
|
|
|
|
|
|
|
# Adjust variable
|
|
|
|
last_built += tower_density
|
|
|
|
|
|
|
|
# Build all towers
|
|
|
|
func build_all_towers():
|
|
|
|
last_built = 300
|
|
|
|
# We're building towers until we're a bit infront of the camera
|
|
|
|
while last_built < screen_size.x * 3:
|
|
|
|
build_tower()
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
# Called when the main scene is ready.
|
|
|
|
# We can use this to connect all signals
|
|
|
|
|
|
|
|
# Build all the towers when the player emits the 'start' signal
|
|
|
|
# Afterwards head over to Player.gd to add the start signal
|
|
|
|
# TODO 2
|
|
|
|
|
2024-04-18 16:02:58 +02:00
|
|
|
# Connect all signals send by the Player scene to the UI scene
|
|
|
|
# TODO 3
|
|
|
|
|
2024-04-18 15:52:41 +02:00
|
|
|
randomize() # Randomize the state of the random generator
|
|
|
|
|
|
|
|
func _on_Tower_exit():
|
|
|
|
build_tower()
|