summaryrefslogtreecommitdiff
path: root/src/entities/actors/snake/body_segment
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2022-05-31 03:49:28 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2022-05-31 03:49:28 -0600
commitbd197168c39551c3456099ed2a39375a8442483f (patch)
treeadeafb80b75e3566918f35141c2392af590897c3 /src/entities/actors/snake/body_segment
parent2838046928db956b7712d24dfb63ee45fbc4d050 (diff)
working snake generation and path following, minor refactor
Diffstat (limited to 'src/entities/actors/snake/body_segment')
-rw-r--r--src/entities/actors/snake/body_segment/BodySegment.tscn28
-rw-r--r--src/entities/actors/snake/body_segment/body_segment.gd27
2 files changed, 0 insertions, 55 deletions
diff --git a/src/entities/actors/snake/body_segment/BodySegment.tscn b/src/entities/actors/snake/body_segment/BodySegment.tscn
deleted file mode 100644
index 4bf02b0..0000000
--- a/src/entities/actors/snake/body_segment/BodySegment.tscn
+++ /dev/null
@@ -1,28 +0,0 @@
-[gd_scene load_steps=3 format=2]
-
-[ext_resource path="res://entities/actors/snake/sprites/segment.png" type="Texture" id=1]
-[ext_resource path="res://entities/actors/snake/body_segment/body_segment.gd" type="Script" id=2]
-
-[node name="BodySegment" type="Node2D"]
-script = ExtResource( 2 )
-
-[node name="Sprite" type="Sprite" parent="."]
-texture = ExtResource( 1 )
-
-[node name="DirectionLine" type="Line2D" parent="."]
-visible = false
-points = PoolVector2Array( 0, 0, 0, -32 )
-width = 2.0
-default_color = Color( 1, 0, 0, 1 )
-
-[node name="DirectionToPreviousLine" type="Line2D" parent="."]
-visible = false
-points = PoolVector2Array( 0, 0, 0, -32 )
-width = 2.0
-default_color = Color( 0, 0, 1, 1 )
-
-[node name="PrevPivot" type="Node2D" parent="."]
-position = Vector2( 0, -8 )
-
-[node name="NextPivot" type="Node2D" parent="."]
-position = Vector2( 0, 8 )
diff --git a/src/entities/actors/snake/body_segment/body_segment.gd b/src/entities/actors/snake/body_segment/body_segment.gd
deleted file mode 100644
index eabede3..0000000
--- a/src/entities/actors/snake/body_segment/body_segment.gd
+++ /dev/null
@@ -1,27 +0,0 @@
-extends Node2D
-
-export(NodePath) var PREV_SEGMENT_NP: NodePath
-
-onready var prev_segment: Node2D = get_node(PREV_SEGMENT_NP)
-onready var prev_segment_next_pivot: Node2D = prev_segment.get_node("NextPivot")
-onready var _prev_pivot: Node2D = $PrevPivot
-onready var _next_pivot: Node2D = $NextPivot
-
-var rot_speed: float = Global.SNAKE_SEGMENT_ROT_SPEED
-
-var prev_segment_next_pivot_to_center: Vector2
-var _center_to_prev_pivot: Vector2
-var _angle_between_segments: float
-
-
-func _process(delta: float) -> void:
- prev_segment_next_pivot_to_center = prev_segment_next_pivot.global_position - prev_segment.global_position
- _center_to_prev_pivot = _prev_pivot.global_position - global_position
-
- _angle_between_segments = _center_to_prev_pivot.angle_to(prev_segment_next_pivot_to_center)
- if _angle_between_segments > 0.0:
- rotate(deg2rad(-rot_speed * delta))
- else:
- rotate(deg2rad(rot_speed * delta))
-
- global_position = prev_segment_next_pivot.global_position - _center_to_prev_pivot