From 2838046928db956b7712d24dfb63ee45fbc4d050 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Mon, 30 May 2022 04:28:12 -0600 Subject: add non-working segment system.. might need to go back to using rigidbodies --- src/entities/actors/snake/head/head.gd | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/entities/actors/snake/head/head.gd') diff --git a/src/entities/actors/snake/head/head.gd b/src/entities/actors/snake/head/head.gd index 222d091..96707b7 100644 --- a/src/entities/actors/snake/head/head.gd +++ b/src/entities/actors/snake/head/head.gd @@ -1,13 +1,10 @@ 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 -var speed: float -var rot_speed: float -var position_update_interval: float - -var direction: Vector2 = Vector2.UP +var speed: float = Global.SNAKE_SPEED +var rot_speed: float = Global.SNAKE_ROT_SPEED +var position_update_interval: float = Global.SNAKE_POSITION_UPDATE_INTERVAL + +var _direction: Vector2 = Vector2.UP var _time_elapsed: float = 0.0 @@ -17,14 +14,14 @@ func _ready(): func _process(delta: float) -> void: if Input.is_action_pressed("move_left"): - # direction = direction.rotated(deg2rad(-ROT_SPEED)) + # _direction = _direction.rotated(deg2rad(-ROT_SPEED)) rotate(deg2rad(-rot_speed * delta)) if Input.is_action_pressed("move_right"): - # direction = direction.rotated(deg2rad(ROT_SPEED)) + # _direction = _direction.rotated(deg2rad(ROT_SPEED)) rotate(deg2rad(rot_speed * delta)) - move_local_x(direction.x * speed * delta) - move_local_y(direction.y * speed * delta) + move_local_x(_direction.x * speed * delta) + move_local_y(_direction.y * speed * delta) _handle_time_elapsed(delta) -- cgit v1.2.3