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...
3 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.
3 weeks ago

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

Loading…
Cancel
Save