flappy-bird/Camera2D.gd
2020-02-08 11:36:48 +01:00

29 lines
704 B
GDScript

extends Node
export (PackedScene) var Tower = preload("res://Tower.tscn");
onready var screen_size = Vector2(ProjectSettings.get("display/window/size/width"), ProjectSettings.get("display/window/size/height"))
export var tower_density = 250
var last_built = 500
func build_tower():
var tower = Tower.instance()
tower.connect("exit", self, "_on_Tower_exit")
var pos = Vector2(last_built, (randf() * (screen_size.y * 0.7)) + screen_size.y * 0.15) # The player's movement vector.
tower.position = pos
add_child(tower)
last_built += tower_density
func _ready():
randomize()
print(screen_size)
while last_built < screen_size.x * 3:
build_tower()
func _on_Tower_exit():
build_tower()