getting-started/flappy-bird/Main.gd

37 lines
1 KiB
GDScript

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
var last_built = 300 # Helper variable to adhear to the given tower density
# 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
randomize() # Randomize the state of the random generator
func _on_Tower_exit():
build_tower()