Working on level and hitbox stuff mostly because I forgot to commit to the feature branch

This commit is contained in:
Dustin 2025-04-13 12:39:18 -07:00
parent 7acdc7633c
commit 19c15fab5d
5 changed files with 110 additions and 10 deletions

View File

@ -1,4 +1,4 @@
[gd_resource type="TileSet" load_steps=17 format=2] [gd_resource type="TileSet" load_steps=21 format=2]
[ext_resource path="res://assets/levels/LegacyFantasy-High_Forest/Tiles/Tiles.png" type="Texture" id=1] [ext_resource path="res://assets/levels/LegacyFantasy-High_Forest/Tiles/Tiles.png" type="Texture" id=1]
@ -38,6 +38,18 @@ points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=12] [sub_resource type="ConvexPolygonShape2D" id=12]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 ) points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=16]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=17]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=18]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=19]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=13] [sub_resource type="ConvexPolygonShape2D" id=13]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 ) points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
@ -203,9 +215,34 @@ points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
3/navigation_offset = Vector2( 0, 0 ) 3/navigation_offset = Vector2( 0, 0 )
3/shape_offset = Vector2( 0, 0 ) 3/shape_offset = Vector2( 0, 0 )
3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
3/shape = SubResource( 16 )
3/shape_one_way = false 3/shape_one_way = false
3/shape_one_way_margin = 0.0 3/shape_one_way_margin = 1.0
3/shapes = [ ] 3/shapes = [ {
"autotile_coord": Vector2( 1, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 16 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 2, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 17 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 3, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 18 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 4, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 19 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
3/z_index = 0 3/z_index = 0
4/name = "Pillar" 4/name = "Pillar"
4/texture = ExtResource( 1 ) 4/texture = ExtResource( 1 )

View File

@ -9,10 +9,14 @@ onready var current_state :StateAnimatedActor
## return to default when no state function ## return to default when no state function
export var default_shape_when_no_state_function :bool = true export var default_shape_when_no_state_function :bool = true
export var disable_shape_when_no_state_function :bool = false
# Declare member variables here. Examples: # Declare member variables here. Examples:
# var a = 2 # var a = 2
# var b = "text" # var b = "text
## Generic parent ref node, can be kinematic2d area, etc.
var parent
var default_shape :Shape2D var default_shape :Shape2D
var default_transform :Transform2D var default_transform :Transform2D
@ -26,6 +30,8 @@ func _ready():
## A reference to the current state machine state ## A reference to the current state machine state
current_state = get_node(callable_state_machine).current_state current_state = get_node(callable_state_machine).current_state
parent = get_parent()
default_shape = shape.duplicate() default_shape = shape.duplicate()
##TODO: Are transforms primitives? Do they get passed by value? ##TODO: Are transforms primitives? Do they get passed by value?
default_transform = transform default_transform = transform
@ -49,6 +55,8 @@ func _on_state_change(old_state_name:String, new_state :State):
print ("Returning to default collision shape") print ("Returning to default collision shape")
shape = default_shape shape = default_shape
transform = default_transform transform = default_transform
if disable_shape_when_no_state_function:
set_deferred("disabled", true)
else: else:
push_warning("Received non animated Actor state.") push_warning("Received non animated Actor state.")

View File

@ -0,0 +1,29 @@
extends CollisionShape2D_StateReceiver
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_state_change_attack_sword():
print ("<---- Hey you called me to Hurt Someone!")
transform = transform.translated(Vector2(-10,10))
match current_state.animation_frame:
2:
transform.origin = Vector2(0,-16)
3:
transform.origin = Vector2(19,0)
5:
transform.origin = Vector2(20,0)
_:
set_deferred("disabled", true)

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=38 format=2] [gd_scene load_steps=41 format=2]
[ext_resource path="res://lib/parent_scenes/actor.tscn" type="PackedScene" id=1] [ext_resource path="res://lib/parent_scenes/actor.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2] [ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2]
@ -31,6 +31,8 @@
[ext_resource path="res://lib/components/Stamina_Component.tscn" type="PackedScene" id=29] [ext_resource path="res://lib/components/Stamina_Component.tscn" type="PackedScene" id=29]
[ext_resource path="res://src/actors/players/playerE/states/death.tres" type="Resource" id=30] [ext_resource path="res://src/actors/players/playerE/states/death.tres" type="Resource" id=30]
[ext_resource path="res://src/actors/players/playerE/PlayerE-CollisionShape2D_StateReceiver.gd" type="Script" id=31] [ext_resource path="res://src/actors/players/playerE/PlayerE-CollisionShape2D_StateReceiver.gd" type="Script" id=31]
[ext_resource path="res://src/actors/players/playerE/Hitbox-CollisionShape2D_StateReceiver.gd" type="Script" id=32]
[ext_resource path="res://lib/components/Hitbox_Component.tscn" type="PackedScene" id=33]
[sub_resource type="Resource" id=3] [sub_resource type="Resource" id=3]
resource_local_to_scene = true resource_local_to_scene = true
@ -76,6 +78,9 @@ extents = Vector2( 7, 14 )
[sub_resource type="RectangleShape2D" id=2] [sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 9, 15 ) extents = Vector2( 9, 15 )
[sub_resource type="RectangleShape2D" id=7]
extents = Vector2( 10, 3 )
[node name="PlayerE" instance=ExtResource( 1 )] [node name="PlayerE" instance=ExtResource( 1 )]
script = ExtResource( 3 ) script = ExtResource( 3 )
actor_type = "Player" actor_type = "Player"
@ -87,7 +92,8 @@ states = [ ExtResource( 4 ), ExtResource( 9 ), ExtResource( 7 ), ExtResource( 8
[node name="AnimatedSprite_StateReceiver" parent="." index="1"] [node name="AnimatedSprite_StateReceiver" parent="." index="1"]
frames = ExtResource( 2 ) frames = ExtResource( 2 )
animation = "attack-shoot" animation = "attack-sword"
frame = 3
script = ExtResource( 5 ) script = ExtResource( 5 )
__meta__ = { __meta__ = {
"_aseprite_wizard_config_": { "_aseprite_wizard_config_": {
@ -161,5 +167,16 @@ interactable_parent_callback = "touch_the_thing"
[node name="PewMachine" parent="." index="12" instance=ExtResource( 28 )] [node name="PewMachine" parent="." index="12" instance=ExtResource( 28 )]
[node name="Hitbox_Component" parent="." index="13" instance=ExtResource( 33 )]
collision_layer = 64
damage_amount = 10
[node name="CollisionShape2D_StateReceiver" type="CollisionShape2D" parent="Hitbox_Component" index="0"]
modulate = Color( 1, 0, 0, 1 )
position = Vector2( -20, 0 )
shape = SubResource( 7 )
script = ExtResource( 32 )
callable_state_machine = NodePath("../../Movement_StateMachine")
[connection signal="state_changed" from="Movement_StateMachine" to="." method="_on_Movement_StateMachine_state_changed"] [connection signal="state_changed" from="Movement_StateMachine" to="." method="_on_Movement_StateMachine_state_changed"]
[connection signal="health_depleted" from="Health_Component" to="." method="_on_Health_Component_health_depleted"] [connection signal="health_depleted" from="Health_Component" to="." method="_on_Health_Component_health_depleted"]

File diff suppressed because one or more lines are too long