diff --git a/assets/cX_nX_pX_sX.png b/assets/cX_nX_pX_sX.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cX_nX_pX_sX.png differ diff --git a/assets/cg_n1_pop_sd.png b/assets/cg_n1_pop_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n1_pop_sd.png differ diff --git a/assets/cg_n1_pop_so.png b/assets/cg_n1_pop_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n1_pop_so.png differ diff --git a/assets/cg_n1_pop_ss.png b/assets/cg_n1_pop_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n1_pop_ss.png differ diff --git a/assets/cg_n1_pso_sd.png b/assets/cg_n1_pso_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n1_pso_sd.png differ diff --git a/assets/cg_n1_pso_so.png b/assets/cg_n1_pso_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n1_pso_so.png differ diff --git a/assets/cg_n1_pso_ss.png b/assets/cg_n1_pso_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n1_pso_ss.png differ diff --git a/assets/cg_n1_pst_sd.png b/assets/cg_n1_pst_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n1_pst_sd.png differ diff --git a/assets/cg_n1_pst_so.png b/assets/cg_n1_pst_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n1_pst_so.png differ diff --git a/assets/cg_n1_pst_ss.png b/assets/cg_n1_pst_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n1_pst_ss.png differ diff --git a/assets/cg_n2_pop_sd.png b/assets/cg_n2_pop_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n2_pop_sd.png differ diff --git a/assets/cg_n2_pop_so.png b/assets/cg_n2_pop_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n2_pop_so.png differ diff --git a/assets/cg_n2_pop_ss.png b/assets/cg_n2_pop_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n2_pop_ss.png differ diff --git a/assets/cg_n2_pso_sd.png b/assets/cg_n2_pso_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n2_pso_sd.png differ diff --git a/assets/cg_n2_pso_so.png b/assets/cg_n2_pso_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n2_pso_so.png differ diff --git a/assets/cg_n2_pso_ss.png b/assets/cg_n2_pso_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n2_pso_ss.png differ diff --git a/assets/cg_n2_pst_sd.png b/assets/cg_n2_pst_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n2_pst_sd.png differ diff --git a/assets/cg_n2_pst_so.png b/assets/cg_n2_pst_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n2_pst_so.png differ diff --git a/assets/cg_n2_pst_ss.png b/assets/cg_n2_pst_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n2_pst_ss.png differ diff --git a/assets/cg_n3_pop_sd.png b/assets/cg_n3_pop_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n3_pop_sd.png differ diff --git a/assets/cg_n3_pop_so.png b/assets/cg_n3_pop_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n3_pop_so.png differ diff --git a/assets/cg_n3_pop_ss.png b/assets/cg_n3_pop_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n3_pop_ss.png differ diff --git a/assets/cg_n3_pso_sd.png b/assets/cg_n3_pso_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n3_pso_sd.png differ diff --git a/assets/cg_n3_pso_so.png b/assets/cg_n3_pso_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n3_pso_so.png differ diff --git a/assets/cg_n3_pso_ss.png b/assets/cg_n3_pso_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n3_pso_ss.png differ diff --git a/assets/cg_n3_pst_sd.png b/assets/cg_n3_pst_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n3_pst_sd.png differ diff --git a/assets/cg_n3_pst_so.png b/assets/cg_n3_pst_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n3_pst_so.png differ diff --git a/assets/cg_n3_pst_ss.png b/assets/cg_n3_pst_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cg_n3_pst_ss.png differ diff --git a/assets/cp_n1_pop_sd.png b/assets/cp_n1_pop_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n1_pop_sd.png differ diff --git a/assets/cp_n1_pop_so.png b/assets/cp_n1_pop_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n1_pop_so.png differ diff --git a/assets/cp_n1_pop_ss.png b/assets/cp_n1_pop_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n1_pop_ss.png differ diff --git a/assets/cp_n1_pso_sd.png b/assets/cp_n1_pso_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n1_pso_sd.png differ diff --git a/assets/cp_n1_pso_so.png b/assets/cp_n1_pso_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n1_pso_so.png differ diff --git a/assets/cp_n1_pso_ss.png b/assets/cp_n1_pso_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n1_pso_ss.png differ diff --git a/assets/cp_n1_pst_sd.png b/assets/cp_n1_pst_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n1_pst_sd.png differ diff --git a/assets/cp_n1_pst_so.png b/assets/cp_n1_pst_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n1_pst_so.png differ diff --git a/assets/cp_n1_pst_ss.png b/assets/cp_n1_pst_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n1_pst_ss.png differ diff --git a/assets/cp_n2_pop_sd.png b/assets/cp_n2_pop_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n2_pop_sd.png differ diff --git a/assets/cp_n2_pop_so.png b/assets/cp_n2_pop_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n2_pop_so.png differ diff --git a/assets/cp_n2_pop_ss.png b/assets/cp_n2_pop_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n2_pop_ss.png differ diff --git a/assets/cp_n2_pso_sd.png b/assets/cp_n2_pso_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n2_pso_sd.png differ diff --git a/assets/cp_n2_pso_so.png b/assets/cp_n2_pso_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n2_pso_so.png differ diff --git a/assets/cp_n2_pso_ss.png b/assets/cp_n2_pso_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n2_pso_ss.png differ diff --git a/assets/cp_n2_pst_sd.png b/assets/cp_n2_pst_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n2_pst_sd.png differ diff --git a/assets/cp_n2_pst_so.png b/assets/cp_n2_pst_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n2_pst_so.png differ diff --git a/assets/cp_n2_pst_ss.png b/assets/cp_n2_pst_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n2_pst_ss.png differ diff --git a/assets/cp_n3_pop_sd.png b/assets/cp_n3_pop_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n3_pop_sd.png differ diff --git a/assets/cp_n3_pop_so.png b/assets/cp_n3_pop_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n3_pop_so.png differ diff --git a/assets/cp_n3_pop_ss.png b/assets/cp_n3_pop_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n3_pop_ss.png differ diff --git a/assets/cp_n3_pso_sd.png b/assets/cp_n3_pso_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n3_pso_sd.png differ diff --git a/assets/cp_n3_pso_so.png b/assets/cp_n3_pso_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n3_pso_so.png differ diff --git a/assets/cp_n3_pso_ss.png b/assets/cp_n3_pso_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n3_pso_ss.png differ diff --git a/assets/cp_n3_pst_sd.png b/assets/cp_n3_pst_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n3_pst_sd.png differ diff --git a/assets/cp_n3_pst_so.png b/assets/cp_n3_pst_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n3_pst_so.png differ diff --git a/assets/cp_n3_pst_ss.png b/assets/cp_n3_pst_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cp_n3_pst_ss.png differ diff --git a/assets/cr_n1_pop_sd.png b/assets/cr_n1_pop_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n1_pop_sd.png differ diff --git a/assets/cr_n1_pop_so.png b/assets/cr_n1_pop_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n1_pop_so.png differ diff --git a/assets/cr_n1_pop_ss.png b/assets/cr_n1_pop_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n1_pop_ss.png differ diff --git a/assets/cr_n1_pso_sd.png b/assets/cr_n1_pso_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n1_pso_sd.png differ diff --git a/assets/cr_n1_pso_so.png b/assets/cr_n1_pso_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n1_pso_so.png differ diff --git a/assets/cr_n1_pso_ss.png b/assets/cr_n1_pso_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n1_pso_ss.png differ diff --git a/assets/cr_n1_pst_sd.png b/assets/cr_n1_pst_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n1_pst_sd.png differ diff --git a/assets/cr_n1_pst_so.png b/assets/cr_n1_pst_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n1_pst_so.png differ diff --git a/assets/cr_n1_pst_ss.png b/assets/cr_n1_pst_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n1_pst_ss.png differ diff --git a/assets/cr_n2_pop_sd.png b/assets/cr_n2_pop_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n2_pop_sd.png differ diff --git a/assets/cr_n2_pop_so.png b/assets/cr_n2_pop_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n2_pop_so.png differ diff --git a/assets/cr_n2_pop_ss.png b/assets/cr_n2_pop_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n2_pop_ss.png differ diff --git a/assets/cr_n2_pso_sd.png b/assets/cr_n2_pso_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n2_pso_sd.png differ diff --git a/assets/cr_n2_pso_so.png b/assets/cr_n2_pso_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n2_pso_so.png differ diff --git a/assets/cr_n2_pso_ss.png b/assets/cr_n2_pso_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n2_pso_ss.png differ diff --git a/assets/cr_n2_pst_sd.png b/assets/cr_n2_pst_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n2_pst_sd.png differ diff --git a/assets/cr_n2_pst_so.png b/assets/cr_n2_pst_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n2_pst_so.png differ diff --git a/assets/cr_n2_pst_ss.png b/assets/cr_n2_pst_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n2_pst_ss.png differ diff --git a/assets/cr_n3_pop_sd.png b/assets/cr_n3_pop_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n3_pop_sd.png differ diff --git a/assets/cr_n3_pop_so.png b/assets/cr_n3_pop_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n3_pop_so.png differ diff --git a/assets/cr_n3_pop_ss.png b/assets/cr_n3_pop_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n3_pop_ss.png differ diff --git a/assets/cr_n3_pso_sd.png b/assets/cr_n3_pso_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n3_pso_sd.png differ diff --git a/assets/cr_n3_pso_so.png b/assets/cr_n3_pso_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n3_pso_so.png differ diff --git a/assets/cr_n3_pso_ss.png b/assets/cr_n3_pso_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n3_pso_ss.png differ diff --git a/assets/cr_n3_pst_sd.png b/assets/cr_n3_pst_sd.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n3_pst_sd.png differ diff --git a/assets/cr_n3_pst_so.png b/assets/cr_n3_pst_so.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n3_pst_so.png differ diff --git a/assets/cr_n3_pst_ss.png b/assets/cr_n3_pst_ss.png new file mode 100644 index 0000000..f9706d7 Binary files /dev/null and b/assets/cr_n3_pst_ss.png differ diff --git a/assets/red_oval_open_one.png b/assets/red_oval_open_one.png deleted file mode 100644 index 9a7b387..0000000 Binary files a/assets/red_oval_open_one.png and /dev/null differ diff --git a/src/boot.rs b/src/boot.rs new file mode 100644 index 0000000..5f8cb2c --- /dev/null +++ b/src/boot.rs @@ -0,0 +1,34 @@ +use crate::{deck::*, *}; +use bevy::{prelude::*, utils::HashMap}; + +/// boot systems kick off the game +pub struct BootPlugin; + +impl Plugin for BootPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Startup, (boot::load, boot::start_setup).chain()); + } +} + +/// loads assets for the game +pub(crate) fn load(mut commands: Commands, server: Res) { + let cards: HashMap = Deck::iter_cards() + .map(|card| { + let sprite = Sprite { + image: server.load(card.sprite()), + ..default() + }; + + (card, sprite) + }) + .collect(); + + let test_deck = Deck { cards }; + + commands.insert_resource(test_deck); +} + +/// Finish boot state by starting setup +pub(crate) fn start_setup(mut game_state: ResMut>) { + game_state.set(GameState::Setup); +} diff --git a/src/debug.rs b/src/debug.rs new file mode 100644 index 0000000..2353400 --- /dev/null +++ b/src/debug.rs @@ -0,0 +1,10 @@ +use bevy::prelude::*; + +/// Debugging systems +pub struct DebugPlugin; + +impl Plugin for DebugPlugin { + fn build(&self, app: &mut App) { + // Nothing yet! + } +} diff --git a/src/deck.rs b/src/deck.rs new file mode 100644 index 0000000..7739f1f --- /dev/null +++ b/src/deck.rs @@ -0,0 +1,118 @@ +use bevy::{prelude::*, utils::HashMap}; + +/// Deck and Cards +pub struct DeckPlugin; + +impl Plugin for DeckPlugin { + fn build(&self, app: &mut App) { + // Nothing yet! + } +} + +/// We expect 81 cards total +#[derive(Resource)] +pub(crate) struct Deck { + pub cards: HashMap, +} + +impl Deck { + pub(crate) fn iter_cards() -> impl Iterator { + let mut v = Vec::new(); + + [ItemColor::Red, ItemColor::Green, ItemColor::Purple] + .iter() + .for_each(|&color| { + [ItemShape::Oval, ItemShape::Diamond, ItemShape::Squiggle] + .iter() + .for_each(|&shape| { + [ItemPattern::Open, ItemPattern::Solid, ItemPattern::Striped] + .iter() + .for_each(|&pattern| { + [ItemNumber::One, ItemNumber::Two, ItemNumber::Three] + .iter() + .for_each(|&number| { + v.push(Card { + color, + shape, + pattern, + number, + }) + }); + }); + }); + }); + + v.into_iter() + } +} + +/// A card describes abstractly the contents of a card +/// including color of items, number of items, pattern, and shape +#[derive(PartialEq, Eq, Hash, Clone, Copy, Component, Debug)] +pub(crate) struct Card { + pub color: ItemColor, + pub number: ItemNumber, + pub pattern: ItemPattern, + pub shape: ItemShape, +} + +impl Card { + pub(crate) fn sprite(&self) -> String { + let col = match self.color { + ItemColor::Red => "cr", + ItemColor::Green => "cg", + ItemColor::Purple => "cp", + }; + let num = match self.number { + ItemNumber::One => "n1", + ItemNumber::Two => "n2", + ItemNumber::Three => "n3", + }; + let pat = match self.pattern { + ItemPattern::Solid => "pso", + ItemPattern::Striped => "pst", + ItemPattern::Open => "pop", + }; + let shape = match self.shape { + ItemShape::Oval => "so", + ItemShape::Diamond => "sd", + ItemShape::Squiggle => "ss", + }; + format!("{}_{}_{}_{}.png", col, num, pat, shape) + } +} + +/// Item colors for the card may be red, green or purple +/// All items must be the same color +#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] +pub(crate) enum ItemColor { + Red, + Green, + Purple, +} + +/// A card may have 1 to 3 items +#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] +pub(crate) enum ItemNumber { + One, + Two, + Three, +} + +/// Each item can be solid, striped, or open +/// a card has all of it's item as one pattern +#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] +pub(crate) enum ItemPattern { + Solid, + Striped, + Open, +} + +/// Each item can be an oval, diamond, or squiggle +/// All items on a card are one shape +#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] +pub(crate) enum ItemShape { + Oval, + Diamond, + Squiggle, +} diff --git a/src/main.rs b/src/main.rs index 005b63c..86a3451 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,116 +1,29 @@ -use bevy::{prelude::*, utils::HashMap}; +mod boot; +mod debug; +mod deck; +mod play; +mod setup; + +use bevy::prelude::*; fn main() { App::new() .add_plugins(DefaultPlugins) + .add_plugins(( + deck::DeckPlugin, + debug::DebugPlugin, + boot::BootPlugin, + setup::SetupPlugin, + play::PlayPlugin, + )) .init_state::() - .add_systems(Startup, (load, start_setup).chain()) - .add_systems( - OnEnter(GameState::Setup), - (setup_cards, setup_camera, start_play).chain(), - ) .run(); } #[derive(States, Default, Debug, Clone, PartialEq, Eq, Hash)] -enum GameState { +pub(crate) enum GameState { #[default] Boot, Setup, Play, } - -fn load(mut commands: Commands, server: Res) { - let sprite = Sprite { - image: server.load("red_oval_open_one.png"), - ..default() - }; - - let card = Card { - color: ItemColor::Red, - shape: ItemShape::Oval, - pattern: ItemPattern::Open, - number: ItemNumber::One, - }; - - let mut cards = HashMap::new(); - cards.insert(card, sprite); - - let test_deck = Deck { cards }; - - commands.insert_resource(test_deck); -} - -fn setup_camera(mut commands: Commands) { - commands.spawn(( - Camera2d, - Camera { - hdr: true, - ..default() - }, - )); -} - -fn setup_cards(mut commands: Commands, deck: Res) { - let this = deck - .cards - .get(&Card { - color: ItemColor::Red, - shape: ItemShape::Oval, - pattern: ItemPattern::Open, - number: ItemNumber::One, - }) - .unwrap() - .clone(); - commands.spawn(this); -} - -fn start_play(mut game_state: ResMut>) { - game_state.set(GameState::Play); -} - -fn start_setup(mut game_state: ResMut>) { - game_state.set(GameState::Setup); -} - -// We expect 81 cards total -#[derive(Resource)] -struct Deck { - cards: HashMap, -} - -#[derive(PartialEq, Eq, Hash, Clone, Copy)] -struct Card { - color: ItemColor, - number: ItemNumber, - pattern: ItemPattern, - shape: ItemShape, -} - -#[derive(PartialEq, Eq, Hash, Clone, Copy)] -enum ItemColor { - Red, - Green, - Purple, -} - -#[derive(PartialEq, Eq, Hash, Clone, Copy)] -enum ItemNumber { - One, - Two, - Three, -} - -#[derive(PartialEq, Eq, Hash, Clone, Copy)] -enum ItemPattern { - Solid, - Striped, - Open, -} - -#[derive(PartialEq, Eq, Hash, Clone, Copy)] -enum ItemShape { - Oval, - Diamond, - Squiggle, -} diff --git a/src/play.rs b/src/play.rs new file mode 100644 index 0000000..2af7aaf --- /dev/null +++ b/src/play.rs @@ -0,0 +1,9 @@ +use bevy::prelude::*; + +pub struct PlayPlugin; + +impl Plugin for PlayPlugin { + fn build(&self, app: &mut App) { + // Nothing yet! + } +} diff --git a/src/setup.rs b/src/setup.rs new file mode 100644 index 0000000..14d616c --- /dev/null +++ b/src/setup.rs @@ -0,0 +1,41 @@ +use crate::{deck::*, *}; +use bevy::prelude::*; + +pub struct SetupPlugin; + +impl Plugin for SetupPlugin { + fn build(&self, app: &mut App) { + app.add_systems( + OnEnter(GameState::Setup), + (setup::setup_cards, setup::setup_camera, setup::start_play).chain(), + ); + } +} + +/// Setup drawing our cards on the screen +pub(crate) fn setup_cards(mut commands: Commands, deck: Res) { + Deck::iter_cards().for_each(|this_card| { + let this = deck + .cards + .get(&this_card) + .expect(format!("fech card sprite {:?}", this_card).as_str()) + .clone(); + commands.spawn((this, this_card)); + }); +} + +/// Setup our camera to view cardson the screen +pub(crate) fn setup_camera(mut commands: Commands) { + commands.spawn(( + Camera2d, + Camera { + hdr: true, + ..default() + }, + )); +} + +/// Finish the setup state by progressing to the play state +pub(crate) fn start_play(mut game_state: ResMut>) { + game_state.set(GameState::Play); +}