From c62350e38207d4e2996a09a51ca5843fb141a92a Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Tue, 7 Oct 2025 16:12:59 -0700 Subject: [PATCH] Spawning pieces at top of board by default --- src/bin/tetris/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bin/tetris/main.rs b/src/bin/tetris/main.rs index bc8b9c4..3ff35f3 100644 --- a/src/bin/tetris/main.rs +++ b/src/bin/tetris/main.rs @@ -26,14 +26,13 @@ fn main() { const SCALE: f32 = 30.0; -#[derive(Component, Default, Debug, Clone, Copy, PartialEq)] +#[derive(Component, Debug, Clone, Copy, PartialEq)] #[require(Transform, Visibility)] struct GridPosition { x: usize, y: usize, } -// TODO: Restirct movement to within the grid impl GridPosition { fn move_up(&self) -> Self { Self { @@ -64,6 +63,15 @@ impl GridPosition { } } +impl Default for GridPosition { + fn default() -> Self { + GridPosition { + x: 5, + y: 20, + } + } +} + impl From<&GridPosition> for Vec3 { fn from(GridPosition { x, y }: &GridPosition) -> Vec3 { // Grid Positions start in the bottom left of the area