From a425a5756cfb0e370775c04bf81cb21476dcb796 Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Tue, 3 Oct 2023 22:38:16 -0700 Subject: [PATCH] Selecting + Calling the piece (board.at) --- README.md | 42 +++++++++++++++++++++++++++--------------- src/display2d.rs | 8 ++++---- src/game.rs | 14 +++++++------- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 40f079b..bddd0eb 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,52 @@ # TODO -## gameplay - -Draw board based on board resource. +## 2d gameplay Background music audio. -Import GLTF assets and use them for drawing pawn, drone, and queens. +Pick up, put down. +Audio for pick up/put down. -Menu: Start, Credits, Quit +Determine valid moves. +Menu: + Start, Credits, Quit + Start -> Gameplay + States: Loading, Gameplay, Menu, Credits, Quit +Gameplay + Escape -> Overlay Menu Menu audio -Start -> Gameplay +Turns + Manual 2 player. -Gameplay + Escape -> Overlay Menu +Ownership based on placement + color based on placement. -States: Gameplay, Menu, Credits, Quit +## 3d gameplay -Pick up, put down. +Import GLTF assets and use them for drawing pawn, drone, and queens. -Audio for pick up/put down. +Select piece in 3d + 3d hitbox -Determine valid moves. +Pick up + Put down -Turns + Manual 2 player. +Gravity for moving piece -Ownership based on placement + color based on placement. +Visual flare for possible moves + +## AI RandoAI Menu: Local 2 Player / Play Against RandoAI -Menu: settings + Settings State: Audio Volume(s), Windowing +Menu: Settings + Settings State: Audio Volume(s), Windowing ## packaging -need to set LD_LIBRARY_PATH (linux) and PATH (windows) to a local folder +Need to set LD_LIBRARY_PATH (linux) and PATH (windows) to a local folder containing the fmod .so and .dll files respectively. + +Package web version with WASM libraries + +Linux: https://appimage.org/ +Windows: diff --git a/src/display2d.rs b/src/display2d.rs index 1813fc5..c513065 100644 --- a/src/display2d.rs +++ b/src/display2d.rs @@ -223,8 +223,8 @@ fn cursor_position( }); } -fn selected(selected: Res) { - if selected.idx.is_some() { - info!("Selected Tile: {:?}", selected.idx); - } +fn selected(selected: Res, board: Res) { + selected.idx.iter().for_each(|idx| { + info!("Selected Tile: {:?} contains {:?}", idx, board.at(idx)); + }); } diff --git a/src/game.rs b/src/game.rs index f937082..343c734 100644 --- a/src/game.rs +++ b/src/game.rs @@ -51,15 +51,10 @@ pub(crate) struct BoardIndex { pub y: usize, } -#[derive(Debug, Default, Resource)] -pub(crate) struct SelectedTile { - pub idx: Option, -} - impl Board { /// Returns the piece at the given location - pub(crate) fn _at(&self, (_x, _y): (usize, usize)) -> Option { - todo!("return piece at location") + pub(crate) fn at(&self, BoardIndex { x, y }: &BoardIndex) -> Option { + self.inner[*y][*x].clone() } /// Returns a list of all pieces on the board with their location @@ -95,6 +90,11 @@ impl std::fmt::Display for Board { } } +#[derive(Debug, Default, Resource)] +pub(crate) struct SelectedTile { + pub idx: Option, +} + fn setup_board(mut commands: Commands) { use Piece::*; commands.insert_resource(Board {