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;
use std::fmt::Display; use std::fmt::Display;
#[derive(PartialEq)]
pub enum BoxColor { pub enum BoxColor {
Red, Red,
Blue, Blue,

View File

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