summaryrefslogtreecommitdiff
path: root/src/entities/actors/snake/snake.gd
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities/actors/snake/snake.gd')
-rw-r--r--src/entities/actors/snake/snake.gd14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/entities/actors/snake/snake.gd b/src/entities/actors/snake/snake.gd
index 7da829c..fb817da 100644
--- a/src/entities/actors/snake/snake.gd
+++ b/src/entities/actors/snake/snake.gd
@@ -1,9 +1,6 @@
class_name Snake
extends Node2D
-export(float, 1.0, 1000.0, 1.0) var SPEED: float = 100.0
-export(float, 1.0, 1000.0, 1.0) var ROT_SPEED: float = 200.0
-export(float, 0.01, 1.0, 0.01) var POSITION_UPDATE_INTERVAL: float = 0.01
export(PackedScene) var BODY_SEGMENT_NP: PackedScene
onready var head: Node2D = $Head
@@ -11,18 +8,16 @@ onready var path: Path2D = $Path
onready var path_follow: PathFollow2D = $Path/PathFollow
onready var curve: Curve2D = Curve2D.new()
+var speed: float = Global.SNAKE_SPEED
+
func _ready():
Event.connect("new_curve_point", self, "_on_Head_new_curve_point")
path.curve = curve
- head.speed = SPEED
- head.rot_speed = ROT_SPEED
- head.position_update_interval = POSITION_UPDATE_INTERVAL
- set_process(false)
func _process(delta: float) -> void:
- path_follow.set_offset(path_follow.get_offset() + SPEED * delta)
+ path_follow.offset = path_follow.offset + speed * delta
func _draw() -> void:
@@ -32,9 +27,6 @@ func _draw() -> void:
func add_point_to_curve(coordinates: Vector2) -> void:
path.curve.add_point(coordinates)
- # need at least 2 points to enable processing (sprite move)
- if not is_processing() and path.curve.get_baked_points().size() >= 2:
- set_process(true)
# update call is to draw curve
update()