-
Notifications
You must be signed in to change notification settings - Fork 1
/
World.gd
133 lines (115 loc) · 4.05 KB
/
World.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
extends Node2D
var obj_num : int
var obj_type : int = -1
#var obstacles_of_vectors : PoolVector3Array
enum {LINE, POLYLINE, CIRCLE, RECT}
func _draw():
match obj_type:
LINE:
for i in obj_num:
draw_line(
Vector2(randi()%640, randi()%360),
Vector2(randi()%640, randi()%360),
# Color("#b2d90a"),
Color(randf(), randf(), randf()),
2.0
)
POLYLINE:
var pool : Array = []
for i in obj_num:
pool.append(Vector2(randi()%640, randi()%360))
draw_polyline(
PoolVector2Array(pool),
# Color("#b2d90a"),
Color(randf(), randf(), randf()),
2.0
)
CIRCLE:
for i in obj_num:
draw_circle(
Vector2(randi()%640+10, randi()%360+10),
randi()%30,
# Color("#b2d90a"),
Color(randf(), randf(), randf())
)
RECT:
for i in obj_num:
draw_rect(
Rect2(Vector2(randi()%640, randi()%360), Vector2(randi()%640, randi()%360)),
Color(randf(), randf(), randf()),
$gui/ScrollContainer/VBoxContainer/Container/CheckButton.pressed
)
_:
print("Type not set")
# var pool_vectors : PoolVector2Array
# for path_vector in path_of_vectors:
# pool_vectors.append(Vector2(path_vector.x*16, path_vector.y*16))
# draw_polyline(
# pool_vectors,
# Color("#b2d90a"),
# 3.0
# )
# var previous
# for path_vector in path_of_vectors:
# if previous != null:
# draw_line(
# Vector2(previous.x + 0.5, previous.y + 0.5)*16,
# Vector2(path_vector.x + 0.5, path_vector.y + 0.5)*16,
# Color("#b2d90a"),
# 3.0
# )
# previous = path_vector
#
# for tile_id in obstacles_of_ids:
# var v = astar.get_point_position(tile_id)
# draw_rect(Rect2(v.x*16, v.y*16, 16, 16), Color('#0000aa'))
# var x = path_vector
# for path_tile_id in self.path:
#
# var t5 = astar.get_point_connections( path_tile_id )
# var t7 = astar.get_point_position( path_tile_id )
# var t8 = astar.get_point_weight_scale( path_tile_id )
#
#
# var v = Vector3(grid[path_tile_id].center.x*tileWidth, grid[path_tile_id].center.y*tileHeight, 0)
# pass
# draw_line(
# Vector2(grid[path_tile_id].center.x, grid[path_tile_id].center.y),
# Vector2(randi()%100, randi()%100),
# Color("#b2d90a"),
# 3.0
# )
func setLines(value):
obj_num = value
$gui/block/label.text = str(value)
func drawCustom(type):
obj_type = type
update()
func drawLines2D():
for c in $"2dlines_container".get_children():
c.queue_free()
for i in range(obj_num):
var l = Line2D.new()
l.add_point(Vector2(randi()%640, randi()%360))
l.add_point(Vector2(randi()%640, randi()%360))
l.width = 2
$"2dlines_container".add_child(l)
func clearAll():
for c in $"2dlines_container".get_children():
c.queue_free()
obj_type = -1
update()
func _ready():
randomize()
var num = $gui/block/lines_num.value
obj_num = num
$gui/block/label.text = str(num)
$gui/block/lines_num.connect('value_changed', self, 'setLines')
$gui.find_node('b_draw_line').connect('pressed', self, 'drawCustom', [LINE])
$gui.find_node('b_draw_polyline').connect('pressed', self, 'drawCustom', [POLYLINE])
$gui.find_node('b_draw_circles').connect('pressed', self, 'drawCustom', [CIRCLE])
$gui.find_node('b_draw_rect').connect('pressed', self, 'drawCustom', [RECT])
$gui/b_draw_line2d.connect('pressed', self, 'drawLines2D')
$gui/clear.connect('pressed', self, 'clearAll')
func _process(delta):
$fps_container/fps.text = str(Engine.get_frames_per_second())