diff options
Diffstat (limited to 'graphics/src/render.rs')
| -rw-r--r-- | graphics/src/render.rs | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/graphics/src/render.rs b/graphics/src/render.rs index a206e04..340189b 100644 --- a/graphics/src/render.rs +++ b/graphics/src/render.rs @@ -92,8 +92,8 @@ pub const RENDER_WIDTH: u16 = RENDER_HEIGHT * 4 / 3; // Tile atlas.bmp textures const ATLAS_WALL_SIDE: (u16, u16) = (0, 0); -const ATLAS_FLOOR_FULL: (u16, u16) = (1, 0); -const ATLAS_FLOOR_EMPTY: (u16, u16) = (2, 0); +const ATLAS_FLOOR: (u16, u16) = (1, 0); +const ATLAS_STAIR: (u16, u16) = (2, 0); const ATLAS_WALL_TOP: (u16, u16) = (3, 0); const ATLAS_WALL_EDGE: (u16, u16) = (0, 1); @@ -103,7 +103,7 @@ const ATLAS_HEART_ICON: (u16, u16) = (2, 1); const ATLAS_DAMAGE_ICON: (u16, u16) = (3, 1); // Misc atlas.bmp textures -const ATLAS_ERROR: (u16, u16) = (3, 3); +//const ATLAS_ERROR: (u16, u16) = (3, 3); /// Full source rec for any texture const FULL_SOURCE_REC: Rectangle = rect! { @@ -376,11 +376,9 @@ impl Renderer { let idx = match tile { Tile::Wall if y + 1 == MAP_SIZE => ATLAS_WALL_TOP, Tile::Wall => ATLAS_WALL_SIDE, - Tile::Room if (x + y) % 2 == 0 => ATLAS_FLOOR_FULL, - Tile::Room if (x + y) % 2 == 1 => ATLAS_FLOOR_EMPTY, - Tile::Hallway if (x + y) % 2 == 0 => ATLAS_FLOOR_FULL, - Tile::Hallway if (x + y) % 2 == 1 => ATLAS_FLOOR_EMPTY, - _ => ATLAS_ERROR, + Tile::Room | Tile::Hallway => ATLAS_FLOOR, + Tile::Stairs => ATLAS_STAIR, + //_ => ATLAS_ERROR, }; rt.draw_atlas( &self.textures.atlas, @@ -458,19 +456,30 @@ impl Renderer { EntityKind::Player => &self.textures.player, _ => &self.textures.error, }; - let (ax, ay) = match entity.dir { + let (mut ax, ay) = match entity.dir { Direction::North => (0, 0), Direction::South => (0, 1), Direction::East => (1, 0), Direction::West => (1, 1), }; + if self.timer.since_start().as_millis() / 250 % 2 == 0 { + // entity animtion frame every 250 millis + ax += 2; + } let dest_rec = rect! { fx * size, fy * size, size, size, }; - r.draw_atlas(texture, (ax, ay), dest_rec.x, dest_rec.y, size, 0.0); + r.draw_atlas( + texture, + (ax, ay), + dest_rec.x, + dest_rec.y - WALL_HEIGHT as f32, + size, + 0.0, + ); if self.debug { r.draw_rectangle_lines_ex(dest_rec, 1.0, Color::YELLOW); |