little work
This commit is contained in:
parent
f389e4e807
commit
ab79ace226
4 changed files with 179 additions and 98 deletions
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
|||
[remap]
|
||||
|
||||
importer="aseprite_wizard.plugin.spriteframes"
|
||||
type="SpriteFrames"
|
||||
importer="aseprite_wizard.plugin.static-texture"
|
||||
type="PortableCompressedTexture2D"
|
||||
uid="uid://d0dy3j0qdycqf"
|
||||
path="res://.godot/imported/player.aseprite-704c4b9b828702113ecb71676625aeb4.res"
|
||||
|
||||
|
|
@ -14,8 +14,8 @@ dest_files=["res://.godot/imported/player.aseprite-704c4b9b828702113ecb71676625a
|
|||
|
||||
layer/exclude_layers_pattern=""
|
||||
layer/only_visible_layers=true
|
||||
sheet/sheet_type="packed"
|
||||
layer/split_layers=false
|
||||
first_frame_only=false
|
||||
sheet/sheet_type="horizontal"
|
||||
sheet/sheet_columns=12
|
||||
sheet/frame_padding=0
|
||||
sheet/scale=1
|
||||
animation/round_fps=true
|
||||
|
|
|
|||
|
|
@ -22,6 +22,12 @@ var jump_ascent_speed := 200.0
|
|||
var late_jump_time_limit := 0.15
|
||||
@export_custom(PROPERTY_HINT_NONE, "suffix:px/s")
|
||||
var slash_speed_boost := 90.0
|
||||
## The angle difference from perfect left/right that still counts.
|
||||
@export_range(0, 360, 0.1, "radians_as_degrees")
|
||||
var side_input_angle := PI / 4
|
||||
## The angle difference from perfect down that still counts.
|
||||
@export_range(0, 360, 0.1, "radians_as_degrees")
|
||||
var down_input_angle := PI / 4
|
||||
|
||||
var _max_input_buffer_time_usec:
|
||||
get():
|
||||
|
|
@ -31,6 +37,7 @@ var _is_jumping := false
|
|||
var _jump_allowed_time := 0.0
|
||||
var _current_direction := Vector2.ZERO
|
||||
var _is_facing_right := true
|
||||
@onready var _playback: AnimationNodeStateMachinePlayback = %AnimationTree["parameters/playback"]
|
||||
|
||||
var _input_buffer: Array[BufferedInput] = []
|
||||
|
||||
|
|
@ -41,10 +48,6 @@ class BufferedInput:
|
|||
var time: int
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
%Body.play()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_echo():
|
||||
return
|
||||
|
|
@ -52,14 +55,12 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||
or event.is_action(&"move_right")
|
||||
or event.is_action(&"move_up")
|
||||
or event.is_action(&"move_down") ):
|
||||
_current_direction = Vector2(
|
||||
Input.get_axis(&"move_left", &"move_right"),
|
||||
Input.get_axis(&"move_up", &"move_down"),
|
||||
_current_direction = Input.get_vector(
|
||||
&"move_left",
|
||||
&"move_right",
|
||||
&"move_up",
|
||||
&"move_down",
|
||||
)
|
||||
if _current_direction.x < 0:
|
||||
_is_facing_right = false
|
||||
elif _current_direction.x > 0:
|
||||
_is_facing_right = true
|
||||
if event.is_action(&"jump") or event.is_action(&"attack"):
|
||||
var buffered_input := BufferedInput.new()
|
||||
buffered_input.direction = _current_direction
|
||||
|
|
@ -70,13 +71,18 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if _current_direction.x < 0:
|
||||
_is_facing_right = false
|
||||
elif _current_direction.x > 0:
|
||||
_is_facing_right = true
|
||||
|
||||
# Walking on the floor
|
||||
if is_on_floor():
|
||||
if sign(velocity.x) != sign(_current_direction.x):
|
||||
velocity.x *= grounded_speed_stop_decay ** delta
|
||||
else:
|
||||
velocity.x *= grounded_speed_decay ** delta
|
||||
var target_vel_x := _current_direction.x * walk_max_speed
|
||||
var target_vel_x: float = sign(_current_direction.x) * walk_max_speed
|
||||
var is_walking := target_vel_x != 0
|
||||
if not is_walking or abs(velocity.x) < walk_max_speed:
|
||||
velocity.x = move_toward(
|
||||
|
|
@ -127,12 +133,6 @@ func _is_holding_wall() -> bool:
|
|||
func _process(_delta: float) -> void:
|
||||
handle_buffered_inputs()
|
||||
%Body.scale.x = 1 if _is_facing_right else -1
|
||||
if _is_holding_wall():
|
||||
%Body.play(&"wall_grab")
|
||||
elif is_on_floor() and _current_direction.x != 0.0:
|
||||
%Body.play(&"walk")
|
||||
else:
|
||||
%Body.play(&"idle")
|
||||
|
||||
|
||||
func handle_buffered_inputs() -> void:
|
||||
|
|
@ -151,7 +151,7 @@ func handle_buffered_inputs() -> void:
|
|||
# Grounded jump
|
||||
if (input.event.is_pressed()
|
||||
and _jump_allowed_time > 0
|
||||
and (not is_on_floor() or input.direction.y <= 0) ):
|
||||
and (not is_on_floor() or not is_input_vec_down(input.direction)) ):
|
||||
input_found = true
|
||||
_jump_allowed_time = 0
|
||||
_jump_ascent_remaining_time = jump_ascent_max_time
|
||||
|
|
@ -172,8 +172,15 @@ func handle_buffered_inputs() -> void:
|
|||
elif input.event.is_action_pressed(&"attack"):
|
||||
input_found = true
|
||||
velocity.x += (1 if _is_facing_right else -1) * slash_speed_boost
|
||||
_playback.travel(&"attack")
|
||||
_input_buffer = _input_buffer.slice(i + 1)
|
||||
break
|
||||
$AnimationPlayer.play("slash")
|
||||
|
||||
if input_found:
|
||||
_input_buffer = _input_buffer.slice(i + 1)
|
||||
break
|
||||
|
||||
|
||||
func is_input_vec_down(vec: Vector2) -> bool:
|
||||
return abs(vec.angle_to(Vector2.DOWN)) < down_input_angle and vec.length() > 0.1
|
||||
|
|
|
|||
|
|
@ -1,98 +1,166 @@
|
|||
[gd_scene format=3 uid="uid://ce2k04khaub8n"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bx500kvj301vt" path="res://player/player.gd" id="1_g1dw6"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://d0dy3j0qdycqf" path="res://player/player.aseprite" id="2_yw30f"]
|
||||
[ext_resource type="Texture2D" uid="uid://d0dy3j0qdycqf" path="res://player/player.aseprite" id="2_yw30f"]
|
||||
[ext_resource type="Texture2D" uid="uid://blw6f2ktsrcmg" path="res://player/hair.aseprite" id="3_qjkh3"]
|
||||
[ext_resource type="Script" uid="uid://b7shvbf7iv6an" path="res://spring2d.gd" id="4_yw30f"]
|
||||
[ext_resource type="Script" uid="uid://bk0k3j7th00wu" path="res://player/ribbon.gd" id="5_qjkh3"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_e2o6t"]
|
||||
radius = 4.0
|
||||
height = 14.0
|
||||
|
||||
[sub_resource type="Animation" id="Animation_g6k8r"]
|
||||
[sub_resource type="Animation" id="Animation_yw30f"]
|
||||
resource_name = "RESET"
|
||||
length = 0.001
|
||||
step = 0.016666668
|
||||
tracks/0/type = "bezier"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Body/Ribbon:position:x")
|
||||
tracks/0/path = NodePath("Body:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"handle_modes": PackedInt32Array(2),
|
||||
"points": PackedFloat32Array(1, -0.1666675, 0, 0.1666675, 0),
|
||||
"times": PackedFloat32Array(0)
|
||||
}
|
||||
tracks/1/type = "bezier"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Body/Ribbon:position:y")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"handle_modes": PackedInt32Array(2),
|
||||
"points": PackedFloat32Array(1, -0.1666675, 0, 0.1666675, 0),
|
||||
"times": PackedFloat32Array(0)
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Body/Ribbon:new_segments_damage")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
"values": [0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_qjkh3"]
|
||||
resource_name = "slash"
|
||||
length = 0.20000167
|
||||
step = 0.016666668
|
||||
tracks/0/type = "bezier"
|
||||
resource_name = "idle"
|
||||
length = 1.0000017
|
||||
loop_mode = 1
|
||||
step = 0.1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Body/Ribbon:position:x")
|
||||
tracks/0/path = NodePath("Body:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"handle_modes": PackedInt32Array(0, 2, 2, 2, 2, 2, 2, 2, 0),
|
||||
"points": PackedFloat32Array(3, 0, 0, 0.027242973, 2.1666667, 5, -6.0920916e-05, 0.02146086, 0.002777778, -0.9785392, -5, -0.002777778, 0.5833334, 0.002777778, -0.5833334, -3, -0.002777778, -0.75, 0.0027777783, 0.75000006, 21, -0.0027777783, -2.2500002, 0.0027777776, 2.2499998, 46, -0.0027777776, 0.45238093, 0.016666668, -2.7142859, 9, -0.016666668, 5.7148743, 0.005692142, -1.9517924, 2, -0.005555558, 1.4640074, 0.00013658404, -0.035992794, 0, -0.0029143642, 0.16666667, 0, 0),
|
||||
"times": PackedFloat32Array(-0.00036552548, 0, 0.016666668, 0.033333335, 0.050000004, 0.06666667, 0.16666667, 0.20000002, 0.20081952)
|
||||
}
|
||||
tracks/1/type = "bezier"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Body/Ribbon:position:y")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"handle_modes": PackedInt32Array(0, 2, 2, 2, 2, 2, 2, 2, 0),
|
||||
"points": PackedFloat32Array(2, 0, 0, 0.027242973, -0.33333334, 5, -6.0920916e-05, 0, 0.002777778, 0, 3, -0.002777778, 0.6666667, 0.002777778, -0.6666667, -4, -0.002777778, 0.49999997, 0.0027777783, -0.5, -6, -0.0027777783, -0.33333337, 0.0027777776, 0.33333328, 0, -0.0027777776, -0.23809522, 0.016666668, 1.4285715, 8, -0.016666668, 0, 0.005692142, 0, 3, -0.005555558, 1.3013397, 0.00013658404, -0.03199359, 0, -0.0029143642, -0.16666667, 0, 0),
|
||||
"times": PackedFloat32Array(-0.00036552548, 0, 0.016666668, 0.033333335, 0.050000004, 0.06666667, 0.16666667, 0.20000002, 0.20081952)
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Body/Ribbon:new_segments_damage")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 0.016666668, 0.16666667),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false, true, false]
|
||||
"values": [0]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_g6k8r"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_g6k8r"),
|
||||
&"slash": SubResource("Animation_qjkh3")
|
||||
[sub_resource type="Animation" id="Animation_g6k8r"]
|
||||
resource_name = "slash"
|
||||
length = 0.20000167
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Body:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [6]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_boad6"]
|
||||
resource_name = "walk"
|
||||
length = 0.400005
|
||||
loop_mode = 1
|
||||
step = 0.1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Body:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 1, 2, 3]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_rgyib"]
|
||||
resource_name = "wall_hold"
|
||||
length = 1.0000017
|
||||
loop_mode = 1
|
||||
step = 0.1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Body:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [5]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_rgyib"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_yw30f"),
|
||||
&"idle": SubResource("Animation_qjkh3"),
|
||||
&"slash": SubResource("Animation_g6k8r"),
|
||||
&"walk": SubResource("Animation_boad6"),
|
||||
&"wall_hold": SubResource("Animation_rgyib")
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_qjkh3"]
|
||||
animation = &"slash"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_yw30f"]
|
||||
animation = &"idle"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_g6k8r"]
|
||||
animation = &"walk"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_boad6"]
|
||||
animation = &"wall_hold"
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_boad6"]
|
||||
switch_mode = 2
|
||||
advance_mode = 2
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_rgyib"]
|
||||
break_loop_at_end = true
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_hg6s5"]
|
||||
advance_mode = 2
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_8t03j"]
|
||||
advance_mode = 2
|
||||
advance_expression = "is_on_floor() and _current_direction.x != 0.0"
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_2ieo8"]
|
||||
break_loop_at_end = true
|
||||
advance_mode = 2
|
||||
advance_expression = "not is_on_floor() or _current_direction.x == 0.0"
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_ebec5"]
|
||||
advance_expression = "_is_on_wall()"
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_yllr7"]
|
||||
advance_mode = 2
|
||||
advance_expression = "_is_holding_wall()"
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_kb6p2"]
|
||||
advance_mode = 2
|
||||
advance_expression = "not _is_holding_wall()"
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_yllr7"]
|
||||
allow_transition_to_self = true
|
||||
states/attack/node = SubResource("AnimationNodeAnimation_qjkh3")
|
||||
states/attack/position = Vector2(604.5, 41.5)
|
||||
states/idle/node = SubResource("AnimationNodeAnimation_yw30f")
|
||||
states/idle/position = Vector2(428.5, 88.5)
|
||||
states/walk/node = SubResource("AnimationNodeAnimation_g6k8r")
|
||||
states/walk/position = Vector2(628.5, 203.5)
|
||||
states/wall_hold/node = SubResource("AnimationNodeAnimation_boad6")
|
||||
states/wall_hold/position = Vector2(362.82965, 231.5)
|
||||
transitions = ["attack", "idle", SubResource("AnimationNodeStateMachineTransition_boad6"), "idle", "attack", SubResource("AnimationNodeStateMachineTransition_rgyib"), "Start", "idle", SubResource("AnimationNodeStateMachineTransition_hg6s5"), "idle", "walk", SubResource("AnimationNodeStateMachineTransition_8t03j"), "walk", "idle", SubResource("AnimationNodeStateMachineTransition_2ieo8"), "walk", "attack", SubResource("AnimationNodeStateMachineTransition_ebec5"), "idle", "wall_hold", SubResource("AnimationNodeStateMachineTransition_yllr7"), "wall_hold", "idle", SubResource("AnimationNodeStateMachineTransition_kb6p2")]
|
||||
graph_offset = Vector2(-59.670364, -27)
|
||||
|
||||
[node name="Player" type="CharacterBody2D" unique_id=500011307]
|
||||
physics_interpolation_mode = 1
|
||||
collision_layer = 2
|
||||
|
|
@ -107,16 +175,21 @@ shape = SubResource("CapsuleShape2D_e2o6t")
|
|||
[node name="Camera2D" type="Camera2D" parent="." unique_id=1975474809]
|
||||
limit_enabled = false
|
||||
|
||||
[node name="Body" type="AnimatedSprite2D" parent="." unique_id=559621433]
|
||||
[node name="Body" type="Sprite2D" parent="." unique_id=567060128]
|
||||
unique_name_in_owner = true
|
||||
sprite_frames = ExtResource("2_yw30f")
|
||||
animation = &"idle"
|
||||
autoplay = "idle"
|
||||
texture = ExtResource("2_yw30f")
|
||||
hframes = 7
|
||||
metadata/_aseprite_wizard_interface_config_ = {
|
||||
"animation_section": true,
|
||||
"animation_section": false,
|
||||
"layer_section": false,
|
||||
"output_section": false,
|
||||
"pending_changes": {
|
||||
"convert_fps_field": 60.0,
|
||||
"convert_ms_field": 16.0,
|
||||
"convert_to_fps": false,
|
||||
"i_mode": 0,
|
||||
"keep_anim_length": false,
|
||||
"player": "",
|
||||
"source": "res://player/player.aseprite"
|
||||
},
|
||||
"slice_section": false
|
||||
|
|
@ -142,14 +215,15 @@ script = ExtResource("4_yw30f")
|
|||
max_offset = Vector2(1, 2)
|
||||
|
||||
[node name="Hair" type="Sprite2D" parent="Body/Spring2D" unique_id=796557000]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2(-2, 2)
|
||||
texture = ExtResource("3_qjkh3")
|
||||
|
||||
[node name="Ribbon" type="Node2D" parent="Body" unique_id=45519559]
|
||||
position = Vector2(1, 1)
|
||||
script = ExtResource("5_qjkh3")
|
||||
color = Color(0.49411765, 0.76862746, 0.75686276, 1)
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=1251324400]
|
||||
libraries/ = SubResource("AnimationLibrary_g6k8r")
|
||||
libraries/ = SubResource("AnimationLibrary_rgyib")
|
||||
|
||||
[node name="AnimationTree" type="AnimationTree" parent="AnimationPlayer" unique_id=1839424284]
|
||||
unique_name_in_owner = true
|
||||
root_node = NodePath("%AnimationTree/../..")
|
||||
tree_root = SubResource("AnimationNodeStateMachine_yllr7")
|
||||
advance_expression_base_node = NodePath("../..")
|
||||
anim_player = NodePath("..")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue