flappy-bird/Camera2D.gd

30 lines
704 B
GDScript3
Raw Permalink Normal View History

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