summaryrefslogtreecommitdiff
path: root/src/entities/actors/snake/head
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2022-05-30 04:28:12 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2022-05-30 04:28:12 -0600
commit2838046928db956b7712d24dfb63ee45fbc4d050 (patch)
tree777be86f84a28498964578a826dad81bb14e7c5c /src/entities/actors/snake/head
parent0aa26dc19da1c8907cd69d18b423c33f351d3f2f (diff)
add non-working segment system.. might need to go back to using rigidbodies
Diffstat (limited to 'src/entities/actors/snake/head')
-rw-r--r--src/entities/actors/snake/head/Head.tscn5
-rw-r--r--src/entities/actors/snake/head/head.gd21
2 files changed, 13 insertions, 13 deletions
diff --git a/src/entities/actors/snake/head/Head.tscn b/src/entities/actors/snake/head/Head.tscn
index 790e2f0..a77cbef 100644
--- a/src/entities/actors/snake/head/Head.tscn
+++ b/src/entities/actors/snake/head/Head.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=2]
-[ext_resource path="res://icons/game.png" type="Texture" id=1]
+[ext_resource path="res://entities/actors/snake/sprites/head.png" type="Texture" id=1]
[ext_resource path="res://entities/actors/snake/head/head.gd" type="Script" id=2]
[node name="HeadPoint" type="Node2D"]
@@ -8,3 +8,6 @@ script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
+
+[node name="NextPivot" type="Node2D" parent="."]
+position = Vector2( 0, 8 )
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)