forked from tutorials/rust-sokoban
Finish 3.1 Colored boxes
This commit is contained in:
parent
e354353e38
commit
c33a5683e7
@ -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,
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user