import the woofer

This commit is contained in:
Haze Weathers 2025-03-01 17:50:05 -05:00
parent 825fee53e2
commit 3e89acfea8
92 changed files with 5783 additions and 0 deletions

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

@ -0,0 +1,59 @@
class_name Player
extends CharacterBody2D
@export var gravity: float
@export var run_speed: float
@export var jump_force: float
@export_group("Node References")
@export var state_chart: StateChart
@export var graphics: Node2D
#region Notifications
func _ready() -> void:
state_chart.set_expression_property(&"player", self)
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed(&"ui_accept"):
state_chart.send_event(&"jump_pressed")
func _process(delta: float) -> void:
if is_on_floor():
graphics.rotation = get_floor_angle()
else:
graphics.rotation = 0.0
func _physics_process(delta: float) -> void:
state_chart.set_expression_property(&"on_floor", is_on_floor())
var h_input = Input.get_axis(&"ui_left", &"ui_right")
state_chart.set_expression_property(&"horizontal_input", h_input != 0.0)
move_and_slide()
#endregion
#region State Processing
func _process_run(delta: float) -> void:
var h_input = Input.get_axis(&"ui_left", &"ui_right")
velocity.x = h_input * run_speed
graphics.scale.x = signf(h_input)
func _process_gravity(delta: float) -> void:
velocity.y += gravity * delta
#endregion
#region State One-Shots
func _do_jump() -> void:
velocity.y = -jump_force
position.y -= 1.0
func _stop_moving() -> void:
velocity = Vector2.ZERO
#endregion

View file

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

185
objects/player/player.tscn Normal file
View file

@ -0,0 +1,185 @@
[gd_scene load_steps=19 format=3 uid="uid://mh2gfm7iqqsm"]
[ext_resource type="Script" path="res://objects/player/player.gd" id="1_jgave"]
[ext_resource type="Shader" path="res://assets/shaders/clean_edge.gdshader" id="2_cpj48"]
[ext_resource type="Texture2D" uid="uid://dscugobu0xe5t" path="res://assets/textures/player/woofer.png" id="2_oy6xr"]
[ext_resource type="Script" path="res://scripts/spritesheet_animation/spritesheet_animation.gd" id="4_dldqk"]
[ext_resource type="Script" path="res://addons/godot_state_charts/state_chart.gd" id="5_yg0e1"]
[ext_resource type="Script" path="res://addons/godot_state_charts/compound_state.gd" id="6_nf3pt"]
[ext_resource type="Script" path="res://addons/godot_state_charts/atomic_state.gd" id="7_56odx"]
[ext_resource type="Script" path="res://addons/godot_state_charts/transition.gd" id="8_pgje5"]
[ext_resource type="Script" path="res://addons/godot_state_charts/expression_guard.gd" id="9_ht8un"]
[ext_resource type="Script" path="res://addons/godot_state_charts/not_guard.gd" id="10_jkoqe"]
[sub_resource type="CircleShape2D" id="CircleShape2D_tvyy1"]
radius = 6.0208
[sub_resource type="SeparationRayShape2D" id="SeparationRayShape2D_57odn"]
length = 2.0
[sub_resource type="ShaderMaterial" id="ShaderMaterial_12eq7"]
shader = ExtResource("2_cpj48")
shader_parameter/highestColor = Vector3(1, 1, 1)
shader_parameter/similarThreshold = 0.0
shader_parameter/lineWidth = 1.0
[sub_resource type="Resource" id="Resource_g8pxc"]
resource_name = "On Floor"
script = ExtResource("9_ht8un")
expression = "on_floor"
[sub_resource type="Resource" id="Resource_4mj4w"]
script = ExtResource("10_jkoqe")
guard = SubResource("Resource_g8pxc")
[sub_resource type="Resource" id="Resource_kdmd2"]
resource_name = "Horizontal Input"
script = ExtResource("9_ht8un")
expression = "horizontal_input"
[sub_resource type="Resource" id="Resource_p43ft"]
script = ExtResource("10_jkoqe")
guard = SubResource("Resource_kdmd2")
[sub_resource type="Resource" id="Resource_g7rrk"]
resource_name = "Downward Velocity"
script = ExtResource("9_ht8un")
expression = "player.velocity.y >= 0.0"
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("state_chart", "graphics")]
floor_snap_length = 3.0
script = ExtResource("1_jgave")
gravity = 200.0
run_speed = 64.0
jump_force = 120.0
state_chart = NodePath("StateChart")
graphics = NodePath("Graphics")
[node name="CollisionShape" type="CollisionShape2D" parent="."]
position = Vector2(0, -6)
shape = SubResource("CircleShape2D_tvyy1")
debug_color = Color(3.32102e-06, 0.648976, 0.161954, 0.42)
[node name="SeparationShapeRight" type="CollisionShape2D" parent="."]
position = Vector2(5, -2)
shape = SubResource("SeparationRayShape2D_57odn")
debug_color = Color(0.850748, 0.32846, 0.463602, 0.42)
[node name="Graphics" type="Node2D" parent="."]
[node name="Sprite" type="Sprite2D" parent="Graphics"]
material = SubResource("ShaderMaterial_12eq7")
texture = ExtResource("2_oy6xr")
offset = Vector2(0, -8)
hframes = 4
vframes = 4
region_rect = Rect2(0, 0, 64, 64)
[node name="Idle" type="Node" parent="Graphics/Sprite"]
script = ExtResource("4_dldqk")
[node name="Bark" type="Node" parent="Graphics/Sprite"]
script = ExtResource("4_dldqk")
first_frame = Vector2i(1, 0)
[node name="Run" type="Node" parent="Graphics/Sprite"]
script = ExtResource("4_dldqk")
first_frame = Vector2i(0, 1)
frames = 3
fps = 8.0
loop = true
[node name="Jump" type="Node" parent="Graphics/Sprite"]
script = ExtResource("4_dldqk")
first_frame = Vector2i(2, 0)
[node name="Fall" type="Node" parent="Graphics/Sprite"]
script = ExtResource("4_dldqk")
first_frame = Vector2i(3, 0)
[node name="StateChart" type="Node" parent="."]
script = ExtResource("5_yg0e1")
track_in_editor = true
initial_expression_properties = {
"horizontal_input": false,
"on_floor": true,
"player": null
}
[node name="Root" type="Node" parent="StateChart"]
script = ExtResource("6_nf3pt")
initial_state = NodePath("Grounded")
[node name="Grounded" type="Node" parent="StateChart/Root"]
script = ExtResource("6_nf3pt")
initial_state = NodePath("Standing")
[node name="When Not On Floor" type="Node" parent="StateChart/Root/Grounded"]
script = ExtResource("8_pgje5")
to = NodePath("../../Airborne")
guard = SubResource("Resource_4mj4w")
delay_in_seconds = "0.0"
[node name="On jump_pressed" type="Node" parent="StateChart/Root/Grounded"]
script = ExtResource("8_pgje5")
to = NodePath("../../Airborne/Jumping")
event = &"jump_pressed"
delay_in_seconds = "0.0"
[node name="Standing" type="Node" parent="StateChart/Root/Grounded"]
script = ExtResource("7_56odx")
[node name="If Horizontal Input" type="Node" parent="StateChart/Root/Grounded/Standing"]
script = ExtResource("8_pgje5")
to = NodePath("../../Running")
guard = SubResource("Resource_kdmd2")
delay_in_seconds = "0.0"
[node name="Running" type="Node" parent="StateChart/Root/Grounded"]
script = ExtResource("7_56odx")
[node name="If No Horizontal Input" type="Node" parent="StateChart/Root/Grounded/Running"]
script = ExtResource("8_pgje5")
to = NodePath("../../Standing")
guard = SubResource("Resource_p43ft")
delay_in_seconds = "0.0"
[node name="Barking" type="Node" parent="StateChart/Root/Grounded"]
script = ExtResource("7_56odx")
[node name="On Timeout" type="Node" parent="StateChart/Root/Grounded/Barking"]
script = ExtResource("8_pgje5")
to = NodePath("../../Standing")
delay_in_seconds = "0.5"
[node name="Airborne" type="Node" parent="StateChart/Root"]
script = ExtResource("6_nf3pt")
initial_state = NodePath("Falling")
[node name="Jumping" type="Node" parent="StateChart/Root/Airborne"]
script = ExtResource("7_56odx")
[node name="When Jump Peaked" type="Node" parent="StateChart/Root/Airborne/Jumping"]
script = ExtResource("8_pgje5")
to = NodePath("../../Falling")
guard = SubResource("Resource_g7rrk")
delay_in_seconds = "0.0"
[node name="Falling" type="Node" parent="StateChart/Root/Airborne"]
script = ExtResource("7_56odx")
[node name="When On Floor" type="Node" parent="StateChart/Root/Airborne/Falling"]
script = ExtResource("8_pgje5")
to = NodePath("../../../Grounded")
guard = SubResource("Resource_g8pxc")
delay_in_seconds = "0.0"
[connection signal="state_entered" from="StateChart/Root/Grounded/Standing" to="." method="_stop_moving"]
[connection signal="state_entered" from="StateChart/Root/Grounded/Standing" to="Graphics/Sprite/Idle" method="play"]
[connection signal="state_entered" from="StateChart/Root/Grounded/Running" to="Graphics/Sprite/Run" method="play"]
[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_process_run"]
[connection signal="state_entered" from="StateChart/Root/Grounded/Barking" to="Graphics/Sprite/Bark" method="play"]
[connection signal="state_physics_processing" from="StateChart/Root/Airborne" to="." method="_process_gravity"]
[connection signal="state_entered" from="StateChart/Root/Airborne/Jumping" to="." method="_do_jump"]
[connection signal="state_entered" from="StateChart/Root/Airborne/Jumping" to="Graphics/Sprite/Jump" method="play"]
[connection signal="state_entered" from="StateChart/Root/Airborne/Falling" to="Graphics/Sprite/Fall" method="play"]