Hitboxes/Hurtboxes update

This commit is contained in:
Alan Youngblood 2024-11-10 10:04:50 -05:00
parent 3e9f095d44
commit 7cb72e12cc
17 changed files with 297 additions and 12 deletions

BIN
.DS_Store vendored

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,10 @@
extends Node2D
onready var animatedSprite = $AnimatedSprite
func _ready():
animatedSprite.frame = 0
animatedSprite.play("Animate")
func _on_AnimatedSprite_animation_finished():
queue_free()

View File

@ -0,0 +1,43 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://Effects/GrassEffect.gd" type="Script" id=1]
[ext_resource path="res://Effects/GrassEffect.png" type="Texture" id=2]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 2 )
region = Rect2( 0, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 2 )
region = Rect2( 32, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 2 )
region = Rect2( 64, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 2 )
region = Rect2( 96, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 2 )
region = Rect2( 128, 0, 32, 32 )
[sub_resource type="SpriteFrames" id=6]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ],
"loop": false,
"name": "Animate",
"speed": 15.0
} ]
[node name="GrassEffect" type="Node2D"]
script = ExtResource( 1 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 6 )
animation = "Animate"
frame = 4
centered = false
[connection signal="animation_finished" from="AnimatedSprite" to="." method="_on_AnimatedSprite_animation_finished"]

View File

@ -0,0 +1,7 @@
[gd_scene format=2]
[node name="Hitbox" type="Area2D"]
collision_layer = 0
collision_mask = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]

View File

@ -0,0 +1,7 @@
[gd_scene format=2]
[node name="Hurtbox" type="Area2D"]
collision_layer = 0
collision_mask = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]

View File

@ -22,7 +22,7 @@ onready var animationState = animationTree.get("parameters/playback")
func _ready():
animationTree.active = true
func _physics_process(delta):
func _process(delta):
match state:
MOVE:
move_state(delta)

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=40 format=2]
[gd_scene load_steps=42 format=2]
[ext_resource path="res://Player/Player.gd" type="Script" id=1]
[ext_resource path="res://Player/Player.png" type="Texture" id=2]
[ext_resource path="res://Overlap/Hitbox.tscn" type="PackedScene" id=3]
[sub_resource type="CapsuleShape2D" id=1]
radius = 4.0
@ -36,6 +37,30 @@ tracks/1/keys = {
"method": "attack_aninimation_finished"
} ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("HitboxPivot:rotation_degrees")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 90.0 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("HitboxPivot/SwordHitbox/CollisionShape2D:disabled")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0.1, 0.4 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ false, true ]
}
[sub_resource type="Animation" id=28]
resource_name = "AttackLeft"
@ -66,6 +91,30 @@ tracks/1/keys = {
"method": "attack_aninimation_finished"
} ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("HitboxPivot:rotation_degrees")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 180.0 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("HitboxPivot/SwordHitbox/CollisionShape2D:disabled")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0.1, 0.4 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ false, true ]
}
[sub_resource type="Animation" id=29]
resource_name = "AttackRight"
@ -77,7 +126,7 @@ tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.1, 0.2, 0.3 ),
"times": PoolRealArray( 0, 0.100979, 0.2, 0.3 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 1,
"values": [ 24, 25, 26, 27 ]
@ -96,6 +145,30 @@ tracks/1/keys = {
"method": "attack_aninimation_finished"
} ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("HitboxPivot:rotation_degrees")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0.0 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("HitboxPivot/SwordHitbox/CollisionShape2D:disabled")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0.1, 0.4 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ false, true ]
}
[sub_resource type="Animation" id=30]
resource_name = "AttackUp"
@ -126,6 +199,30 @@ tracks/1/keys = {
"method": "attack_aninimation_finished"
} ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("HitboxPivot:rotation_degrees")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 270.0 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("HitboxPivot/SwordHitbox/CollisionShape2D:disabled")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0.106438, 0.4 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ false, true ]
}
[sub_resource type="Animation" id=9]
resource_name = "IdleDown"
@ -209,6 +306,18 @@ tracks/0/keys = {
"update": 0,
"values": [ 0 ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("HitboxPivot/SwordHitbox/CollisionShape2D:disabled")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ true ]
}
[sub_resource type="Animation" id=6]
resource_name = "RunDown"
@ -377,7 +486,11 @@ start_node = "Idle"
[sub_resource type="AnimationNodeStateMachinePlayback" id=19]
[sub_resource type="CapsuleShape2D" id=40]
height = 12.0
[node name="Player" type="KinematicBody2D"]
collision_layer = 2
script = ExtResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
@ -411,3 +524,20 @@ parameters/playback = SubResource( 19 )
parameters/Attack/blend_position = Vector2( 0, 0 )
parameters/Idle/blend_position = Vector2( 0, 0 )
parameters/Run/blend_position = Vector2( 0, 0 )
[node name="HitboxPivot" type="Position2D" parent="."]
position = Vector2( 0, -4 )
rotation = 4.71239
__meta__ = {
"_gizmo_extents_": 8.0
}
[node name="SwordHitbox" parent="HitboxPivot" instance=ExtResource( 3 )]
position = Vector2( 15, 0 )
collision_mask = 8
[node name="CollisionShape2D" parent="HitboxPivot/SwordHitbox" index="0"]
shape = SubResource( 40 )
disabled = true
[editable path="HitboxPivot/SwordHitbox"]

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=59 format=2]
[gd_scene load_steps=60 format=2]
[ext_resource path="res://World/Bush.tscn" type="PackedScene" id=1]
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://World/GrassBackground.png" type="Texture" id=3]
[ext_resource path="res://World/DirtTileset.png" type="Texture" id=4]
[ext_resource path="res://World/CliffTileset.png" type="Texture" id=5]
[ext_resource path="res://World/Grass.tscn" type="PackedScene" id=6]
[sub_resource type="TileSet" id=1]
0/name = "DirtTileset.png 0"
@ -533,25 +534,60 @@ tile_data = PoolIntArray( 9, 0, 0, 10, 0, 2, 65545, 0, 65536, 65546, 0, 65538, 6
[node name="DirtCliffTileMap" type="TileMap" parent="."]
tile_set = SubResource( 2 )
cell_size = Vector2( 32, 32 )
collision_mask = 0
format = 1
tile_data = PoolIntArray( 0, 0, 4, 1, 0, 196609, 2, 0, 196609, 3, 0, 196610, 7, 0, 196608, 8, 0, 196609, 9, 0, 7, 65536, 0, 131075, 65545, 0, 131075, 196611, 0, 3, 196617, 0, 3, 262144, 0, 0, 262145, 0, 1, 262146, 0, 1, 262147, 0, 131079, 262152, 0, 196608, 262153, 0, 262151, 327680, 0, 131072, 327681, 0, 131073, 327682, 0, 131073, 327683, 0, 131074, 327689, 0, 131075 )
[node name="YSort" type="YSort" parent="."]
[node name="Player" parent="YSort" instance=ExtResource( 2 )]
position = Vector2( 88, 64 )
position = Vector2( 111, 71 )
__meta__ = {
"_edit_group_": true
}
[node name="Bush" parent="YSort" instance=ExtResource( 1 )]
position = Vector2( 56, 56 )
[node name="Bushes" type="YSort" parent="YSort"]
[node name="Bush2" parent="YSort" instance=ExtResource( 1 )]
position = Vector2( 184, 136 )
[node name="Bush" parent="YSort/Bushes" instance=ExtResource( 1 )]
position = Vector2( 62, 58 )
[node name="Bush3" parent="YSort" instance=ExtResource( 1 )]
[node name="Bush2" parent="YSort/Bushes" instance=ExtResource( 1 )]
position = Vector2( 188, 145 )
[node name="Bush3" parent="YSort/Bushes" instance=ExtResource( 1 )]
position = Vector2( 192, 56 )
[node name="Bush4" parent="YSort" instance=ExtResource( 1 )]
[node name="Bush4" parent="YSort/Bushes" instance=ExtResource( 1 )]
position = Vector2( 240, 152 )
[node name="Grass" type="YSort" parent="YSort"]
[node name="Grass" parent="YSort/Grass" instance=ExtResource( 6 )]
position = Vector2( 32, 32 )
[node name="Grass2" parent="YSort/Grass" instance=ExtResource( 6 )]
position = Vector2( 209, 0 )
[node name="Grass3" parent="YSort/Grass" instance=ExtResource( 6 )]
position = Vector2( 272, 113 )
[node name="Grass4" parent="YSort/Grass" instance=ExtResource( 6 )]
position = Vector2( 255, 113 )
[node name="Grass5" parent="YSort/Grass" instance=ExtResource( 6 )]
position = Vector2( 271, 95 )
[node name="Grass6" parent="YSort/Grass" instance=ExtResource( 6 )]
position = Vector2( 81, 96 )
[node name="Grass7" parent="YSort/Grass" instance=ExtResource( 6 )]
position = Vector2( 80, 112 )
[node name="Grass8" parent="YSort/Grass" instance=ExtResource( 6 )]
position = Vector2( 64, 112 )
[node name="Grass9" parent="YSort/Grass" instance=ExtResource( 6 )]
position = Vector2( 48, 112 )
[node name="Grass10" parent="YSort/Grass" instance=ExtResource( 6 )]
position = Vector2( 128, 121 )

View File

@ -0,0 +1,18 @@
extends Node2D
# 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 create_grass_effect():
var GrassEffect = load("res://Effects/GrassEffect.tscn")
var grassEffect = GrassEffect.instance()
var world = get_tree().current_scene
world.add_child(grassEffect)
grassEffect.global_position = global_position
func _on_Hurtbox_area_entered(area):
create_grass_effect()
queue_free()

View File

@ -0,0 +1,27 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://World/Grass.png" type="Texture" id=1]
[ext_resource path="res://World/Grass.gd" type="Script" id=2]
[ext_resource path="res://Overlap/Hurtbox.tscn" type="PackedScene" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 7, 7 )
[node name="Grass" type="Node2D"]
script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
centered = false
offset = Vector2( -8, -8 )
[node name="Hurtbox" parent="." instance=ExtResource( 3 )]
collision_layer = 8
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2( 8, 8 )
shape = SubResource( 1 )
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[editable path="Hurtbox"]

Binary file not shown.

BIN
ActionRPG-HeartBeast/build/web/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -139,7 +139,7 @@
<script type='text/javascript' src='index.js'></script>
<script type='text/javascript'>//<![CDATA[
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":2249584,"index.wasm":13790961},"focusCanvas":true,"gdnativeLibs":[]};
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":2258384,"index.wasm":13790961},"focusCanvas":true,"gdnativeLibs":[]};
var engine = new Engine(GODOT_CONFIG);
(function() {

View File

@ -87,6 +87,13 @@ attack={
]
}
[layer_names]
2d_physics/layer_1="World"
2d_physics/layer_2="Player"
2d_physics/layer_3="PlayerHurtbox"
2d_physics/layer_4="EnemyHurtbox"
[physics]
common/enable_pause_aware_picking=true