chill out bro:

This commit is contained in:
pennyrigate 2025-03-01 19:49:37 -05:00
parent cbbf55a48a
commit ddd02953da
10 changed files with 178 additions and 7 deletions

20
objects/ice/ice.gd Normal file
View file

@ -0,0 +1,20 @@
extends Node2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _on_area_2d_body_entered(body: Node2D) -> void:
if body is Player:
body.ices_touched += 1
func _on_area_2d_body_exited(body: Node2D) -> void:
body.ices_touched -= 1

34
objects/ice/ice.tscn Normal file
View file

@ -0,0 +1,34 @@
[gd_scene load_steps=5 format=3 uid="uid://b5eso40mjhlmv"]
[ext_resource type="Texture2D" uid="uid://d0e475k64fbja" path="res://assets/textures/ice/ice.png" id="1_0p7ug"]
[ext_resource type="Script" path="res://objects/ice/ice.gd" id="1_hgdc3"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_sv4q1"]
size = Vector2(16, 17)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_xodyg"]
size = Vector2(16, 16)
[node name="Ice" type="Node2D"]
script = ExtResource("1_hgdc3")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_0p7ug")
[node name="Area2D" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 16
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2(0, -0.5)
shape = SubResource("RectangleShape2D_sv4q1")
[node name="StaticBody2D" type="StaticBody2D" parent="."]
collision_layer = 2
collision_mask = 16
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
shape = SubResource("RectangleShape2D_xodyg")
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
[connection signal="body_exited" from="Area2D" to="." method="_on_area_2d_body_exited"]

View file

@ -10,6 +10,14 @@ extends CharacterBody2D
@export var state_chart: StateChart
@export var graphics: Node2D
var ices_touched:int = 0:
set(value):
ices_touched = value
if ices_touched <= 0:
ices_touched = 0
state_chart.send_event(&"ground_touched")
else:
state_chart.send_event(&"ice_touched")
#region Notifications
func _ready() -> void:

View file

@ -47,6 +47,8 @@ script = ExtResource("9_ht8un")
expression = "player.velocity.y >= 0.0"
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("state_chart", "graphics")]
collision_layer = 16
collision_mask = 3
floor_snap_length = 3.0
script = ExtResource("1_jgave")
gravity = 400.0
@ -120,6 +122,12 @@ to = NodePath("../../Airborne")
guard = SubResource("Resource_4mj4w")
delay_in_seconds = "0.0"
[node name="On ice_touched" type="Node" parent="StateChart/Root/Grounded"]
script = ExtResource("8_pgje5")
to = NodePath("../Sliding")
event = &"ice_touched"
delay_in_seconds = "0.0"
[node name="On jump_pressed" type="Node" parent="StateChart/Root/Grounded"]
script = ExtResource("8_pgje5")
to = NodePath("../../Airborne/Jumping")
@ -135,6 +143,15 @@ to = NodePath("../../Running")
guard = SubResource("Resource_kdmd2")
delay_in_seconds = "0.0"
[node name="Sliding" type="Node" parent="StateChart/Root/Grounded"]
script = ExtResource("7_56odx")
[node name="On ground_touched" type="Node" parent="StateChart/Root/Grounded/Sliding"]
script = ExtResource("8_pgje5")
to = NodePath("../../Standing")
event = &"ground_touched"
delay_in_seconds = "0.0"
[node name="Running" type="Node" parent="StateChart/Root/Grounded"]
script = ExtResource("7_56odx")
@ -176,6 +193,7 @@ 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/Sliding" 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"]