Finish 3.1 Colored boxes

This commit is contained in:
Timothy Warren 2020-07-24 18:00:23 -04:00
parent e354353e38
commit c33a5683e7
2 changed files with 12 additions and 4 deletions

View File

@ -2,6 +2,7 @@ use specs::{Component, NullStorage, VecStorage, World, WorldExt};
use std::fmt;
use std::fmt::Display;
#[derive(PartialEq)]
pub enum BoxColor {
Red,
Blue,

View File

@ -30,10 +30,17 @@ impl<'a> System<'a> for GameplayStateSystem {
.collect();
// loop through all box spots and check if there is a corresponding
// box at that position
for (_box_spot, position) in (&box_spots, &positions).join() {
if boxes_by_position.contains_key(&(position.x, position.y)) {
// box at that position. since we now have different types of boxes
// we need to make sure the right type of box is on the right
// type of spot.
for (box_spot, position) in (&box_spots, &positions).join() {
if let Some(the_box) = boxes_by_position.get(&(position.x, position.y)) {
if the_box.color == box_spot.color {
// continue
} else {
// return, haven't won yet
return;
}
} else {
gameplay_state.state = GameplayState::Playing;
return;