diff --git a/src/bin/tetris/main.rs b/src/bin/tetris/main.rs index 2ba2ed8..29f7614 100644 --- a/src/bin/tetris/main.rs +++ b/src/bin/tetris/main.rs @@ -64,7 +64,6 @@ fn main() { sync_resource_to_ui::.run_if(resource_changed::), sync_resource_to_ui::.run_if(resource_changed::), sync_singleton_to_ui::.run_if(any_component_changed::), - sync_singleton_to_ui::.run_if(any_component_changed::), ), ) .add_systems(Update, draw_grid) @@ -200,46 +199,6 @@ impl std::ops::AddAssign<&GridPosition> for GridPosition { } } -#[derive(Component, Default, Event, Clone, Debug)] -enum Orientation { - #[default] - Up, - Left, - Down, - Right, -} - -impl Orientation { - fn next(&self) -> Self { - match self { - Self::Up => Self::Left, - Self::Left => Self::Down, - Self::Down => Self::Right, - Self::Right => Self::Up, - } - } - - fn prev(&self) -> Self { - match self { - Self::Up => Self::Right, - Self::Right => Self::Down, - Self::Down => Self::Left, - Self::Left => Self::Up, - } - } -} - -impl Display for Orientation { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Orientation::Up => write!(f, "up"), - Orientation::Down => write!(f, "down"), - Orientation::Left => write!(f, "<-"), - Orientation::Right => write!(f, "->"), - } - } -} - #[derive(States, Clone, Eq, PartialEq, Debug, Hash, Default, Component)] enum GameState { #[default] @@ -361,10 +320,6 @@ fn init_debug_ui(mut commands: Commands) { Node::default(), children![ (Text::new("SHAPE"), SyncSingleton::::default()), - ( - Text::new("ORIENTATION"), - SyncSingleton::::default() - ), ], )); }); @@ -482,10 +437,6 @@ impl Shape { } } - fn rotate(&mut self) { - *self = self.rotated(); - } - fn coordinates( &self, center: &GridPosition, @@ -557,13 +508,13 @@ fn update_position( // TODO: Inline this to when movement occurs fn update_shape_blocks( - query: Query<(Entity, &Shape, &Orientation, &GridPosition), Or<(Added, Changed)>>, + query: Query<(Entity, &Shape, &GridPosition), Or<(Added, Changed)>>, mut blocks: Query<&mut GridPosition, (With, Without)>, mut commands: Commands, visuals: Res, ) { - query.iter().for_each(|(e, s, o, center)| { - debug!("Setting piece: {e:?} {o:?} {center:?}\n{}", s.as_ascii()); + query.iter().for_each(|(e, s, center)| { + debug!("Setting piece: {e:?} {center:?}\n{}", s.as_ascii()); if blocks.is_empty() { let mesh = Mesh2d(visuals.mesh.clone()); @@ -668,7 +619,6 @@ fn clock_cycle(n: f32) -> impl FnMut(Res