diff --git a/.import/slash_effect_anim_spritesheet.png-3702611dfcce89cd9721b467abc49fbd.md5 b/.import/slash_effect_anim_spritesheet.png-3702611dfcce89cd9721b467abc49fbd.md5 index 8a9b429..2f1eb9d 100644 --- a/.import/slash_effect_anim_spritesheet.png-3702611dfcce89cd9721b467abc49fbd.md5 +++ b/.import/slash_effect_anim_spritesheet.png-3702611dfcce89cd9721b467abc49fbd.md5 @@ -1,3 +1,3 @@ source_md5="39b3d8583205c90284cd60f0e018f29d" -dest_md5="52cfea7aa3d138927af2e1c7588f90dd" +dest_md5="4ce9d0860f904c4c550d375db85f5dbe" diff --git a/.import/slash_effect_anim_spritesheet.png-3702611dfcce89cd9721b467abc49fbd.stex b/.import/slash_effect_anim_spritesheet.png-3702611dfcce89cd9721b467abc49fbd.stex index a1fd026..d1b7d85 100644 Binary files a/.import/slash_effect_anim_spritesheet.png-3702611dfcce89cd9721b467abc49fbd.stex and b/.import/slash_effect_anim_spritesheet.png-3702611dfcce89cd9721b467abc49fbd.stex differ diff --git a/.import/weapon_sword_1.png-e17b5819c65b4aa28788a53c68a37d70.md5 b/.import/weapon_sword_1.png-e17b5819c65b4aa28788a53c68a37d70.md5 index 7cc5e88..727b00a 100644 --- a/.import/weapon_sword_1.png-e17b5819c65b4aa28788a53c68a37d70.md5 +++ b/.import/weapon_sword_1.png-e17b5819c65b4aa28788a53c68a37d70.md5 @@ -1,3 +1,3 @@ source_md5="290f29e73374ffb00e4aa61a383c707f" -dest_md5="c84a1eb2d5df3915de49fddf1e67b6cc" +dest_md5="24e0abbb82a08a4daf6d28c1acdb3c38" diff --git a/.import/weapon_sword_1.png-e17b5819c65b4aa28788a53c68a37d70.stex b/.import/weapon_sword_1.png-e17b5819c65b4aa28788a53c68a37d70.stex index 08a0501..c751fe3 100644 Binary files a/.import/weapon_sword_1.png-e17b5819c65b4aa28788a53c68a37d70.stex and b/.import/weapon_sword_1.png-e17b5819c65b4aa28788a53c68a37d70.stex differ diff --git a/Art/v1.1 dungeon crawler 16x16 pixel pack/effects (new)/slash_effect_anim_spritesheet.png.import b/Art/v1.1 dungeon crawler 16x16 pixel pack/effects (new)/slash_effect_anim_spritesheet.png.import index 6e5f2a3..5cf5cb0 100644 --- a/Art/v1.1 dungeon crawler 16x16 pixel pack/effects (new)/slash_effect_anim_spritesheet.png.import +++ b/Art/v1.1 dungeon crawler 16x16 pixel pack/effects (new)/slash_effect_anim_spritesheet.png.import @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 @@ -30,5 +30,5 @@ process/HDR_as_SRGB=false process/invert_color=false stream=false size_limit=0 -detect_3d=true +detect_3d=false svg/scale=1.0 diff --git a/Art/v1.1 dungeon crawler 16x16 pixel pack/heroes/knight/weapon_sword_1.png.import b/Art/v1.1 dungeon crawler 16x16 pixel pack/heroes/knight/weapon_sword_1.png.import index 2d11d41..23e560a 100644 --- a/Art/v1.1 dungeon crawler 16x16 pixel pack/heroes/knight/weapon_sword_1.png.import +++ b/Art/v1.1 dungeon crawler 16x16 pixel pack/heroes/knight/weapon_sword_1.png.import @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 @@ -30,5 +30,5 @@ process/HDR_as_SRGB=false process/invert_color=false stream=false size_limit=0 -detect_3d=true +detect_3d=false svg/scale=1.0 diff --git a/Characters/Player/Player.gd b/Characters/Player/Player.gd index b17172c..1f81565 100644 --- a/Characters/Player/Player.gd +++ b/Characters/Player/Player.gd @@ -1,5 +1,8 @@ extends Character +onready var sword: Node2D = get_node("Sword") +onready var sword_animation_player: AnimationPlayer = sword.get_node("SwordAnimationPlayer") + func _process(_delta: float) -> void: var mouse_direction: Vector2 = (get_global_mouse_position() - global_position).normalized() @@ -9,6 +12,14 @@ func _process(_delta: float) -> void: elif mouse_direction.x < 0 and not animated_sprite.flip_h: animated_sprite.flip_h = true + sword.rotation = mouse_direction.angle() + if sword.scale.y == 1 and mouse_direction.x < 0: + sword.scale.y = -1 + elif sword.scale.y == -1 and mouse_direction.x > 0: + sword.scale.y = 1 + if Input.is_action_just_pressed("ui_attack") and not sword_animation_player.is_playing(): + sword_animation_player.play("attack") + func get_input() -> void: mov_direction = Vector2.ZERO diff --git a/Characters/Player/Player.tscn b/Characters/Player/Player.tscn index e732e06..5546930 100644 --- a/Characters/Player/Player.tscn +++ b/Characters/Player/Player.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=21 format=2] +[gd_scene load_steps=25 format=2] [ext_resource path="res://Characters/Character.tscn" type="PackedScene" id=1] [ext_resource path="res://Art/v1.1 dungeon crawler 16x16 pixel pack/heroes/knight/knight_idle_spritesheet.png" type="Texture" id=2] [ext_resource path="res://Art/v1.1 dungeon crawler 16x16 pixel pack/heroes/knight/knight_run_spritesheet.png" type="Texture" id=3] [ext_resource path="res://Characters/Player/Player.gd" type="Script" id=4] [ext_resource path="res://Characters/Player/PlayerFSM.gd" type="Script" id=5] +[ext_resource path="res://Art/v1.1 dungeon crawler 16x16 pixel pack/heroes/knight/weapon_sword_1.png" type="Texture" id=6] +[ext_resource path="res://Art/v1.1 dungeon crawler 16x16 pixel pack/effects (new)/slash_effect_anim_spritesheet.png" type="Texture" id=7] [sub_resource type="AtlasTexture" id=1] atlas = ExtResource( 2 ) @@ -67,8 +69,63 @@ animations = [ { "speed": 5.0 } ] -[sub_resource type="Animation" id=14] -resource_name = "idle" +[sub_resource type="CircleShape2D" id=14] +radius = 4.0 + +[sub_resource type="Animation" id=15] +resource_name = "attack" +length = 1.25 +step = 0.05 +tracks/0/type = "value" +tracks/0/path = NodePath("Node2D:rotation_degrees") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.15, 0.8, 1.25 ), +"transitions": PoolRealArray( 1, 1, 1, 1 ), +"update": 0, +"values": [ -90.0, 120.0, 120.0, -90.0 ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("Node2D/Sprite:rotation_degrees") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0, 0.05, 0.15, 0.8, 1.25 ), +"transitions": PoolRealArray( 1, 1, 1, 1, 1 ), +"update": 0, +"values": [ -45.0, 40.0, 50.0, 50.0, -45.0 ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("SlashSprite:visible") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0, 0.3 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 1, +"values": [ true, false ] +} +tracks/3/type = "value" +tracks/3/path = NodePath("SlashSprite:frame") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/keys = { +"times": PoolRealArray( 0, 0.1, 0.2 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 1, +"values": [ 0, 1, 2 ] +} + +[sub_resource type="Animation" id=16] length = 0.6 loop = true tracks/0/type = "value" @@ -96,8 +153,7 @@ tracks/1/keys = { "values": [ 0, 1, 2, 3, 4, 5 ] } -[sub_resource type="Animation" id=15] -resource_name = "move" +[sub_resource type="Animation" id=17] length = 0.6 loop = true tracks/0/type = "value" @@ -126,6 +182,8 @@ tracks/1/keys = { } [node name="Player" instance=ExtResource( 1 )] +collision_layer = 2 +collision_mask = 5 script = ExtResource( 4 ) [node name="FiniteStateMachine" parent="." index="0"] @@ -133,9 +191,33 @@ script = ExtResource( 5 ) [node name="AnimatedSprite" parent="." index="1"] frames = SubResource( 13 ) -animation = "move" -frame = 1 +animation = "idle" + +[node name="CollisionShape2D" parent="." index="2"] +position = Vector2( 0, 3 ) +shape = SubResource( 14 ) + +[node name="Sword" type="Node2D" parent="." index="3"] + +[node name="Node2D" type="Node2D" parent="Sword" index="0"] +rotation = -1.5708 + +[node name="Sprite" type="Sprite" parent="Sword/Node2D" index="0"] +position = Vector2( 7, 3 ) +rotation = -0.785398 +texture = ExtResource( 6 ) +offset = Vector2( 5, -4 ) + +[node name="SlashSprite" type="Sprite" parent="Sword" index="1"] +visible = false +position = Vector2( 18, 0 ) +texture = ExtResource( 7 ) +hframes = 3 +frame = 2 + +[node name="SwordAnimationPlayer" type="AnimationPlayer" parent="Sword" index="2"] +anims/attack = SubResource( 15 ) -[node name="AnimationPlayer" parent="." index="3"] -anims/idle = SubResource( 14 ) -anims/move = SubResource( 15 ) +[node name="AnimationPlayer" parent="." index="4"] +anims/idle = SubResource( 16 ) +anims/move = SubResource( 17 ) diff --git a/project.godot b/project.godot index 34206e1..23cd8eb 100644 --- a/project.godot +++ b/project.godot @@ -39,6 +39,20 @@ window/size/test_height=720 window/stretch/mode="2d" window/stretch/aspect="keep" +[input] + +ui_attack={ +"deadzone": 0.5, +"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) + ] +} + +[layer_names] + +2d_physics/layer_1="World" +2d_physics/layer_2="Player" +2d_physics/layer_3="Enemy" + [physics] common/enable_pause_aware_picking=true