From c39b6d212077daa987be59dd9b493f677a4fb080 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Wed, 27 Aug 2025 12:57:02 -0500 Subject: [PATCH] Add a const `OCTAGON` and use it in map.rs We could made a bunch of pre-built Card constatns for all the basic shapes. That way we can `Card::OCTAGON` to create one, instead of typing out the whole function call. --- src/card.rs | 3 +++ src/game/map.rs | 15 +-------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/card.rs b/src/card.rs index 6c9cecf..5409c64 100644 --- a/src/card.rs +++ b/src/card.rs @@ -97,6 +97,9 @@ impl Card { } } + // TODO: The other shapes + pub const OCTAGON: Self = Self::new(OCTAGON); + /// Produces a new card by stacking another on top of this one. pub fn merge(self, top: Self) -> (Self, Option) { let mut new_card = Self::default(); diff --git a/src/game/map.rs b/src/game/map.rs index 26b9a14..44cea41 100644 --- a/src/game/map.rs +++ b/src/game/map.rs @@ -11,20 +11,7 @@ pub fn setup_test_tilemap(mut commands: Commands, assets: Res) { let map_size = TilemapSize { x: 9, y: 9 }; let mut tile_storage = TileStorage::empty(map_size); - let card = Card { - cells: [ - Cell::NW, - Cell::Filled, - Cell::NE, - Cell::Filled, - Cell::Filled, - Cell::Filled, - Cell::SW, - Cell::Filled, - Cell::SE, - ], - ..Default::default() - }; + let card = Card::OCTAGON; add_card_to_tilemap( &card,