Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions assets/data/characters.ron
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
collider_density: 1.0,
character_type: Captain,
projectile_type: Blast(Ally),
projectile_range: 100.0,
projectile_despawn_time: 1.00,
projectile_velocity: (0.0, 500.0),
projectile_offset_position: (0.0, 40.0),
Expand All @@ -31,6 +32,7 @@
collider_density: 1.5,
character_type: Juggernaut,
projectile_type: Bullet(Ally),
projectile_range: 80.0,
projectile_despawn_time: 0.7,
projectile_velocity: (0.0, 400.0),
projectile_offset_position: (0.0, 45.0),
Expand Down
9 changes: 9 additions & 0 deletions assets/data/effects.ron
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
frame_duration: 0.1,
),
),
AllyBeamDespawn: (
effect_type: AllyBeamDespawn,
effect_behaviors_data: [FadeOutAndDespawnAfterAnimation],
z_level: 9.0,
animation: (
direction: Forward,
frame_duration: 0.12,
),
),
MobExplosion: (
effect_type: MobExplosion,
effect_behaviors_data: [FadeOutAndDespawnAfterAnimation],
Expand Down
35 changes: 23 additions & 12 deletions assets/data/projectiles.ron
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
frame_duration: 1.0
),
collider: (
dimensions: (2.0, 2.0),
dimensions: (4.0, 4.0),
position: (0.0, 0.0),
rotation: 0.0,
),
Expand All @@ -19,14 +19,13 @@
projectile_type: Blast(Neutral),
spawnable_behaviors: [],
projectile_behaviors: [ExplodeOnIntersection, DealDamageOnIntersection],
collider_dimensions: (1.5, 1.5),
z_level: 20.0,
animation: (
direction: None,
frame_duration: 1.0
),
collider: (
dimensions: (2.0, 2.0),
dimensions: (4.0, 4.0),
position: (0.0, 0.0),
rotation: 0.0,
),
Expand All @@ -36,14 +35,13 @@
projectile_type: Blast(Ally),
spawnable_behaviors: [],
projectile_behaviors: [ExplodeOnIntersection, DealDamageOnIntersection],
collider_dimensions: (1.5, 1.5),
z_level: 19.0,
animation: (
direction: None,
frame_duration: 1.0
),
collider: (
dimensions: (2.0, 2.0),
dimensions: (4.0, 4.0),
position: (0.0, 0.0),
rotation: 0.0,
),
Expand All @@ -53,14 +51,13 @@
projectile_type: Bullet(Enemy),
spawnable_behaviors: [],
projectile_behaviors: [DealDamageOnContact, ExplodeOnContact],
collider_dimensions: (1.5, 1.5),
z_level: 20.0,
animation: (
direction: None,
frame_duration: 1.0
),
collider: (
dimensions: (2.0, 2.0),
dimensions: (4.0, 4.0),
position: (0.0, 0.0),
rotation: 0.0,
),
Expand All @@ -70,14 +67,13 @@
projectile_type: Bullet(Neutral),
spawnable_behaviors: [],
projectile_behaviors: [DealDamageOnContact, ExplodeOnContact],
collider_dimensions: (1.5, 1.5),
z_level: 20.0,
animation: (
direction: None,
frame_duration: 1.0
),
collider: (
dimensions: (2.0, 2.0),
dimensions: (4.0, 4.0),
position: (0.0, 0.0),
rotation: 0.0,
),
Expand All @@ -87,17 +83,32 @@
projectile_type: Bullet(Ally),
spawnable_behaviors: [],
projectile_behaviors: [DealDamageOnContact, ExplodeOnContact],
collider_dimensions: (1.5, 1.5),
z_level: 19.0,
animation: (
direction: None,
frame_duration: 1.0
),
collider: (
dimensions: (2.0, 2.0),
dimensions: (4.0, 4.0),
position: (0.0, 0.0),
rotation: 0.0,
),
is_solid: true,
)
),
Beam(Ally): (
projectile_type: Beam(Ally),
spawnable_behaviors: [],
projectile_behaviors: [DealDamageOnIntersection, FollowSource, OscillateCollider(0.2)],
z_level: 19.0,
animation: (
direction: None,
frame_duration: 1.0
),
collider: (
dimensions: (6.0, 1.0),
position: (0.0, 0.0),
rotation: 0.0,
),
is_solid: false,
),
}
7 changes: 7 additions & 0 deletions assets/effect_assets.assets.ron
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,11 @@
columns: 6,
rows: 1,
),
"ally_beam_despawn": TextureAtlas (
path: "texture/ally_beam_despawn_spritesheet.png",
tile_size_x: 9.,
tile_size_y: 1.,
columns: 3,
rows: 1,
),
})
14 changes: 14 additions & 0 deletions assets/projectile_assets.assets.ron
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,18 @@
columns: 1,
rows: 1,
),
"ally_beam": TextureAtlas (
path: "texture/ally_beam.png",
tile_size_x: 5.,
tile_size_y: 1.,
columns: 1,
rows: 1,
),
"enemy_beam": TextureAtlas(
path: "texture/enemy_beam.png",
tile_size_x: 5.,
tile_size_y: 1.,
columns: 1,
rows: 1,
),
})
2 changes: 2 additions & 0 deletions crates/thetawave_interface/src/character.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub struct Character {
pub character_type: CharacterType,
/// Projectile type
pub projectile_type: ProjectileType,
/// Used for some projectiles (like the beam) to determine length
pub projectile_range: f32,
/// Time until fired projectile despawns
pub projectile_despawn_time: f32,
/// Velocity of fired projectile
Expand Down
3 changes: 3 additions & 0 deletions crates/thetawave_interface/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ pub struct PlayerComponent {
pub collider_density: f32,
/// Type of projectile fired
pub projectile_type: ProjectileType,
/// Used for some projectiles (like the beam) to determine length
pub projectile_range: f32,
/// Time until fired projectile despawns
pub projectile_despawn_time: f32,
/// Velocity of fired projectile
Expand Down Expand Up @@ -113,6 +115,7 @@ impl From<&Character> for PlayerComponent {
collider_dimensions: character.collider_dimensions,
collider_density: character.collider_density,
projectile_type: character.projectile_type.clone(),
projectile_range: character.projectile_range,
projectile_despawn_time: character.projectile_despawn_time,
projectile_velocity: character.projectile_velocity,
projectile_offset_position: character.projectile_offset_position,
Expand Down
13 changes: 13 additions & 0 deletions crates/thetawave_interface/src/spawnable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ impl Default for SpawnableType {
pub enum ProjectileType {
Blast(Faction),
Bullet(Faction),
Beam(Faction),
}

impl ProjectileType {
pub fn get_faction(&self) -> Faction {
match self {
ProjectileType::Blast(faction) => faction,
ProjectileType::Bullet(faction) => faction,
ProjectileType::Beam(faction) => faction,
}
.clone()
}
}

/// Factions
Expand Down Expand Up @@ -179,6 +191,7 @@ pub enum EffectType {
EnemyBulletDespawn,
AllyBulletExplosion,
Text(TextEffectType),
AllyBeamDespawn,
}

/// Subtype of effect for text effects
Expand Down
2 changes: 1 addition & 1 deletion crates/thetawave_storage/src/core.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::info;
use bevy::log::info;
use directories::ProjectDirs;
use rusqlite;
use rusqlite::Connection;
Expand Down
2 changes: 1 addition & 1 deletion crates/thetawave_storage/src/user_stats.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::core::{get_db, OurDBError, ENEMY_KILL_HISTORY_TABLE_NAME, USERSTAT};
use bevy::prelude::{error, info};
use bevy::log::{error, info};
use rusqlite::{params, Result};
use thetawave_interface::spawnable::EnemyMobType;

Expand Down
15 changes: 13 additions & 2 deletions src/animation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ impl Plugin for AnimationPlugin {
.run_if(in_state(states::AppStates::Game))
.run_if(in_state(states::GameStates::Playing)),
);

app.add_event::<AnimationCompleteEvent>();
}
}

Expand Down Expand Up @@ -63,17 +65,22 @@ pub struct AnimationComponent {
pub direction: AnimationDirection,
}

#[derive(Event, PartialEq)]
pub struct AnimationCompleteEvent(pub Entity);

/// Handles animation of sprites
pub fn animate_sprite_system(
time: Res<Time>,
texture_atlases: Res<Assets<TextureAtlas>>,
mut query: Query<(
Entity,
&mut AnimationComponent,
&mut TextureAtlasSprite,
&Handle<TextureAtlas>,
)>,
mut animation_complete_event_writer: EventWriter<AnimationCompleteEvent>,
) {
for (mut animation, mut sprite, texture_atlas_handle) in query.iter_mut() {
for (entity, mut animation, mut sprite, texture_atlas_handle) in query.iter_mut() {
// tick the animation timer
animation.timer.tick(time.delta());

Expand All @@ -86,7 +93,11 @@ pub fn animate_sprite_system(
match &animation.direction {
AnimationDirection::None => {}
AnimationDirection::Forward => {
sprite.index = (sprite.index + 1) % texture_atlas.textures.len()
let new_idx = (sprite.index + 1) % texture_atlas.textures.len();
if new_idx == 0 {
animation_complete_event_writer.send(AnimationCompleteEvent(entity))
}
sprite.index = new_idx;
}
AnimationDirection::PingPong(direction) => match direction {
PingPongDirection::Forward => {
Expand Down
4 changes: 4 additions & 0 deletions src/assets/effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub struct EffectAssets {
pub ally_bullet_despawn: Handle<TextureAtlas>,
#[asset(key = "enemy_bullet_despawn")]
pub enemy_bullet_despawn: Handle<TextureAtlas>,
#[asset(key = "ally_beam_despawn")]
pub ally_beam_despawn: Handle<TextureAtlas>,
#[asset(key = "ally_bullet_explosion")]
pub ally_bullet_explosion: Handle<TextureAtlas>,
#[asset(key = "enemy_bullet_explosion")]
Expand Down Expand Up @@ -44,6 +46,7 @@ impl EffectAssets {
EffectType::AllyBulletExplosion => Some(self.ally_bullet_explosion.clone()),
EffectType::EnemyBulletExplosion => Some(self.enemy_bullet_explosion.clone()),
EffectType::Text(_) => None,
EffectType::AllyBeamDespawn => Some(self.ally_beam_despawn.clone()),
}
}

Expand All @@ -61,6 +64,7 @@ impl EffectAssets {
EffectType::AllyBulletDespawn => Color::rgb(5.0, 5.0, 5.0),
EffectType::EnemyBulletDespawn => Color::rgb(5.0, 5.0, 5.0),
EffectType::Text(_) => Color::rgb(0.0, 0.0, 0.0),
EffectType::AllyBeamDespawn => Color::rgb(2.0, 2.0, 2.0),
}
}
}
10 changes: 10 additions & 0 deletions src/assets/projectile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ pub struct ProjectileAssets {
pub ally_bullet: Handle<TextureAtlas>,
#[asset(key = "enemy_bullet")]
pub enemy_bullet: Handle<TextureAtlas>,
#[asset(key = "ally_beam")]
pub ally_beam: Handle<TextureAtlas>,
#[asset(key = "enemy_beam")]
pub enemy_beam: Handle<TextureAtlas>,
}

impl ProjectileAssets {
Expand All @@ -29,12 +33,18 @@ impl ProjectileAssets {
Faction::Enemy => self.enemy_bullet.clone(),
Faction::Neutral => todo!(),
},
ProjectileType::Beam(faction) => match faction {
Faction::Ally => self.ally_beam.clone(),
Faction::Enemy => self.enemy_beam.clone(),
Faction::Neutral => todo!(),
},
}
}
pub fn get_color(&self, projectile_type: &ProjectileType) -> Color {
match projectile_type {
ProjectileType::Blast(_) => Color::rgb(3.0, 3.0, 3.0),
ProjectileType::Bullet(_) => Color::rgb(2.0, 2.0, 2.0),
ProjectileType::Beam(_) => Color::rgb(3.0, 3.0, 3.0),
}
}
}
Loading