forked from Dariasteam/TowerJumper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
platforms_deployer.gd
39 lines (28 loc) · 1.11 KB
/
platforms_deployer.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
extends Spatial
var first_platform = preload ("res://Scenes/first_platform.tscn")
var platform = preload ("res://Scenes/platform.tscn")
var end_line = preload ("res://Scenes/end_line.tscn")
export var MAX_PLATFORMS = 100
onready var col = get_node ("Column")
export(int) var space = 7
export(int) var n_platforms = 30
func instance_in (element, i):
element.translate (Vector3(0, -1 * i * space , 0))
add_child(element)
func _ready():
var prev_platform = first_platform.instance()
instance_in(prev_platform, 0)
if (global.level > 16):
n_platforms += ((global.level - 16) / 12)
n_platforms = min(n_platforms, MAX_PLATFORMS)
global.level_size = n_platforms
col.set_scale(Vector3(col.get_scale().x, n_platforms + n_platforms * 0.0035, col.get_scale().z))
col.set_translation(Vector3 (0, -(n_platforms * space / 2) + 0.5, 0))
for i in range (1, n_platforms):
var new_platform = platform.instance();
prev_platform.next_platform = new_platform
instance_in(new_platform, i)
prev_platform = new_platform
var end = end_line.instance()
prev_platform.next_platform = end
instance_in(end, n_platforms)