Compare commits

..

No commits in common. "7c1275f477364b52931c4475e305cc91e57e06ba" and "4f18f997352d117a74285813ed4cacc608ce88e9" have entirely different histories.

7 changed files with 48 additions and 530 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ca744qwgmwejx"
path="res://.godot/imported/bnuuy-spritesheet.png-948399fca383ea0fdc4492e69ecb4f3c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://scenes/player/assets/bnuuy-spritesheet.png"
dest_files=["res://.godot/imported/bnuuy-spritesheet.png-948399fca383ea0fdc4492e69ecb4f3c.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -6,21 +6,18 @@ const DEADZONE: float = 0.1
@export var max_speed: float = 90 @export var max_speed: float = 90
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D @onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
@onready var anim_player: AnimationPlayer = $AnimationPlayer
@onready var state_machine: StateMachine = $StateMachine @onready var state_machine: StateMachine = $StateMachine
@onready var hit_timer: Timer = $HitTimer @onready var hit_timer: Timer = $HitTimer
var anim_dir: String var anim_dir: String
var def_dir: String var def_dir: String
func _ready() -> void: func _ready() -> void:
assert(id == 1 or id == 2, "id ("+str(id)+") is invalid") assert(id == 1 or id == 2, "id ("+str(id)+") is invalid")
anim_dir = 'up' if id == 1 else 'down' anim_dir = 'up' if id == 1 else 'down'
def_dir = 'idle_up' if id == 1 else 'idle_down' def_dir = 'up' if id == 1 else 'down'
hit_timer.connect("timeout", $StateMachine/Hitting._on_hit_end) hit_timer.connect("timeout", $StateMachine/Hitting._on_hit_end)
func get_movement_vector() -> Vector2: func get_movement_vector() -> Vector2:
var x_mov: float = Input.get_action_strength('p'+str(id)+'_move_right') - Input.get_action_strength('p'+str(id)+'_move_left') var x_mov: float = Input.get_action_strength('p'+str(id)+'_move_right') - Input.get_action_strength('p'+str(id)+'_move_left')
var y_mov: float = Input.get_action_strength('p'+str(id)+'_move_down') - Input.get_action_strength('p'+str(id)+'_move_up') var y_mov: float = Input.get_action_strength('p'+str(id)+'_move_down') - Input.get_action_strength('p'+str(id)+'_move_up')

View file

@ -1,381 +1,12 @@
[gd_scene load_steps=38 format=3 uid="uid://642nm6c4mpxx"] [gd_scene load_steps=21 format=3 uid="uid://642nm6c4mpxx"]
[ext_resource type="Script" uid="uid://rdqmsvofiots" path="res://scenes/player/player.gd" id="1_v6fml"] [ext_resource type="Script" uid="uid://rdqmsvofiots" path="res://scenes/player/player.gd" id="1_v6fml"]
[ext_resource type="Texture2D" uid="uid://b8ptokcqwpdud" path="res://scenes/player/saffron.png" id="2_3li8b"] [ext_resource type="Texture2D" uid="uid://b8ptokcqwpdud" path="res://scenes/player/saffron.png" id="2_3li8b"]
[ext_resource type="Texture2D" uid="uid://ca744qwgmwejx" path="res://scenes/player/assets/bnuuy-spritesheet.png" id="3_0owmy"]
[ext_resource type="Script" uid="uid://dqjaxgmyxq3rx" path="res://scenes/classes/state_machine.gd" id="3_lvxji"] [ext_resource type="Script" uid="uid://dqjaxgmyxq3rx" path="res://scenes/classes/state_machine.gd" id="3_lvxji"]
[ext_resource type="Script" uid="uid://delyni51vg6us" path="res://scenes/player/states/idle.gd" id="4_75vfm"] [ext_resource type="Script" uid="uid://delyni51vg6us" path="res://scenes/player/states/idle.gd" id="4_75vfm"]
[ext_resource type="Script" uid="uid://dxfs1b8fuk7kv" path="res://scenes/player/states/running.gd" id="5_75vfm"] [ext_resource type="Script" uid="uid://dxfs1b8fuk7kv" path="res://scenes/player/states/running.gd" id="5_75vfm"]
[ext_resource type="Script" uid="uid://n7v8leojhykt" path="res://scenes/player/states/hitting.gd" id="6_75vfm"] [ext_resource type="Script" uid="uid://n7v8leojhykt" path="res://scenes/player/states/hitting.gd" id="6_75vfm"]
[sub_resource type="Animation" id="Animation_gx1jg"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AnimatedSprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [1]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("AnimatedSprite2D:animation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"idle_up"]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("AnimatedSprite2D:speed_scale")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [1.0]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("AnimatedSprite2D:offset:y")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [-16.0]
}
[sub_resource type="Animation" id="Animation_fm80t"]
resource_name = "idle_down"
length = 2.0
loop_mode = 1
step = 0.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AnimatedSprite2D:frame")
tracks/0/interp = 0
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.6800001, 1.1299999, 1.7200001),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 1,
"values": [0, 1, 2, 1]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("AnimatedSprite2D:animation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"idle_down"]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("AnimatedSprite2D:speed_scale")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}
[sub_resource type="Animation" id="Animation_0owmy"]
resource_name = "idle_up"
length = 2.0
loop_mode = 1
step = 0.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AnimatedSprite2D:frame")
tracks/0/interp = 0
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.6800001, 1.1299999, 1.7200001),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 1,
"values": [0, 1, 2, 1]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("AnimatedSprite2D:animation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"idle_up"]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("AnimatedSprite2D:speed_scale")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}
[sub_resource type="Animation" id="Animation_qek5x"]
resource_name = "walk_right"
length = 0.475
loop_mode = 1
step = 0.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AnimatedSprite2D:frame")
tracks/0/interp = 0
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.12206663, 0.20329137, 0.37493116),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 1,
"values": [1, 0, 1, 2]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("AnimatedSprite2D:animation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"right"]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("AnimatedSprite2D:speed_scale")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("AnimatedSprite2D:offset:y")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0, 0.12206663, 0.20329137, 0.37493116),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 1,
"values": [-16.0, -18.0, -16.0, -18.0]
}
[sub_resource type="Animation" id="Animation_5gtgg"]
resource_name = "walk_left"
length = 0.475
loop_mode = 1
step = 0.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AnimatedSprite2D:frame")
tracks/0/interp = 0
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.12206663, 0.20329137, 0.37493116),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 1,
"values": [1, 0, 1, 2]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("AnimatedSprite2D:animation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"right"]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("AnimatedSprite2D:speed_scale")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("AnimatedSprite2D:offset:y")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0, 0.12206663, 0.20329137, 0.37493116),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 1,
"values": [-16.0, -18.0, -16.0, -18.0]
}
[sub_resource type="Animation" id="Animation_h17s1"]
resource_name = "hit_left_up"
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AnimatedSprite2D:animation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"idle_up"]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("AnimatedSprite2D:frame")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0]
}
[sub_resource type="Animation" id="Animation_je7p5"]
resource_name = "hit_right_up"
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AnimatedSprite2D:animation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"idle_up"]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("AnimatedSprite2D:frame")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [2]
}
[sub_resource type="Animation" id="Animation_ugbui"]
resource_name = "hit_right_down"
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AnimatedSprite2D:animation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"idle_down"]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("AnimatedSprite2D:frame")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [2]
}
[sub_resource type="Animation" id="Animation_fcs02"]
resource_name = "hit_left_down"
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AnimatedSprite2D:animation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"idle_down"]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("AnimatedSprite2D:frame")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ugbui"]
_data = {
&"RESET": SubResource("Animation_gx1jg"),
&"hit_left_down": SubResource("Animation_fcs02"),
&"hit_left_up": SubResource("Animation_h17s1"),
&"hit_right_down": SubResource("Animation_ugbui"),
&"hit_right_up": SubResource("Animation_je7p5"),
&"idle_down": SubResource("Animation_fm80t"),
&"idle_up": SubResource("Animation_0owmy"),
&"walk_left": SubResource("Animation_5gtgg"),
&"walk_right": SubResource("Animation_qek5x")
}
[sub_resource type="AtlasTexture" id="AtlasTexture_g2els"] [sub_resource type="AtlasTexture" id="AtlasTexture_g2els"]
atlas = ExtResource("2_3li8b") atlas = ExtResource("2_3li8b")
region = Rect2(0, 64, 24, 32) region = Rect2(0, 64, 24, 32)
@ -388,53 +19,29 @@ region = Rect2(24, 64, 24, 32)
atlas = ExtResource("2_3li8b") atlas = ExtResource("2_3li8b")
region = Rect2(48, 64, 24, 32) region = Rect2(48, 64, 24, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qek5x"] [sub_resource type="AtlasTexture" id="AtlasTexture_qlg0r"]
atlas = ExtResource("3_0owmy") atlas = ExtResource("2_3li8b")
region = Rect2(96, 0, 32, 32) region = Rect2(0, 96, 24, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_5gtgg"] [sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"]
atlas = ExtResource("3_0owmy") atlas = ExtResource("2_3li8b")
region = Rect2(128, 0, 32, 32) region = Rect2(24, 96, 24, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_h17s1"] [sub_resource type="AtlasTexture" id="AtlasTexture_fjrip"]
atlas = ExtResource("3_0owmy") atlas = ExtResource("2_3li8b")
region = Rect2(160, 0, 32, 32) region = Rect2(48, 96, 24, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_0owmy"] [sub_resource type="AtlasTexture" id="AtlasTexture_smehm"]
atlas = ExtResource("3_0owmy") atlas = ExtResource("2_3li8b")
region = Rect2(192, 0, 32, 32) region = Rect2(0, 32, 24, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_je7p5"] [sub_resource type="AtlasTexture" id="AtlasTexture_ur7pv"]
atlas = ExtResource("3_0owmy") atlas = ExtResource("2_3li8b")
region = Rect2(224, 0, 32, 32) region = Rect2(24, 32, 24, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_fm80t"] [sub_resource type="AtlasTexture" id="AtlasTexture_y4r1p"]
atlas = ExtResource("3_0owmy") atlas = ExtResource("2_3li8b")
region = Rect2(256, 0, 32, 32) region = Rect2(48, 32, 24, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_myrg7"]
atlas = ExtResource("3_0owmy")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_kvlxm"]
atlas = ExtResource("3_0owmy")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_uf5tr"]
atlas = ExtResource("3_0owmy")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_gx1jg"]
atlas = ExtResource("3_0owmy")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ugbui"]
atlas = ExtResource("3_0owmy")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_fcs02"]
atlas = ExtResource("3_0owmy")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_d2wvv"] [sub_resource type="AtlasTexture" id="AtlasTexture_d2wvv"]
atlas = ExtResource("2_3li8b") atlas = ExtResource("2_3li8b")
@ -469,41 +76,16 @@ animations = [{
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_qek5x") "texture": SubResource("AtlasTexture_qlg0r")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_5gtgg") "texture": SubResource("AtlasTexture_tuyoq")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_h17s1") "texture": SubResource("AtlasTexture_fjrip")
}],
"loop": true,
"name": &"idle_down",
"speed": 0.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_0owmy")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_je7p5") "texture": SubResource("AtlasTexture_tuyoq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_fm80t")
}],
"loop": true,
"name": &"idle_up",
"speed": 0.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_myrg7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_kvlxm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uf5tr")
}], }],
"loop": true, "loop": true,
"name": &"left", "name": &"left",
@ -511,17 +93,20 @@ animations = [{
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_gx1jg") "texture": SubResource("AtlasTexture_smehm")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_ugbui") "texture": SubResource("AtlasTexture_ur7pv")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_fcs02") "texture": SubResource("AtlasTexture_y4r1p")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ur7pv")
}], }],
"loop": true, "loop": true,
"name": &"right", "name": &"right",
"speed": 0.0 "speed": 5.0
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
@ -541,8 +126,9 @@ animations = [{
"speed": 5.0 "speed": 5.0
}] }]
[sub_resource type="CircleShape2D" id="CircleShape2D_0owmy"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_oprun"]
radius = 8.0 radius = 5.0
height = 16.0
[node name="Player" type="CharacterBody2D"] [node name="Player" type="CharacterBody2D"]
collision_layer = 2 collision_layer = 2
@ -550,20 +136,15 @@ collision_mask = 13
floor_stop_on_slope = false floor_stop_on_slope = false
script = ExtResource("1_v6fml") script = ExtResource("1_v6fml")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
&"": SubResource("AnimationLibrary_ugbui")
}
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_f1ej7") sprite_frames = SubResource("SpriteFrames_f1ej7")
animation = &"idle_up" animation = &"down"
frame_progress = 0.29168898
offset = Vector2(0, -16) offset = Vector2(0, -16)
flip_h = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(-1, -8) position = Vector2(0, -8)
shape = SubResource("CircleShape2D_0owmy") shape = SubResource("CapsuleShape2D_oprun")
[node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("initial_state")] [node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("initial_state")]
script = ExtResource("3_lvxji") script = ExtResource("3_lvxji")

View file

@ -19,18 +19,9 @@ func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
previous_state_path = _previous_state_path previous_state_path = _previous_state_path
hit_dir = _data.get("hit_dir") hit_dir = _data.get("hit_dir")
#player.sprite.play('up' if player.id == 1 else 'down') player.sprite.play('up' if player.id == 1 else 'down')
#player.sprite.frame = 1 player.sprite.frame = 1
#player.sprite.pause() player.sprite.pause()
player.anim_player.play("hit_"+hit_dir+"_up" if player.id == 1 else "hit_"+hit_dir+"_down")
assert(
player.anim_player.current_animation == "hit_left_up" or
player.anim_player.current_animation == "hit_left_down" or
player.anim_player.current_animation == "hit_right_up" or
player.anim_player.current_animation == "hit_right_down",
"invalid animation ("+player.anim_player.current_animation+")"
)
var sprite_texture: Texture2D = player.sprite.sprite_frames.get_frame_texture('up', 1) var sprite_texture: Texture2D = player.sprite.sprite_frames.get_frame_texture('up', 1)
var hit_node: Area2D = preload("res://scenes/hit/hit.tscn").instantiate() var hit_node: Area2D = preload("res://scenes/hit/hit.tscn").instantiate()

View file

@ -6,11 +6,9 @@ func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
player.velocity = Vector2.ZERO player.velocity = Vector2.ZERO
player.move_and_slide() player.move_and_slide()
#player.sprite.play(player.def_dir) player.sprite.play(player.def_dir)
#player.sprite.frame = 1 player.sprite.frame = 1
#player.sprite.pause() player.sprite.pause()
player.anim_player.play(player.def_dir)
print("entered") print("entered")

View file

@ -24,21 +24,12 @@ func _state_physics_update(_delta: float) -> void:
return return
if abs(player.velocity.x) > abs(player.velocity.y): if abs(player.velocity.x) > abs(player.velocity.y):
# TODO: implement walk left animation to stop doing flip_h player.anim_dir = 'right' if player.velocity.x > 0 else 'left'
if player.velocity.x > 0:
if player.anim_player.current_animation != "walk_right": player.anim_player.play("walk_right")
player.sprite.flip_h = false
else:
if player.anim_player.current_animation != "walk_left": player.anim_player.play("walk_left")
player.sprite.flip_h = true
else: else:
# TODO: walking up and down animations player.anim_dir = 'down' if player.velocity.y > 0 else 'up'
#player.anim_dir = 'down' if player.velocity.y > 0 else 'up'
pass
#player.sprite.play(player.anim_dir) player.sprite.play(player.anim_dir)
func _exit() -> void: func _exit() -> void:
player.anim_player.stop() player.sprite.stop()
player.sprite.flip_h = false
print("exit") print("exit")