Skip to content

Commit

Permalink
Move files into separate modules
Browse files Browse the repository at this point in the history
  • Loading branch information
PurityLake committed Jan 9, 2024
1 parent 99daefa commit cf3abe8
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/animation.rs → src/animation/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{collections::HashMap, time::Duration};

use crate::{json::*, GameState};
use crate::data::{json::*, state::GameState};
use bevy::prelude::*;
use serde::Deserialize;

Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/data/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod json;
pub mod state;
File renamed without changes.
4 changes: 2 additions & 2 deletions src/enemy.rs → src/entities/enemy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::{
AnimState, AnimationComponent, AnimationHandles, AnimationList, AnimationListAsset,
EnemyAnimations, ImagesToLoad,
},
player::GameStats,
state::GameState,
data::state::GameState,
entities::player::GameStats,
GameplayStart,
};

Expand Down
2 changes: 2 additions & 0 deletions src/entities/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod enemy;
pub mod player;
16 changes: 2 additions & 14 deletions src/player.rs → src/entities/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ use std::time::Duration;

use bevy::prelude::*;
use bevy_rapier2d::prelude::*;
use serde::de;

use crate::{
animation::{
AnimState, AnimationComponent, AnimationList, AnimationListAsset, ImagesToLoad,
PlayerAnimation,
},
state::GameState,
data::state::GameState,
GameplayStart,
};

Expand Down Expand Up @@ -78,23 +77,13 @@ pub struct PlayerPlugin;
#[derive(Resource)]
pub struct PlayerPhysicsAttached(bool);

#[derive(Resource)]
#[derive(Resource, Default)]
pub struct GameStats {
pub villagers_saved: i32,
pub villagers_lost: i32,
pub entites_spawned: i32,
}

impl Default for GameStats {
fn default() -> Self {
Self {
villagers_saved: 0,
villagers_lost: 0,
entites_spawned: 0,
}
}
}

impl Plugin for PlayerPlugin {
fn build(&self, app: &mut App) {
app.init_resource::<PlayerLoaded>()
Expand Down Expand Up @@ -168,7 +157,6 @@ fn spawn_text(
}

fn update_text(
score: Res<GameStats>,
asset_server: Res<AssetServer>,
player_data: Res<PlayerData>,
mut query: Query<(&mut Text, &EntitiesText)>,
Expand Down
13 changes: 6 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#![allow(clippy::too_many_arguments, clippy::type_complexity)]

mod animation;
mod enemy;
mod json;
mod player;
mod state;
mod data;
mod entities;

use crate::entities::enemy;
use animation::{AnimationList, AnimationLoadPlugin};
use bevy::{asset::AssetMetaCheck, prelude::*, window::WindowTheme};
use bevy_rapier2d::prelude::*;
use enemy::EnemySpawnPlugin;
use player::PlayerPlugin;
use state::GameState;
use data::state::GameState;
use entities::enemy::EnemySpawnPlugin;
use entities::player::PlayerPlugin;

#[derive(Resource)]
pub struct GameplayStart {
Expand Down

0 comments on commit cf3abe8

Please sign in to comment.