Skip to content

Commit

Permalink
Attack effect animations bleh
Browse files Browse the repository at this point in the history
  • Loading branch information
outfrost committed Apr 26, 2021
1 parent 17e0c64 commit 3e260be
Show file tree
Hide file tree
Showing 11 changed files with 614 additions and 81 deletions.
631 changes: 565 additions & 66 deletions character/AttackFx_SpriteFrames.tres

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions character/Enemy.gd
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ func hit(other: CollisionObject2D):


func _process(delta:float):
if nearest_player:
DebugLabel.display(self, nearest_player.position)
DebugLabel.display(self, ((nearest_player.position - self.position).normalized() * self.run_speed))
else:
# if nearest_player:
# DebugLabel.display(self, nearest_player.position)
# DebugLabel.display(self, ((nearest_player.position - self.position).normalized() * self.run_speed))
# else:
pass

func try_play_walk_sound():
Expand Down
28 changes: 28 additions & 0 deletions character/PlayerCharacter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var resist_wind: float = 0.20
var basic_attack_dmg: float = 40.0

var walk_sound_timer: float = 0.0
var playing_action: bool = false

func _ready() -> void:
$AnimatedSprite.playing = true
Expand All @@ -49,6 +50,8 @@ func _physics_process(delta: float) -> void:
walk_sound_timer = 0.0
move_and_slide(direction * run_speed)

if playing_action:
return
var angle = direction.angle() if moving else last_movement_dir.angle()
# right
if angle > -0.1875 * TAU && angle < 0.1875 * TAU:
Expand Down Expand Up @@ -94,6 +97,8 @@ func _input(event: InputEvent) -> void:
print_inventory()
elif event.is_action_pressed("attack"):
get_tree().set_input_as_handled()
play_attack_anim(last_movement_dir)

if swing_sounds.size() > 0:
get_node(swing_sounds[randi() % swing_sounds.size()]).play()
var collision = move_and_collide(
Expand All @@ -112,6 +117,29 @@ func hit(other: CollisionObject2D):
if hit_sounds.size() > 0:
get_node(hit_sounds[randi() % hit_sounds.size()]).play()

func play_attack_anim(direction: Vector2):
playing_action = true
var angle = last_movement_dir.angle()
var anim: String
# right
if angle > -0.1875 * TAU && angle < 0.1875 * TAU:
anim = "slash_right"
# left
elif angle < -0.3125 * TAU || angle > 0.3125 * TAU:
anim = "slash_left"
# down
elif angle > 0.0:
anim = "slash_down"
# up
else:
anim = "slash_up"

sprite.play(anim)
$FxSprite.play(anim + "_red")
yield(sprite, "animation_finished")
playing_action = false
$FxSprite.play("idle")

func entered_lootable_range(lootable):
print_debug(lootable)
current_lootable = lootable
Expand Down
8 changes: 7 additions & 1 deletion character/PlayerCharacter.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=19 format=2]
[gd_scene load_steps=20 format=2]

[ext_resource path="res://character/PlayerCharacter.gd" type="Script" id=1]
[ext_resource path="res://character/PlayerCharacter_SpriteFrames.tres" type="SpriteFrames" id=2]
Expand All @@ -17,6 +17,7 @@
[ext_resource path="res://sound/positional/SFX_SwordHit_6.wav" type="AudioStream" id=15]
[ext_resource path="res://sound/positional/SFX_SwordHit_5.wav" type="AudioStream" id=16]
[ext_resource path="res://sound/positional/SFX_SwordHit_1.wav" type="AudioStream" id=17]
[ext_resource path="res://character/AttackFx_SpriteFrames.tres" type="SpriteFrames" id=18]

[sub_resource type="CircleShape2D" id=1]
radius = 16.0
Expand All @@ -37,6 +38,11 @@ frames = ExtResource( 2 )
animation = "idle_down"
offset = Vector2( 0, -16 )

[node name="FxSprite" type="AnimatedSprite" parent="."]
frames = ExtResource( 18 )
animation = "idle"
offset = Vector2( 0, -16 )

[node name="AudioStreamPlayerWalk1" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 7 )
volume_db = -12.0
Expand Down
8 changes: 4 additions & 4 deletions character/PlayerCharacter_SpriteFrames.tres
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,12 @@ animations = [ {
"speed": 12.5
}, {
"frames": [ SubResource( 65 ), SubResource( 66 ), SubResource( 67 ), SubResource( 68 ), SubResource( 69 ), SubResource( 70 ), SubResource( 71 ), SubResource( 72 ), SubResource( 73 ) ],
"loop": true,
"loop": false,
"name": "slash_right",
"speed": 12.5
}, {
"frames": [ SubResource( 56 ), SubResource( 57 ), SubResource( 58 ), SubResource( 59 ), SubResource( 60 ), SubResource( 61 ), SubResource( 62 ), SubResource( 63 ), SubResource( 64 ) ],
"loop": true,
"loop": false,
"name": "slash_left",
"speed": 12.5
}, {
Expand Down Expand Up @@ -351,12 +351,12 @@ animations = [ {
"speed": 12.5
}, {
"frames": [ SubResource( 82 ), SubResource( 83 ), SubResource( 84 ), SubResource( 85 ), SubResource( 86 ), SubResource( 87 ), SubResource( 88 ), SubResource( 89 ), SubResource( 90 ) ],
"loop": true,
"loop": false,
"name": "slash_up",
"speed": 12.5
}, {
"frames": [ SubResource( 74 ), SubResource( 75 ), SubResource( 76 ), SubResource( 77 ), SubResource( 78 ), SubResource( 79 ), SubResource( 80 ), SubResource( 81 ) ],
"loop": true,
"loop": false,
"name": "slash_down",
"speed": 12.5
} ]
Binary file removed character/backwardsattackeffect-export.png
Binary file not shown.
Binary file added character/backwardsattackeffect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

importer="texture"
type="StreamTexture"
path="res://.import/backwardsattackeffect-export.png-fa97fbbe935d3f2cf0ed00f9e7f19086.stex"
path="res://.import/backwardsattackeffect.png-edf727e483ff56be2817e5d0cd3b7a74.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://character/backwardsattackeffect-export.png"
dest_files=[ "res://.import/backwardsattackeffect-export.png-fa97fbbe935d3f2cf0ed00f9e7f19086.stex" ]
source_file="res://character/backwardsattackeffect.png"
dest_files=[ "res://.import/backwardsattackeffect.png-edf727e483ff56be2817e5d0cd3b7a74.stex" ]

[params]

Expand Down
Binary file removed character/sideattackeffects.png
Binary file not shown.
Binary file added character/sideslasheffect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

importer="texture"
type="StreamTexture"
path="res://.import/sideattackeffects.png-1ff700c1a1f799a0b6c9a69ae3d6f91e.stex"
path="res://.import/sideslasheffect.png-dc1954bc128bb992b837fcdea4da8409.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://character/sideattackeffects.png"
dest_files=[ "res://.import/sideattackeffects.png-1ff700c1a1f799a0b6c9a69ae3d6f91e.stex" ]
source_file="res://character/sideslasheffect.png"
dest_files=[ "res://.import/sideslasheffect.png-dc1954bc128bb992b837fcdea4da8409.stex" ]

[params]

Expand Down

0 comments on commit 3e260be

Please sign in to comment.