rust/lib-hedgewars-engine/src/world.rs
changeset 14714 4df1aac5f090
parent 14711 40809bfd44af
child 14715 e519802076e9
equal deleted inserted replaced
14711:40809bfd44af 14714:4df1aac5f090
    39             camera: Camera::new(),
    39             camera: Camera::new(),
    40         }
    40         }
    41     }
    41     }
    42 
    42 
    43     pub fn create_renderer(&mut self, width: u16, height: u16) {
    43     pub fn create_renderer(&mut self, width: u16, height: u16) {
    44         self.renderer = Some(MapRenderer::new(512, 512));
    44         let land_tile_size = Size::square(512);
       
    45         self.renderer = Some(MapRenderer::new(land_tile_size));
    45         self.camera = Camera::with_size(Size::new(width as usize, height as usize));
    46         self.camera = Camera::with_size(Size::new(width as usize, height as usize));
    46 
    47 
    47         use mapgen::{theme::Theme, MapGenerator};
    48         use mapgen::{theme::Theme, MapGenerator};
    48         use std::path::Path;
    49         use std::path::Path;
    49 
    50 
    50         if let Some(ref state) = self.game_state {
    51         if let Some(ref state) = self.game_state {
    51             self.camera.position = state.land.play_box().center();
    52             self.camera.position = state.land.play_box().center();
    52             
    53 
    53             let theme =
    54             let theme =
    54                 Theme::load(Path::new("../../share/hedgewars/Data/Themes/Cheese/")).unwrap();
    55                 Theme::load(Path::new("../../share/hedgewars/Data/Themes/Cheese/")).unwrap();
    55             let texture = MapGenerator::new().make_texture(&state.land, &theme);
    56             let texture = MapGenerator::new().make_texture(&state.land, &theme);
    56             if let Some(ref mut renderer) = self.renderer {
    57             if let Some(ref mut renderer) = self.renderer {
    57                 renderer.init(&texture);
    58                 renderer.init(&texture);