|
@@ -15,36 +15,23 @@ impl<'a, 'r> System<'a> for DrawRenderables<'r> {
|
|
|
);
|
|
|
|
|
|
fn run(&mut self, (positions, renderables, map): Self::SystemData) {
|
|
|
- let mut y = 0;
|
|
|
- let mut x = 0;
|
|
|
- for (idx, tile) in map.tiles.iter().enumerate() {
|
|
|
+ let points = iproduct!(0..map::MAPHEIGHT, 0..map::MAPWIDTH);
|
|
|
+ for (idx, (tile, (y, x))) in map.tiles.iter().zip(points).enumerate() {
|
|
|
// Render a tile depending upon the tile type
|
|
|
|
|
|
if map.revealed_tiles[idx] {
|
|
|
- let glyph;
|
|
|
- let mut fg;
|
|
|
- match tile {
|
|
|
- map::TileType::Floor => {
|
|
|
- glyph = rltk::to_cp437('.');
|
|
|
- fg = rltk::RGB::from_f32(0.0, 0.5, 0.5);
|
|
|
- }
|
|
|
- map::TileType::Wall => {
|
|
|
- glyph = rltk::to_cp437('#');
|
|
|
- fg = rltk::RGB::from_f32(0., 1.0, 0.);
|
|
|
- }
|
|
|
- }
|
|
|
- if !map.visible_tiles[idx] {
|
|
|
- fg = fg.to_greyscale()
|
|
|
- }
|
|
|
- self.ctx
|
|
|
- .set(x, y, fg, rltk::RGB::from_f32(0., 0., 0.), glyph);
|
|
|
- }
|
|
|
-
|
|
|
- // Move the coordinates
|
|
|
- x += 1;
|
|
|
- if x > map::MAPWIDTH as i32 - 1 {
|
|
|
- x = 0;
|
|
|
- y += 1;
|
|
|
+ let fg = if map.visible_tiles[idx] {
|
|
|
+ tile.color()
|
|
|
+ } else {
|
|
|
+ tile.color().to_greyscale()
|
|
|
+ };
|
|
|
+ self.ctx.set(
|
|
|
+ x as i32,
|
|
|
+ y as i32,
|
|
|
+ fg,
|
|
|
+ rltk::RGB::from_f32(0., 0., 0.),
|
|
|
+ tile.glyph(),
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
|