-
Notifications
You must be signed in to change notification settings - Fork 4
/
straight_better.gd
62 lines (45 loc) · 1.41 KB
/
straight_better.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
tool
extends "straight2D.gd"
# class member variables go here, for example:
export(int) var width = 70
var inner_first = Vector2(0,0)
var inner_last = Vector2(0,0)
var outer_first = Vector2(0,0)
var outer_last = Vector2(0,0)
var building = null
var buildDistance = 70
var buildingSpacing = 15*8
func _ready():
# Called when the node is added to the scene for the first time.
# Initialization here
thick = 2
inner_first = first + Vector2(0, -width)
inner_last = last + Vector2(0, -width)
outer_first = first + Vector2(0, width)
outer_last = last + Vector2(0, width)
# send data on
var poly = [inner_first, inner_last, outer_last, outer_first]
get_child(0).set_polygon(poly)
# props
building = load("res://building2D.tscn")
var numBuildings = int(length/buildingSpacing)
for index in range(numBuildings):
placeBuilding(index)
#pass
func placeBuilding(index):
# left side
var build = building.instance()
build.set_position(first + Vector2(buildingSpacing*index, -width-buildDistance))
add_child(build)
# right side
build = building.instance()
build.set_position(first + Vector2(buildingSpacing*index, width+buildDistance))
add_child(build)
func _draw():
#draw_line(inner_first, inner_last, Color(0,0,0), thick)
#draw_line(outer_first, outer_last, Color(0,0,0), thick)
pass
#func _process(delta):
# # Called every frame. Delta is time since last frame.
# # Update game logic here.
# pass