Compare commits

..

2 Commits

Author SHA1 Message Date
Elijah Voigt 5fe049e4d3 Fix the bug where sometimes shapes occupy the same space as other
shapes.

This is game breaking and gets in the way of testing and developing
other features...
4 weeks ago
Elijah Voigt ea4448f781 Fix a bug where textures did not follow debug state when new entities
were spawned (i.e., shapes), leading to textured shapes being added in
debug mode.
4 weeks ago

@ -39,10 +39,10 @@ fn main() {
), ),
) )
.add_systems( .add_systems(
OnEnter(DebuggingState::On), toggle_visuals OnEnter(DebuggingState::On), toggle_art
) )
.add_systems( .add_systems(
OnExit(DebuggingState::On), toggle_visuals OnExit(DebuggingState::On), toggle_art
) )
.add_systems( .add_systems(
Update, Update,
@ -88,6 +88,7 @@ fn main() {
damage_over_time.run_if(on_timer(Duration::from_secs(5))), damage_over_time.run_if(on_timer(Duration::from_secs(5))),
check_level_goal.run_if(resource_changed::<Score>), check_level_goal.run_if(resource_changed::<Score>),
check_level_fail.run_if(any_component_removed::<ShapeBlock>), check_level_fail.run_if(any_component_removed::<ShapeBlock>),
toggle_art.run_if(any_component_added::<Art>),
), ),
) )
// UI systems // UI systems
@ -396,37 +397,30 @@ fn init_tetris(
}, },
material_o: materials.add(ColorMaterial { material_o: materials.add(ColorMaterial {
color: YELLOW.into(), color: YELLOW.into(),
texture: Some(server.load("tetris/shape_block.png")),
..default() ..default()
}), }),
material_t: materials.add(ColorMaterial { material_t: materials.add(ColorMaterial {
color: PURPLE.into(), color: PURPLE.into(),
texture: Some(server.load("tetris/shape_block.png")),
..default() ..default()
}), }),
material_l: materials.add(ColorMaterial { material_l: materials.add(ColorMaterial {
color: ORANGE.into(), color: ORANGE.into(),
texture: Some(server.load("tetris/shape_block.png")),
..default() ..default()
}), }),
material_j: materials.add(ColorMaterial { material_j: materials.add(ColorMaterial {
color: BLUE.into(), color: BLUE.into(),
texture: Some(server.load("tetris/shape_block.png")),
..default() ..default()
}), }),
material_s: materials.add(ColorMaterial { material_s: materials.add(ColorMaterial {
color: LIME.into(), color: LIME.into(),
texture: Some(server.load("tetris/shape_block.png")),
..default() ..default()
}), }),
material_z: materials.add(ColorMaterial { material_z: materials.add(ColorMaterial {
color: RED.into(), color: RED.into(),
texture: Some(server.load("tetris/shape_block.png")),
..default() ..default()
}), }),
material_i: materials.add(ColorMaterial { material_i: materials.add(ColorMaterial {
color: AQUA.into(), color: AQUA.into(),
texture: Some(server.load("tetris/shape_block.png")),
..default() ..default()
}), }),
}); });
@ -438,7 +432,6 @@ fn init_tetris(
Mesh2d(mesh.clone()), Mesh2d(mesh.clone()),
MeshMaterial2d(materials.add(ColorMaterial { MeshMaterial2d(materials.add(ColorMaterial {
color: BLACK.into(), color: BLACK.into(),
texture: Some(server.load("tetris/bg_block.png")),
..default() ..default()
})), })),
Art { Art {
@ -471,7 +464,6 @@ fn init_battler(
{ {
let mat = materials.add(ColorMaterial { let mat = materials.add(ColorMaterial {
color: BLUE.into(), color: BLUE.into(),
texture: Some(server.load("tetris/placeholder_protagonist.png")),
..default() ..default()
}); });
let mesh = meshes.add(Ellipse::new(SCALE, SCALE * 2.0)); let mesh = meshes.add(Ellipse::new(SCALE, SCALE * 2.0));
@ -494,7 +486,6 @@ fn init_battler(
{ {
let mat = materials.add(ColorMaterial { let mat = materials.add(ColorMaterial {
color: RED.into(), color: RED.into(),
texture: Some(server.load("tetris/placeholder_enemy.png")),
..default() ..default()
}); });
let art = Art { let art = Art {
@ -1492,8 +1483,9 @@ fn check_level_fail(
}); });
} }
fn toggle_visuals( fn toggle_art(
state: Res<State<DebuggingState>>, state: Res<State<DebuggingState>>,
// TODO: Correctness: Query for added or changed <Art> entities
query: Query<(&MeshMaterial2d<ColorMaterial>, &Art)>, query: Query<(&MeshMaterial2d<ColorMaterial>, &Art)>,
mut color_materials: ResMut<Assets<ColorMaterial>>, mut color_materials: ResMut<Assets<ColorMaterial>>,
) { ) {

Loading…
Cancel
Save