start of player char

This commit is contained in:
Haze Weathers 2025-11-01 19:58:18 -06:00
parent 2926a12796
commit 3c62183156
11 changed files with 335 additions and 5 deletions

10
objects/player/groove.gd Normal file
View file

@ -0,0 +1,10 @@
class_name Groove
extends CharacterBody2D
@export var max_length: float
@export var player: Player
func _physics_process(delta: float) -> void:
pass

View file

@ -0,0 +1 @@
uid://bbgvbxyesmfkg

25
objects/player/player.gd Normal file
View file

@ -0,0 +1,25 @@
class_name Player
extends CharacterBody2D
@export var walk_speed: float
@export_group("Internal References")
@export var _animations: AnimationPlayer
var is_stunned := false
func _physics_process(delta: float) -> void:
if is_stunned:
pass
else:
var input_dir = Input.get_vector(&"move_left", &"move_right", &"move_up", &"move_down")
velocity = input_dir * walk_speed
if input_dir.is_zero_approx():
_animations.play(&"idle")
else:
_animations.play(&"walk")
move_and_slide()

View file

@ -0,0 +1 @@
uid://by3eww6d7boay

View file

@ -0,0 +1,99 @@
[gd_scene load_steps=11 format=3 uid="uid://djpowg53xsgux"]
[ext_resource type="Script" uid="uid://by3eww6d7boay" path="res://objects/player/player.gd" id="1_cqmt1"]
[ext_resource type="Texture2D" uid="uid://b0myjj8ggu2gt" path="res://assets/graphics/splint.png" id="2_g7ett"]
[ext_resource type="Script" uid="uid://bbgvbxyesmfkg" path="res://objects/player/groove.gd" id="3_jnjyq"]
[ext_resource type="Texture2D" uid="uid://dgclvsxcplj81" path="res://assets/graphics/groove.png" id="3_ssrue"]
[sub_resource type="CircleShape2D" id="CircleShape2D_cqmt1"]
radius = 12.0
[sub_resource type="Animation" id="Animation_g7ett"]
resource_name = "walk"
length = 0.3
loop_mode = 1
step = 0.05
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:flip_h")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.15),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [true, false]
}
[sub_resource type="Animation" id="Animation_ssrue"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:flip_h")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
[sub_resource type="Animation" id="Animation_jnjyq"]
resource_name = "idle"
length = 0.001
step = 0.25
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:flip_h")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_gnkmh"]
_data = {
&"RESET": SubResource("Animation_ssrue"),
&"idle": SubResource("Animation_jnjyq"),
&"walk": SubResource("Animation_g7ett")
}
[sub_resource type="CircleShape2D" id="CircleShape2D_ssrue"]
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("_animations")]
motion_mode = 1
script = ExtResource("1_cqmt1")
walk_speed = 100.0
_animations = NodePath("AnimationPlayer")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_cqmt1")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_g7ett")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
&"": SubResource("AnimationLibrary_gnkmh")
}
[node name="Node" type="Node" parent="."]
[node name="Groove" type="CharacterBody2D" parent="Node" node_paths=PackedStringArray("player")]
position = Vector2(64, 0)
script = ExtResource("3_jnjyq")
max_length = 64.0
player = NodePath("../..")
[node name="Sprite2D" type="Sprite2D" parent="Node/Groove"]
texture = ExtResource("3_ssrue")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Node/Groove"]
shape = SubResource("CircleShape2D_ssrue")