diff --git a/src/bin/tetris/main.rs b/src/bin/tetris/main.rs index 4f84866..c0c23b0 100644 --- a/src/bin/tetris/main.rs +++ b/src/bin/tetris/main.rs @@ -487,8 +487,32 @@ impl Shape { output } + + fn height(&self) -> usize { + let mut x = 0; + + match self { + Self::M4(this) => { + for i in 0..4 { + if this.col(i).to_array().contains(&1.0) { + x += 1 + } + } + } + Self::M3(this) => { + for i in 0..3 { + if this.col(i).to_array().contains(&1.0) { + x += 1 + } + } + } + }; + + x + } } +// TODO: move to trigger fn update_position( mut changed: Query< (Entity, &GridPosition, &mut Transform), @@ -506,9 +530,9 @@ fn update_position( }); } -// TODO: Inline this to when movement occurs +// TODO: Move to trigger fn update_shape_blocks( - query: Query<(Entity, &Shape, &GridPosition), Or<(Added, Changed)>>, + query: Query<(Entity, &Shape, &GridPosition), Or<(Added, Changed, Added, Changed)>>, mut blocks: Query<&mut GridPosition, (With, Without)>, mut commands: Commands, visuals: Res, @@ -620,10 +644,11 @@ fn clock_cycle(n: f32) -> impl FnMut(Res