From bd197168c39551c3456099ed2a39375a8442483f Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Tue, 31 May 2022 03:49:28 -0600 Subject: working snake generation and path following, minor refactor --- src/entities/actors/snake/scenes/Body.tscn | 14 ++++++++++++++ src/entities/actors/snake/scenes/Head.tscn | 10 ++++++++++ src/entities/actors/snake/scenes/Snake.tscn | 21 +++++++++++++++++++++ src/entities/actors/snake/scenes/Tail.tscn | 15 +++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 src/entities/actors/snake/scenes/Body.tscn create mode 100644 src/entities/actors/snake/scenes/Head.tscn create mode 100644 src/entities/actors/snake/scenes/Snake.tscn create mode 100644 src/entities/actors/snake/scenes/Tail.tscn (limited to 'src/entities/actors/snake/scenes') diff --git a/src/entities/actors/snake/scenes/Body.tscn b/src/entities/actors/snake/scenes/Body.tscn new file mode 100644 index 0000000..93020b2 --- /dev/null +++ b/src/entities/actors/snake/scenes/Body.tscn @@ -0,0 +1,14 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://entities/actors/snake/sprites/body.png" type="Texture" id=1] +[ext_resource path="res://entities/actors/snake/scripts/generic_segment.gd" type="Script" id=2] + +[node name="BodyPathFollow" type="PathFollow2D"] +loop = false +script = ExtResource( 2 ) + +[node name="Body" type="Node2D" parent="."] +rotation = 1.5708 + +[node name="Sprite" type="Sprite" parent="Body"] +texture = ExtResource( 1 ) diff --git a/src/entities/actors/snake/scenes/Head.tscn b/src/entities/actors/snake/scenes/Head.tscn new file mode 100644 index 0000000..2dc1666 --- /dev/null +++ b/src/entities/actors/snake/scenes/Head.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://entities/actors/snake/sprites/head.png" type="Texture" id=1] +[ext_resource path="res://entities/actors/snake/scripts/head.gd" type="Script" id=2] + +[node name="HeadPoint" type="Node2D"] +script = ExtResource( 2 ) + +[node name="Sprite" type="Sprite" parent="."] +texture = ExtResource( 1 ) diff --git a/src/entities/actors/snake/scenes/Snake.tscn b/src/entities/actors/snake/scenes/Snake.tscn new file mode 100644 index 0000000..cb1eb2a --- /dev/null +++ b/src/entities/actors/snake/scenes/Snake.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=6 format=2] + +[ext_resource path="res://entities/actors/snake/scenes/Head.tscn" type="PackedScene" id=1] +[ext_resource path="res://entities/actors/snake/scenes/Body.tscn" type="PackedScene" id=2] +[ext_resource path="res://entities/actors/snake/scripts/snake.gd" type="Script" id=3] +[ext_resource path="res://entities/actors/snake/scenes/Tail.tscn" type="PackedScene" id=4] + +[sub_resource type="Curve2D" id=1] +_data = { +"points": PoolVector2Array( ) +} + +[node name="Snake" type="Node2D"] +script = ExtResource( 3 ) +BODY_SEGMENT_NP = ExtResource( 2 ) +TAIL_SEGMENT_NP = ExtResource( 4 ) + +[node name="Path" type="Path2D" parent="."] +curve = SubResource( 1 ) + +[node name="Head" parent="." instance=ExtResource( 1 )] diff --git a/src/entities/actors/snake/scenes/Tail.tscn b/src/entities/actors/snake/scenes/Tail.tscn new file mode 100644 index 0000000..bb30c42 --- /dev/null +++ b/src/entities/actors/snake/scenes/Tail.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://entities/actors/snake/sprites/tail.png" type="Texture" id=1] +[ext_resource path="res://entities/actors/snake/scripts/generic_segment.gd" type="Script" id=2] + +[node name="TailPathFollow" type="PathFollow2D"] +loop = false +script = ExtResource( 2 ) +TYPE = "tail" + +[node name="Tail" type="Node2D" parent="."] +rotation = 1.5708 + +[node name="Sprite" type="Sprite" parent="Tail"] +texture = ExtResource( 1 ) -- cgit v1.2.3-70-g09d2