2020-10-29 08:52:56 +01:00
|
|
|
extends Node2D
|
|
|
|
|
2020-11-07 17:36:23 +01:00
|
|
|
var move_vector: Vector2 = Vector2(1, 1)
|
|
|
|
var speed: float = 1000.0
|
|
|
|
|
2020-10-29 08:52:56 +01:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
pass
|
2020-11-07 17:36:23 +01:00
|
|
|
|
|
|
|
|
2020-10-29 08:52:56 +01:00
|
|
|
func _process(delta):
|
2020-11-07 17:36:23 +01:00
|
|
|
position += Vector2(move_vector.x * delta * speed, move_vector.y * delta * speed)
|
|
|
|
|
2020-10-29 08:52:56 +01:00
|
|
|
if position.y > Autoload.screen_size.y:
|
|
|
|
move_vector.y = -1
|
|
|
|
elif position.y < 0:
|
|
|
|
move_vector.y = 1
|
|
|
|
elif position.x > Autoload.screen_size.x:
|
|
|
|
move_vector.x = -1
|
|
|
|
elif position.x < 0:
|
|
|
|
move_vector.x = 1
|
2020-11-07 17:36:23 +01:00
|
|
|
|
2020-10-29 08:52:56 +01:00
|
|
|
|
|
|
|
func _on_Area2D_area_entered(area):
|
|
|
|
move_vector = -move_vector
|
|
|
|
|
|
|
|
|
|
|
|
func _on_Area2D_body_entered(body):
|
2020-11-07 17:36:23 +01:00
|
|
|
move_vector = Vector2(move_vector.x, -move_vector.y)
|