Small player refactor
This commit is contained in:
parent
3f838d6edc
commit
6cd7c017cc
5 changed files with 33 additions and 32 deletions
|
@ -1,3 +1,4 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
## Prevents the player from sliding/walljumping
|
||||||
@export var no_wallslide := false
|
@export var no_wallslide := false
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
[ext_resource type="Script" path="res://state_machine/Dash.gd" id="8_cenpi"]
|
[ext_resource type="Script" path="res://state_machine/Dash.gd" id="8_cenpi"]
|
||||||
[ext_resource type="Script" path="res://state_machine/Wallslide.gd" id="8_g5obm"]
|
[ext_resource type="Script" path="res://state_machine/Wallslide.gd" id="8_g5obm"]
|
||||||
[ext_resource type="Shape2D" uid="uid://c1iuvxx2i661g" path="res://player/shape.tres" id="9_lka70"]
|
[ext_resource type="Shape2D" uid="uid://c1iuvxx2i661g" path="res://player/shape.tres" id="9_lka70"]
|
||||||
[ext_resource type="Script" path="res://state_machine/misc/HitBox.gd" id="10_anmyf"]
|
|
||||||
[ext_resource type="Script" path="res://state_machine/misc/HurtBox.gd" id="10_mejgj"]
|
[ext_resource type="Script" path="res://state_machine/misc/HurtBox.gd" id="10_mejgj"]
|
||||||
[ext_resource type="Script" path="res://state_machine/Death.gd" id="12_33ksn"]
|
[ext_resource type="Script" path="res://state_machine/Death.gd" id="12_33ksn"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c25ofwwebxe3m" path="res://assets/characters/player/atk/atk d.png" id="12_hw4yd"]
|
[ext_resource type="Texture2D" uid="uid://c25ofwwebxe3m" path="res://assets/characters/player/atk/atk d.png" id="12_hw4yd"]
|
||||||
|
@ -39,6 +38,7 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://bqxyd08o0jo33" path="res://assets/characters/player/respawn/respawn.png" id="28_opbni"]
|
[ext_resource type="Texture2D" uid="uid://bqxyd08o0jo33" path="res://assets/characters/player/respawn/respawn.png" id="28_opbni"]
|
||||||
[ext_resource type="Texture2D" uid="uid://8cpq5vfdeio4" path="res://assets/characters/player/wallslide/wallslide l.png" id="29_3n5cc"]
|
[ext_resource type="Texture2D" uid="uid://8cpq5vfdeio4" path="res://assets/characters/player/wallslide/wallslide l.png" id="29_3n5cc"]
|
||||||
[ext_resource type="AudioStream" uid="uid://bahjna6lj84iw" path="res://assets/sounds/hurt.mp3" id="37_3cxyn"]
|
[ext_resource type="AudioStream" uid="uid://bahjna6lj84iw" path="res://assets/sounds/hurt.mp3" id="37_3cxyn"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://1x4yec1dhsr2" path="res://state_machine/misc/HitBox.tscn" id="39_n188b"]
|
||||||
|
|
||||||
[sub_resource type="Curve" id="Curve_w1mwi"]
|
[sub_resource type="Curve" id="Curve_w1mwi"]
|
||||||
max_value = 300.0
|
max_value = 300.0
|
||||||
|
@ -507,36 +507,27 @@ stream = ExtResource("37_3cxyn")
|
||||||
|
|
||||||
[node name="Hitboxes" type="Node2D" parent="."]
|
[node name="Hitboxes" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="Up" type="Area2D" parent="Hitboxes"]
|
[node name="Up" parent="Hitboxes" instance=ExtResource("39_n188b")]
|
||||||
collision_layer = 0
|
|
||||||
collision_mask = 2
|
collision_mask = 2
|
||||||
script = ExtResource("10_anmyf")
|
|
||||||
active = false
|
active = false
|
||||||
damage = 10
|
|
||||||
|
|
||||||
[node name="Shape" type="CollisionShape2D" parent="Hitboxes/Up"]
|
[node name="Shape" type="CollisionShape2D" parent="Hitboxes/Up"]
|
||||||
position = Vector2(0, -70)
|
position = Vector2(0, -70)
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
shape = SubResource("CapsuleShape2D_tyvbo")
|
shape = SubResource("CapsuleShape2D_tyvbo")
|
||||||
|
|
||||||
[node name="Down" type="Area2D" parent="Hitboxes"]
|
[node name="Down" parent="Hitboxes" instance=ExtResource("39_n188b")]
|
||||||
collision_layer = 0
|
|
||||||
collision_mask = 2
|
collision_mask = 2
|
||||||
script = ExtResource("10_anmyf")
|
|
||||||
active = false
|
active = false
|
||||||
damage = 10
|
|
||||||
|
|
||||||
[node name="Shape" type="CollisionShape2D" parent="Hitboxes/Down"]
|
[node name="Shape" type="CollisionShape2D" parent="Hitboxes/Down"]
|
||||||
position = Vector2(0, 72)
|
position = Vector2(0, 72)
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
shape = SubResource("CapsuleShape2D_vt7h5")
|
shape = SubResource("CapsuleShape2D_vt7h5")
|
||||||
|
|
||||||
[node name="Side" type="Area2D" parent="Hitboxes"]
|
[node name="Side" parent="Hitboxes" instance=ExtResource("39_n188b")]
|
||||||
collision_layer = 0
|
|
||||||
collision_mask = 2
|
collision_mask = 2
|
||||||
script = ExtResource("10_anmyf")
|
|
||||||
active = false
|
active = false
|
||||||
damage = 10
|
|
||||||
|
|
||||||
[node name="Shape" type="CollisionShape2D" parent="Hitboxes/Side"]
|
[node name="Shape" type="CollisionShape2D" parent="Hitboxes/Side"]
|
||||||
position = Vector2(77, -6)
|
position = Vector2(77, -6)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
extends Area2D
|
extends Node2D
|
||||||
## Generic hitbox, lingering or not
|
## Generic hitbox, lingering or not
|
||||||
|
|
||||||
signal hit(data) ## If actor using this wants to know if something is hit
|
signal hit(data) ## If actor using this wants to know if something is hit
|
||||||
|
@ -20,12 +20,9 @@ signal hit(data) ## If actor using this wants to know if something is hit
|
||||||
# During one hit, the same hurtbox can only be hit once
|
# During one hit, the same hurtbox can only be hit once
|
||||||
var hits := {}
|
var hits := {}
|
||||||
|
|
||||||
func _ready():
|
|
||||||
area_entered.connect(_on_area_entered)
|
|
||||||
area_exited.connect(_on_area_exited)
|
|
||||||
|
|
||||||
## Hitting something emits a signal and calls hit on the victim
|
## Hitting something emits a signal and calls hit on the victim
|
||||||
func _hit_something(what):
|
func _hit_something(what):
|
||||||
|
if active:
|
||||||
var data := {
|
var data := {
|
||||||
"damage": damage,
|
"damage": damage,
|
||||||
"hitbox": self,
|
"hitbox": self,
|
||||||
|
@ -43,11 +40,12 @@ func _process(_delta):
|
||||||
for node in hits:
|
for node in hits:
|
||||||
_hit_something(node)
|
_hit_something(node)
|
||||||
|
|
||||||
func _on_area_entered(area):
|
|
||||||
|
func actor_enter(area):
|
||||||
if hits.has(area):
|
if hits.has(area):
|
||||||
return
|
return
|
||||||
hits[area] = true
|
hits[area] = true
|
||||||
_hit_something(area)
|
_hit_something(area)
|
||||||
|
|
||||||
func _on_area_exited(area):
|
func actor_exit(area):
|
||||||
hits.erase(area)
|
hits.erase(area)
|
||||||
|
|
|
@ -7,3 +7,6 @@ collision_layer = 0
|
||||||
collision_mask = 4
|
collision_mask = 4
|
||||||
script = ExtResource("1_wc5uu")
|
script = ExtResource("1_wc5uu")
|
||||||
knockback = Vector2(200, -200)
|
knockback = Vector2(200, -200)
|
||||||
|
|
||||||
|
[connection signal="area_entered" from="." to="." method="actor_enter"]
|
||||||
|
[connection signal="area_exited" from="." to="." method="actor_exit"]
|
||||||
|
|
|
@ -19,7 +19,7 @@ inherit_limit = true
|
||||||
|
|
||||||
[node name="Collision" type="TileMapLayer" parent="."]
|
[node name="Collision" type="TileMapLayer" parent="."]
|
||||||
scale = Vector2(0.5, 0.5)
|
scale = Vector2(0.5, 0.5)
|
||||||
tile_map_data = PackedByteArray("AAAAABAAAAAAAAAAAAABABAAAAAAAAAAAAACABAAAAAAAAAAAAADABAAAAAAAAAAAAAEABAAAAAAAAAAAAAFABAAAAAAAAAAAAAGABAAAAAAAAAAAAAHABAAAAAAAAAAAAAIABAAAAAAAAAAAAAJABAAAAAAAAAAAAAKABAAAAAAAAAAAAALABAAAAAAAAAAAAAMABAAAAAAAAAAAAANABAAAAAAAAAAAAAOABAAAAAAAAAAAAAPABAAAAAAAAAAAAAQABAAAAAAAAAAAAARABAAAAAAAAAAAAASABAAAAAAAAAAAAATABAAAAAAAAAAAAAUABAAAAAAAAAAAAAVABAAAAAAAAAAAAAWABAAAAAAAAAAAAAXABAAAAAAAAAAAAAYABAAAAAAAAAAAAAZABAAAAAAAAAAAAAaABAAAAAAAAAAAAAbABAAAAAAAAAAAAAcABAAAAAAAAAAAAAdABAAAAAAAAAAAAA=")
|
tile_map_data = PackedByteArray("AAAAABAAAAAAAAAAAAABABAAAAAAAAAAAAACABAAAAAAAAAAAAADABAAAAAAAAAAAAAEABAAAAAAAAAAAAAFABAAAAAAAAAAAAAGABAAAAAAAAAAAAAHABAAAAAAAAAAAAAIABAAAAAAAAAAAAAJABAAAAAAAAAAAAAKABAAAAAAAAAAAAALABAAAAAAAAAAAAAMABAAAAAAAAAAAAANABAAAAAAAAAAAAAOABAAAAAAAAAAAAAPABAAAAAAAAAAAAAQABAAAAAAAAAAAAARABAAAAAAAAAAAAASABAAAAAAAAAAAAATABAAAAAAAAAAAAAUABAAAAAAAAAAAAAVABAAAAAAAAAAAAAWABAAAAAAAAAAAAAXABAAAAAAAAAAAAAYABAAAAAAAAAAAAAZABAAAAAAAAAAAAAaABAAAAAAAAAAAAAbABAAAAAAAAAAAAAcABAAAAAAAAAAAAAdABAAAAAAAAAAAAANAA4AAAAAAAAAAAANAA8AAAAAAAAAAAASAA4AAAAAAAAAAAASAA8AAAAAAAAAAAA=")
|
||||||
tile_set = ExtResource("2_l8ggp")
|
tile_set = ExtResource("2_l8ggp")
|
||||||
|
|
||||||
[node name="NoSlide" type="TileMapLayer" parent="."]
|
[node name="NoSlide" type="TileMapLayer" parent="."]
|
||||||
|
@ -30,6 +30,14 @@ tile_set = ExtResource("2_l8ggp")
|
||||||
script = ExtResource("3_g21q1")
|
script = ExtResource("3_g21q1")
|
||||||
no_wallslide = true
|
no_wallslide = true
|
||||||
|
|
||||||
|
[node name="Acid" type="TileMapLayer" parent="."]
|
||||||
|
modulate = Color(0.900298, 0.753927, 0.894313, 1)
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
tile_map_data = PackedByteArray("AAAOAA8AAAAAAAAAAAAPAA8AAAAAAAAAAAAQAA8AAAAAAAAAAAARAA8AAAAAAAAAAAA=")
|
||||||
|
tile_set = ExtResource("2_l8ggp")
|
||||||
|
script = ExtResource("3_g21q1")
|
||||||
|
no_wallslide = true
|
||||||
|
|
||||||
[node name="SceneTransition" parent="." instance=ExtResource("3_fe1fg")]
|
[node name="SceneTransition" parent="." instance=ExtResource("3_fe1fg")]
|
||||||
position = Vector2(161, 958)
|
position = Vector2(161, 958)
|
||||||
walk = false
|
walk = false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue