rust/lib-hedgewars-engine/src/world.rs
changeset 16017 e8afb1bf2779
parent 15891 d52f5d8e75e6
child 16022 2003b466b279
equal deleted inserted replaced
16016:4933920eba89 16017:e8afb1bf2779
    10     outline_template::OutlineTemplate, template_based::TemplatedLandGenerator,
    10     outline_template::OutlineTemplate, template_based::TemplatedLandGenerator,
    11     LandGenerationParameters, LandGenerator,
    11     LandGenerationParameters, LandGenerator,
    12 };
    12 };
    13 use lfprng::LaggedFibonacciPRNG;
    13 use lfprng::LaggedFibonacciPRNG;
    14 use std::path::{Path, PathBuf};
    14 use std::path::{Path, PathBuf};
       
    15 use log::trace;
    15 
    16 
    16 use crate::render::{camera::Camera, GearEntry, GearRenderer, MapRenderer};
    17 use crate::render::{camera::Camera, GearEntry, GearRenderer, MapRenderer};
    17 
    18 
    18 struct GameState {
    19 struct GameState {
    19     land: Land2D<u32>,
    20     land: Land2D<u32>,
    57         let land_tile_size = Size::square(512);
    58         let land_tile_size = Size::square(512);
    58         self.map_renderer = Some(MapRenderer::new(land_tile_size));
    59         self.map_renderer = Some(MapRenderer::new(land_tile_size));
    59         self.gear_renderer = Some(GearRenderer::new(&self.data_path.as_path()));
    60         self.gear_renderer = Some(GearRenderer::new(&self.data_path.as_path()));
    60         self.camera = Camera::with_size(Size::new(width as usize, height as usize));
    61         self.camera = Camera::with_size(Size::new(width as usize, height as usize));
    61 
    62 
       
    63         if let Some(ref state) = self.game_state {
       
    64             self.camera.position = state.land.play_box().center();
       
    65         }
       
    66     }
       
    67 
       
    68     pub fn init_renderer(&mut self) {
    62         use mapgen::{theme::Theme, MapGenerator};
    69         use mapgen::{theme::Theme, MapGenerator};
    63 
    70 
    64         if let Some(ref state) = self.game_state {
    71         if let Some(ref state) = self.game_state {
    65             self.camera.position = state.land.play_box().center();
       
    66 
       
    67             let theme =
    72             let theme =
    68                 Theme::load(self.data_path.join(Path::new("Themes/Cheese/")).as_path()).unwrap();
    73                 Theme::load(self.data_path.join(Path::new("Themes/Cheese/")).as_path()).unwrap();
    69             let texture = MapGenerator::new().make_texture(&state.land, &theme);
    74             let texture = MapGenerator::new().make_texture(&state.land, &theme);
    70             if let Some(ref mut renderer) = self.map_renderer {
    75             if let Some(ref mut renderer) = self.map_renderer {
    71                 renderer.init(&texture);
    76                 renderer.init(&texture);