Working on editor
This commit is contained in:
@@ -209,7 +209,7 @@ impl GraphicTile {
|
||||
}
|
||||
}
|
||||
|
||||
panic!("Did not find a tile, implementation error");
|
||||
GraphicTile::Center
|
||||
}
|
||||
|
||||
/// Returns the offset to the corresponding graphic tile in the texture.
|
||||
@@ -279,11 +279,6 @@ impl Map {
|
||||
tiles[(rows - 1, i)] = CollisionTile::full();
|
||||
}
|
||||
|
||||
tiles[(25, 12)] = CollisionTile::full();
|
||||
tiles[(25, 13)] = CollisionTile::full();
|
||||
tiles[(25, 14)] = CollisionTile::full();
|
||||
tiles[(25, 15)] = CollisionTile::full();
|
||||
|
||||
Map::from_collision_tiles(tiles)
|
||||
}
|
||||
|
||||
|
||||
@@ -72,12 +72,17 @@ impl Renderer {
|
||||
|
||||
/// Draws a drawable.
|
||||
pub fn draw<D: Drawable>(&mut self, drawable: &D) {
|
||||
self.translate_and_draw(drawable, (0.0, 0.0));
|
||||
}
|
||||
|
||||
/// Draws a drawable with a certain translation.
|
||||
pub fn translate_and_draw<D: Drawable, V: Into<Vector2<f32>>>(&mut self, drawable: &D, translation: V) {
|
||||
let texture = self.texture_manager.get(drawable.texture());
|
||||
let mut sprite = Sprite::with_texture(&texture);
|
||||
sprite.set_texture_rect(&drawable.texture_rect());
|
||||
|
||||
use sfml::graphics::Transformable;
|
||||
sprite.set_position(drawable.position());
|
||||
sprite.set_position(drawable.position() + translation.into());
|
||||
|
||||
self.window.draw(&sprite);
|
||||
}
|
||||
@@ -116,4 +121,14 @@ impl Renderer {
|
||||
pub fn poll_event(&mut self) -> Option<Event> {
|
||||
self.window.poll_event()
|
||||
}
|
||||
|
||||
/// Returns a reference to the window.
|
||||
pub fn window(&self) -> &RenderWindow {
|
||||
&self.window
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the window.
|
||||
pub fn window_mut(&mut self) -> &mut RenderWindow {
|
||||
&mut self.window
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user