diff --git a/assets/config/deck_dock.ron b/assets/config/deck_dock.ron new file mode 100644 index 0000000..e42f4d8 --- /dev/null +++ b/assets/config/deck_dock.ron @@ -0,0 +1,8 @@ +( + card_width: 20, + max_dock_width: 100, + max_dock_height: 10, + minimum_card_distance: 16, + dock_translation: Vec3(10.0, -35.0, 0.0), + dock_scale: 0.7, +) \ No newline at end of file diff --git a/assets/mockup/sample_card.png b/assets/mockup/sample_card.png new file mode 100644 index 0000000..f4c080b Binary files /dev/null and b/assets/mockup/sample_card.png differ diff --git a/src/game.rs b/src/game.rs index 80748bf..b61acf6 100644 --- a/src/game.rs +++ b/src/game.rs @@ -3,6 +3,7 @@ pub mod actor; mod card; mod deck; +mod deck_dock; pub mod sprite; pub mod step; @@ -19,6 +20,7 @@ pub(super) fn plugin(app: &mut App) { step::plugin, card::plugin, deck::plugin, + deck_dock::plugin, )); } diff --git a/src/game/actor.rs b/src/game/actor.rs index b8dad04..7edbe53 100644 --- a/src/game/actor.rs +++ b/src/game/actor.rs @@ -1,7 +1,6 @@ pub mod enemy; pub mod facing; pub mod health; -pub mod movement; pub mod player; use bevy::ecs::system::EntityCommand; @@ -28,7 +27,6 @@ pub(super) fn plugin(app: &mut App) { enemy::plugin, facing::plugin, health::plugin, - movement::plugin, player::plugin, )); } diff --git a/src/game/actor/player.rs b/src/game/actor/player.rs index 3093fab..ee485d8 100644 --- a/src/game/actor/player.rs +++ b/src/game/actor/player.rs @@ -2,6 +2,7 @@ use bevy::prelude::*; use crate::game::actor::actor_helper; use crate::game::actor::facing::FaceCursor; +use crate::game::deck_dock::DrawDeck; use crate::util::prelude::*; pub(super) fn plugin(app: &mut App) { @@ -19,5 +20,5 @@ impl Configure for IsPlayer { } pub fn player(entity: EntityWorldMut) { - actor_helper(entity, None).insert((IsPlayer, FaceCursor)); + actor_helper(entity, None).insert((IsPlayer, DrawDeck, FaceCursor)); } diff --git a/src/game/card.rs b/src/game/card.rs index ff6338b..6ad17de 100644 --- a/src/game/card.rs +++ b/src/game/card.rs @@ -1,3 +1,4 @@ +use bevy::asset::embedded_asset; use bevy::ecs::system::SystemId; use bevy::prelude::*; use bevy::utils::HashMap; @@ -6,6 +7,9 @@ use pyri_state::prelude::*; use crate::screen::Screen; pub(super) fn plugin(app: &mut App) { + // TODO: setup correct asset loading for cards + embedded_asset!(app, "cards/sample_card.png"); + app.add_systems( StateFlush, Screen::Playing.on_edge(exit_playing, enter_playing), diff --git a/src/game/cards/sample_card.png b/src/game/cards/sample_card.png new file mode 100644 index 0000000..f4c080b Binary files /dev/null and b/src/game/cards/sample_card.png differ diff --git a/src/game/deck_dock.rs b/src/game/deck_dock.rs new file mode 100644 index 0000000..a565a91 --- /dev/null +++ b/src/game/deck_dock.rs @@ -0,0 +1,235 @@ +use bevy::prelude::*; +use bevy::render::texture::ImageLoaderSettings; +use bevy::render::texture::ImageSampler; +use leafwing_input_manager::common_conditions::action_just_pressed; +use pyri_state::prelude::*; +use serde::Deserialize; +use serde::Serialize; + +use crate::game::deck::Deck; +use crate::screen::playing::PlayingAction; +use crate::screen::Screen; +use crate::util::prelude::*; + +pub(super) fn plugin(app: &mut App) { + app.configure::>(); + app.add_systems( + StateFlush, + Screen::Playing.on_edge(exit_playing, enter_playing), + ); + + app.add_systems( + Update, + Screen::Playing.on_update(( + animate_move_towards, + rotate_dock_left.run_if(action_just_pressed(PlayingAction::RotateDock)), + create_dock.run_if(any_with_component::), + )), + ); +} + +#[derive(Asset, Reflect, Serialize, Deserialize)] +pub struct DeckDockConfig { + pub card_width: usize, + pub max_dock_width: usize, + pub max_dock_height: usize, + pub minimum_card_distance: usize, + pub dock_translation: Vec3, + pub dock_scale: f32, +} + +impl Config for DeckDockConfig { + const PATH: &'static str = "config/deck_dock.ron"; + + const EXTENSION: &'static str = "deck_dock.ron"; + + fn on_load(&mut self, _: &mut World) {} +} + +fn enter_playing() {} + + + +#[derive(Component)] +struct MoveToward { + start: Vec3, + end: Vec3, + duration: Timer, +} + +fn animate_move_towards( + mut commands: Commands, + mut move_towards: Query<(Entity, &mut Transform, &mut MoveToward)>, + time: Res