diff --git a/Godot/Code/Character.gd b/Godot/Code/Character.gd index 61617ef..5538831 100644 --- a/Godot/Code/Character.gd +++ b/Godot/Code/Character.gd @@ -25,87 +25,100 @@ enum State { Jump, AirSpin, Land, + Attack, Roll, } func _physics_process(delta): - if not is_on_floor(): - if velocity.y > 50: - velocity.y += gravity_fall * delta - elif velocity.y < -50: - velocity.y += gravity * delta - else: - velocity.y += gravity_mid * delta - elif state == State.Jump or state == State.AirSpin: - state = State.Land - sprite.play("Land") - land_time = 0.16 - return - - if Input.is_action_just_pressed("roll"): - if is_on_floor() and roll_time <= 0 and roll_cooldown <= 0: - state = State.Roll - roll_time = 0.55 - roll_dir = -1 if sprite.flip_h else 1 - $CollisionShape2D.shape.size.y = colshape_stand / 2 - $CollisionShape2D.position.y = colshape_stand / -4 - sprite.play("GroundRoll") - if Input.is_action_just_pressed("ui_accept") and state != State.Roll: + if Input.is_action_just_pressed("attack"): if is_on_floor(): - velocity.y = JUMP_VELOCITY - sprite.play("Jump") - state = State.Jump - sprite.pause() - sprite.set_frame_and_progress(0, 0) - elif state != State.AirSpin: - sprite.play("AirSpin") - state = State.AirSpin - var boost = 0 if velocity.y > 0 else velocity.y / 3 - velocity.y = JUMP_VELOCITY / 1.4 + boost - - if state == State.Roll: - velocity.x = roll_dir * roll_speed - else: - var speed = SPEED - if Input.is_key_pressed(KEY_SHIFT): - speed /= 3 - var direction = Input.get_axis("left", "right") - if direction: - velocity.x = direction * speed - else: - # Decelerate - velocity.x = move_toward(velocity.x, 0, 25) - - if direction != 0: - sprite.flip_h = direction == -1 - - if land_time >= 0: - land_time -= delta - if roll_cooldown >= 0: - roll_cooldown -= delta - if roll_time >= 0: - roll_time -= delta - elif state == State.Roll: - $CollisionShape2D.shape.size.y = colshape_stand - $CollisionShape2D.position.y = colshape_stand / -2 - roll_cooldown = roll_cooldown_time + state = State.Attack + velocity = Vector2.ZERO + sprite.play("Attack1") + + if state == State.Attack: + await (sprite as AnimatedSprite2D).animation_finished state = State.Idle - if state == State.Jump: - if velocity.y > 50: - sprite.set_frame_and_progress(2,0) - elif velocity.y > -150: - sprite.set_frame_and_progress(1, 0) - - # If shift left/right then 2 * speed, play run - if land_time <= 0 and is_on_floor() and state != State.Jump and state != State.Roll: - if velocity.x != 0: - if Input.is_key_pressed(KEY_SHIFT): - sprite.play("Walk") + else: + if not is_on_floor(): + if velocity.y > 50: + velocity.y += gravity_fall * delta + elif velocity.y < -50: + velocity.y += gravity * delta else: - sprite.play("Run") + velocity.y += gravity_mid * delta + elif state == State.Jump or state == State.AirSpin: + state = State.Land + sprite.play("Land") + land_time = 0.16 + return + + if Input.is_action_just_pressed("roll"): + if is_on_floor() and roll_time <= 0 and roll_cooldown <= 0: + state = State.Roll + roll_time = 0.55 + roll_dir = -1 if sprite.flip_h else 1 + $CollisionShape2D.shape.size.y = colshape_stand / 2 + $CollisionShape2D.position.y = colshape_stand / -4 + sprite.play("GroundRoll") + if Input.is_action_just_pressed("ui_accept") and state != State.Roll: + if is_on_floor(): + velocity.y = JUMP_VELOCITY + sprite.play("Jump") + state = State.Jump + sprite.pause() + sprite.set_frame_and_progress(0, 0) + elif state != State.AirSpin: + sprite.play("AirSpin") + state = State.AirSpin + var boost = 0 if velocity.y > 0 else velocity.y / 3 + velocity.y = JUMP_VELOCITY / 1.4 + boost + + if state == State.Roll: + velocity.x = roll_dir * roll_speed else: - sprite.play("Idle") + var speed = SPEED + if Input.is_key_pressed(KEY_SHIFT): + speed /= 3 + var direction = Input.get_axis("left", "right") + + if direction: + velocity.x = direction * speed + else: + # Decelerate + velocity.x = move_toward(velocity.x, 0, 25) + + if direction != 0: + sprite.flip_h = direction == -1 + + if land_time >= 0: + land_time -= delta + if roll_cooldown >= 0: + roll_cooldown -= delta + if roll_time >= 0: + roll_time -= delta + elif state == State.Roll: + $CollisionShape2D.shape.size.y = colshape_stand + $CollisionShape2D.position.y = colshape_stand / -2 + roll_cooldown = roll_cooldown_time + state = State.Idle + + if state == State.Jump: + if velocity.y > 50: + sprite.set_frame_and_progress(2,0) + elif velocity.y > -150: + sprite.set_frame_and_progress(1, 0) + + # If shift left/right then 2 * speed, play run + if land_time <= 0 and is_on_floor() and state != State.Jump and state != State.Roll: + if velocity.x != 0: + if Input.is_key_pressed(KEY_SHIFT): + sprite.play("Walk") + else: + sprite.play("Run") + else: + sprite.play("Idle") move_and_slide() diff --git a/Godot/Import/Sprites/player katana attack-sheathe 80x64.png b/Godot/Import/Sprites/player katana attack-sheathe 80x64.png new file mode 100644 index 0000000..56ab97b Binary files /dev/null and b/Godot/Import/Sprites/player katana attack-sheathe 80x64.png differ diff --git a/Godot/Import/Sprites/player katana attack-sheathe 80x64.png.import b/Godot/Import/Sprites/player katana attack-sheathe 80x64.png.import new file mode 100644 index 0000000..ecfa164 --- /dev/null +++ b/Godot/Import/Sprites/player katana attack-sheathe 80x64.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cwovkjj1o7fm0" +path="res://.godot/imported/player katana attack-sheathe 80x64.png-4676fdc54f170af8c2189309f269706a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Import/Sprites/player katana attack-sheathe 80x64.png" +dest_files=["res://.godot/imported/player katana attack-sheathe 80x64.png-4676fdc54f170af8c2189309f269706a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +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/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 diff --git a/Godot/Import/Sprites/player katana continuous attack 80x64.png b/Godot/Import/Sprites/player katana continuous attack 80x64.png new file mode 100644 index 0000000..0778e6a Binary files /dev/null and b/Godot/Import/Sprites/player katana continuous attack 80x64.png differ diff --git a/Godot/Import/Sprites/player katana continuous attack 80x64.png.import b/Godot/Import/Sprites/player katana continuous attack 80x64.png.import new file mode 100644 index 0000000..9d4d200 --- /dev/null +++ b/Godot/Import/Sprites/player katana continuous attack 80x64.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cqoe7j0c5o3w3" +path="res://.godot/imported/player katana continuous attack 80x64.png-500ac913698c7a3ade722a623a783a4d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Import/Sprites/player katana continuous attack 80x64.png" +dest_files=["res://.godot/imported/player katana continuous attack 80x64.png-500ac913698c7a3ade722a623a783a4d.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +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/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 diff --git a/Godot/Scenes/Player.tscn b/Godot/Scenes/Player.tscn index 883e61f..5f66aae 100644 --- a/Godot/Scenes/Player.tscn +++ b/Godot/Scenes/Player.tscn @@ -1,13 +1,15 @@ -[gd_scene load_steps=56 format=3 uid="uid://bjc6dwxaakqdg"] +[gd_scene load_steps=83 format=3 uid="uid://bjc6dwxaakqdg"] [ext_resource type="Script" path="res://Code/Character.gd" id="1_23c20"] [ext_resource type="Texture2D" uid="uid://wfwjlevruveu" path="res://Import/Sprites/Character Idle 48x48.png" id="2_8h572"] [ext_resource type="Texture2D" uid="uid://c87b08n23v0kx" path="res://Import/Sprites/player air spin 48x48.png" id="2_gpxo5"] [ext_resource type="Texture2D" uid="uid://clx88ivnf6id6" path="res://Import/Sprites/Player Roll 48x48.png" id="3_4dpty"] +[ext_resource type="Texture2D" uid="uid://cwovkjj1o7fm0" path="res://Import/Sprites/player katana attack-sheathe 80x64.png" id="3_ldd0x"] [ext_resource type="Texture2D" uid="uid://bge22c82umdui" path="res://Import/Sprites/PlayerWalk 48x48.png" id="3_xxdqr"] [ext_resource type="Texture2D" uid="uid://y8syonuki304" path="res://Import/Sprites/run cycle 48x48.png" id="4_rqcgh"] [ext_resource type="Texture2D" uid="uid://8ikuchoh7pyd" path="res://Import/Sprites/player jump 48x48.png" id="5_f2sni"] [ext_resource type="Texture2D" uid="uid://diiqvgeqnmn1c" path="res://Import/Sprites/player land 48x48.png" id="6_ba2s3"] +[ext_resource type="Texture2D" uid="uid://cqoe7j0c5o3w3" path="res://Import/Sprites/player katana continuous attack 80x64.png" id="10_sjvpb"] [sub_resource type="AtlasTexture" id="AtlasTexture_c40es"] atlas = ExtResource("2_gpxo5") @@ -33,6 +35,106 @@ region = Rect2(192, 0, 48, 48) atlas = ExtResource("2_gpxo5") region = Rect2(240, 0, 48, 48) +[sub_resource type="AtlasTexture" id="AtlasTexture_4y312"] +atlas = ExtResource("3_ldd0x") +region = Rect2(0, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_lc7wi"] +atlas = ExtResource("3_ldd0x") +region = Rect2(80, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_lf13m"] +atlas = ExtResource("3_ldd0x") +region = Rect2(160, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bkbg6"] +atlas = ExtResource("3_ldd0x") +region = Rect2(240, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gh4du"] +atlas = ExtResource("3_ldd0x") +region = Rect2(320, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yh84k"] +atlas = ExtResource("3_ldd0x") +region = Rect2(400, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_myi62"] +atlas = ExtResource("3_ldd0x") +region = Rect2(480, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ba8as"] +atlas = ExtResource("3_ldd0x") +region = Rect2(560, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_nbmkv"] +atlas = ExtResource("3_ldd0x") +region = Rect2(640, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dvg4c"] +atlas = ExtResource("3_ldd0x") +region = Rect2(720, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0liim"] +atlas = ExtResource("3_ldd0x") +region = Rect2(800, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_em1mn"] +atlas = ExtResource("3_ldd0x") +region = Rect2(880, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_73cfr"] +atlas = ExtResource("3_ldd0x") +region = Rect2(960, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qp1t3"] +atlas = ExtResource("3_ldd0x") +region = Rect2(1040, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rcujh"] +atlas = ExtResource("3_ldd0x") +region = Rect2(1120, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_km0fj"] +atlas = ExtResource("3_ldd0x") +region = Rect2(1200, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0audb"] +atlas = ExtResource("10_sjvpb") +region = Rect2(0, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_4322d"] +atlas = ExtResource("10_sjvpb") +region = Rect2(80, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_vnrrw"] +atlas = ExtResource("10_sjvpb") +region = Rect2(160, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_u7b31"] +atlas = ExtResource("10_sjvpb") +region = Rect2(240, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mgpi0"] +atlas = ExtResource("10_sjvpb") +region = Rect2(320, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_56uqh"] +atlas = ExtResource("10_sjvpb") +region = Rect2(400, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5mbn8"] +atlas = ExtResource("10_sjvpb") +region = Rect2(480, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_icpi6"] +atlas = ExtResource("10_sjvpb") +region = Rect2(560, 0, 80, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_fht4k"] +atlas = ExtResource("10_sjvpb") +region = Rect2(640, 0, 80, 64) + [sub_resource type="AtlasTexture" id="AtlasTexture_7tnm4"] atlas = ExtResource("3_4dpty") region = Rect2(0, 0, 48, 48) @@ -216,6 +318,103 @@ animations = [{ }, { "frames": [{ "duration": 1.0, +"texture": SubResource("AtlasTexture_4y312") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_lc7wi") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_lf13m") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_bkbg6") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gh4du") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gh4du") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gh4du") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gh4du") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gh4du") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yh84k") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_myi62") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ba8as") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_nbmkv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dvg4c") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0liim") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_em1mn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_73cfr") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qp1t3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rcujh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_km0fj") +}], +"loop": false, +"name": &"Attack1", +"speed": 15.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_0audb") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_4322d") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_vnrrw") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_u7b31") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mgpi0") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_56uqh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5mbn8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_icpi6") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_fht4k") +}], +"loop": true, +"name": &"Attack2", +"speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, "texture": SubResource("AtlasTexture_7tnm4") }, { "duration": 1.0, @@ -372,7 +571,8 @@ script = ExtResource("1_23c20") texture_filter = 1 position = Vector2(0, -16) sprite_frames = SubResource("SpriteFrames_gvqqb") -animation = &"AirSpin" +animation = &"Idle" +autoplay = "Idle" metadata/_edit_lock_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="."] diff --git a/Godot/project.godot b/Godot/project.godot index 6bbb31b..f97abef 100644 --- a/Godot/project.godot +++ b/Godot/project.godot @@ -51,6 +51,11 @@ down={ } roll={ "deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":108,"echo":false,"script":null) +] +} +attack={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":74,"key_label":0,"unicode":106,"echo":false,"script":null) ] }