Skip to content
Snippets Groups Projects
Commit 8554f5f4 authored by pumapaul's avatar pumapaul
Browse files

Add new assets in code

parent b45e23e2
No related branches found
No related tags found
No related merge requests found
......@@ -392,19 +392,34 @@ impl GameState {
Tile::Wall => GameState::draw_wall(self, draw_x, draw_y, ctx),
Tile::Player => GameState::draw_player(self, draw_x, draw_y, ctx),
Tile::Enemy(_) => GameState::draw_enemy(self, draw_x, draw_y, ctx),
Tile::Exit => GameState::draw_tile(self, Color::RED, draw_x, draw_y, ctx),
Tile::Exit => GameState::draw_exit(self, draw_x, draw_y, ctx),
Tile::Treasure(_, _) => GameState::draw_treasure(self, draw_x, draw_y, ctx),
}
}
}
}
fn draw_exit(&mut self, x: usize, y: usize, ctx: &mut Context) {
GameState::draw_tile(self, Color::WHITE, x, y, ctx);
self.textures.exit.draw(ctx, DrawParams {
position: Vec2::new(x as f32 * 33.0, y as f32 * 33.0),
scale: Vec2::new(1.0, 1.0),
origin: Vec2::new(0.0, 0.0),
rotation: 0.0,
color: Color::WHITE,
})
}
fn draw_treasure(&mut self, x: usize, y: usize, ctx: &mut Context) {
GameState::draw_tile(self, Color::WHITE, x, y, ctx);
self.textures.treasure.draw(ctx, DrawParams {
position: Vec2::new(x as f32 * 33.0, y as f32 * 33.0),
scale: Vec2::new(1.0, 1.0),
origin: Vec2::new(0.0, 0.0),
rotation: 0.0,
color: Color::GREEN,
color: Color::WHITE,
})
}
......
......@@ -9,6 +9,7 @@ pub struct Textures {
pub player: Texture,
pub enemy: Texture,
pub treasure: Texture,
pub exit: Texture,
}
impl Textures {
......@@ -20,7 +21,8 @@ impl Textures {
cross: Texture::new(ctx, "./resources/cross.png")?,
player: Texture::new(ctx, "./resources/player_new.png")?,
enemy: Texture::new(ctx, "./resources/foe.png")?,
treasure: Texture::new(ctx, "./resources/tile.png")?,
treasure: Texture::new(ctx, "./resources/chest.png")?,
exit: Texture::new(ctx, "./resources/stairs.png")?,
})
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment