generated from Nekojimi/GodotTemplate
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
808 B
38 lines
808 B
3 years ago
|
extends Polygon2D
|
||
|
|
||
|
export var sides: int = 4
|
||
|
export var size: float = 50
|
||
|
|
||
|
var idx: int
|
||
|
var accessor: GameScene.CellAccessor
|
||
|
|
||
|
var moveSpeed: float = rand_range(0.5,1.5)
|
||
|
|
||
|
func _ready() -> void:
|
||
|
init()
|
||
|
|
||
|
func init() -> void:
|
||
|
var points: PoolVector2Array = []
|
||
|
|
||
|
for side in range(sides):
|
||
|
var angle: float = ((side / float(sides)) + (0.5 / sides) ) * (2 * PI)
|
||
|
points.append(Vector2(cos(angle),sin(angle)) * size)
|
||
|
|
||
|
polygon = points
|
||
|
|
||
|
# color = Color(randf(),randf(),randf())
|
||
|
accessor = get_parent().get_cell(idx)
|
||
|
|
||
|
func _process(delta):
|
||
|
var target: Vector2 = accessor.get_pos() + Vector2(size,size)
|
||
|
position = position.linear_interpolate(target,delta*moveSpeed)
|
||
|
|
||
|
var owner: int = accessor.get_owner()
|
||
|
match owner:
|
||
|
0:
|
||
|
color = Color.white
|
||
|
1:
|
||
|
color = Color.pink
|
||
|
2:
|
||
|
color = Color.skyblue
|