Skip to content

Commit 4a393ee

Browse files
committed
feat: Add fulgur avis spell (using bevy_trickfilm)
1 parent b2ba1ab commit 4a393ee

13 files changed

+343
-5
lines changed

CREDITS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ https://stealthix.itch.io/animated-fires
2525
### Lightning
2626

2727
https://sanctumpixel.itch.io/lightning-lines-pixel-art-effect
28+
https://pimen.itch.io/thunder-spell-effect-01
29+
https://pimen.itch.io/thunder-spell-effect-02
2830

2931
### Statue Beam Effect and Statue Unlock Effect
3032

@@ -34,6 +36,10 @@ https://ansimuz.itch.io/warped-shooting-fx
3436

3537
https://creativekind.itch.io/necromancer-free
3638

39+
### Air spells (aer tracto, aer pello)
40+
41+
https://pimen.itch.io/wind-spell-effect
42+
3743
---
3844

3945
## UI

Cargo.lock

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ bevy_asset_loader = { version = "0.18.0", features = ["2d"] }
2222
bevy_ecs_ldtk = { git = "https://github.com/PraxTube/bevy_ecs_ldtk.git", branch = "feat/bevy-0.12", features = ["atlas"]}
2323
bevy_rapier2d = "0.23.0"
2424
bevy_kira_audio = "0.18.0"
25+
bevy_trickfilm = { version = "0.5.0"}

assets/lightning_bird.png

11.3 KB
Loading

assets/lightning_bird.trickfilm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
(
3+
name: "spawn",
4+
keyframes: KeyframesRange((start: 0, end: 8)),
5+
duration: 0.8,
6+
),
7+
(
8+
name: "fly",
9+
keyframes: KeyframesRange((start: 8, end: 16)),
10+
duration: 0.8,
11+
),
12+
]

assets/lightning_strike.png

27.9 KB
Loading

assets/lightning_strike.trickfilm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
(
3+
name: "main",
4+
keyframes: KeyframesRange((start: 0, end: 13)),
5+
duration: 0.6,
6+
),
7+
]

assets/sounds/lightning_bird_flap.ogg

11.6 KB
Binary file not shown.

src/assets.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use bevy::prelude::*;
22
use bevy_asset_loader::prelude::*;
33
use bevy_ecs_ldtk::prelude::LdtkProject;
44
use bevy_kira_audio::AudioSource;
5+
use bevy_trickfilm::prelude::*;
56

67
#[derive(AssetCollection, Resource)]
78
pub struct GameAssets {
@@ -21,6 +22,23 @@ pub struct GameAssets {
2122
#[asset(path = "lightning.png")]
2223
pub lightning: Handle<TextureAtlas>,
2324

25+
#[asset(texture_atlas(tile_size_x = 66.0, tile_size_y = 66.0, columns = 13, rows = 1))]
26+
#[asset(path = "lightning_strike.png")]
27+
pub lightning_strike: Handle<TextureAtlas>,
28+
#[asset(paths("lightning_strike.trickfilm#main"), collection(typed))]
29+
pub lightning_strike_animations: Vec<Handle<AnimationClip2D>>,
30+
31+
#[asset(texture_atlas(tile_size_x = 50.0, tile_size_y = 50.0, columns = 16, rows = 1))]
32+
#[asset(path = "lightning_bird.png")]
33+
pub lightning_bird: Handle<TextureAtlas>,
34+
#[asset(
35+
paths("lightning_bird.trickfilm#spawn", "lightning_bird.trickfilm#fly"),
36+
collection(typed)
37+
)]
38+
pub lightning_bird_animations: Vec<Handle<AnimationClip2D>>,
39+
#[asset(path = "sounds/lightning_bird_flap.ogg")]
40+
pub lightning_bird_flap_sound: Handle<AudioSource>,
41+
2442
#[asset(texture_atlas(tile_size_x = 48.0, tile_size_y = 48.0, columns = 7, rows = 1))]
2543
#[asset(path = "aer_tracto.png")]
2644
pub aer_tracto: Handle<TextureAtlas>,

src/enemy/slime/collision.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::spell::aer_tracto::AerTracto;
77
use crate::spell::fireball::Fireball;
88
use crate::spell::icicle::Icicle;
99
use crate::spell::lightning::Lightning;
10+
use crate::spell::lightning_bird::LightningStrike;
1011
use crate::ui::health::Health;
1112

1213
fn player_collisions(
@@ -119,6 +120,7 @@ fn fireball_collisions(
119120
fn lightning_collisions(
120121
mut q_enemies: Query<(&mut SlimeEnemy, &mut Health, &mut Velocity)>,
121122
q_lightnings: Query<&Lightning>,
123+
q_lightning_strikes: Query<&LightningStrike>,
122124
q_colliders: Query<&Parent, (With<Collider>, Without<Enemy>)>,
123125
mut ev_collision_events: EventReader<CollisionEvent>,
124126
) {
@@ -150,16 +152,20 @@ fn lightning_collisions(
150152
continue;
151153
}
152154

153-
let lightning = if let Ok(l) = q_lightnings.get(source_parent) {
154-
l
155+
let damage = if let Ok(l) = q_lightnings.get(source_parent) {
156+
l.damage
155157
} else if let Ok(l) = q_lightnings.get(target_parent) {
156-
l
158+
l.damage
159+
} else if let Ok(l) = q_lightning_strikes.get(source_parent) {
160+
l.damage
161+
} else if let Ok(l) = q_lightning_strikes.get(target_parent) {
162+
l.damage
157163
} else {
158164
continue;
159165
};
160166

167+
slime_health.health -= damage;
161168
velocity.linvel = Vec2::ZERO;
162-
slime_health.health -= lightning.damage;
163169
slime.state = SlimeState::Staggering;
164170
}
165171
}

src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use bevy_rapier2d::prelude::*;
2020
use bevy_screen_diagnostics::{
2121
ScreenDiagnosticsPlugin, ScreenEntityDiagnosticsPlugin, ScreenFrameDiagnosticsPlugin,
2222
};
23+
use bevy_trickfilm::Animation2DPlugin;
2324

2425
const BACKGROUND_COLOR: Color = Color::rgb(0.95, 0.90, 0.75);
2526

@@ -58,7 +59,8 @@ fn main() {
5859
ScreenFrameDiagnosticsPlugin,
5960
ScreenEntityDiagnosticsPlugin,
6061
RapierPhysicsPlugin::<NoUserData>::default(),
61-
// RapierDebugRenderPlugin::default(),
62+
RapierDebugRenderPlugin::default(),
63+
Animation2DPlugin,
6264
))
6365
.insert_resource(Msaa::Off)
6466
.add_state::<GameState>()

0 commit comments

Comments
 (0)