mirror of
https://github.com/Relintai/regression-test-project.git
synced 2024-12-25 14:07:21 +01:00
30 lines
582 B
GDScript
30 lines
582 B
GDScript
extends Node2D
|
|
|
|
var move_vector: Vector2 = Vector2(1, 1)
|
|
var speed: float = 1000.0
|
|
|
|
|
|
func _ready():
|
|
pass
|
|
|
|
|
|
func _process(delta):
|
|
position += Vector2(move_vector.x * delta * speed, move_vector.y * delta * speed)
|
|
|
|
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
|
|
|
|
|
|
func _on_Area2D_area_entered(area):
|
|
move_vector = -move_vector
|
|
|
|
|
|
func _on_Area2D_body_entered(body):
|
|
move_vector = Vector2(move_vector.x, -move_vector.y)
|