rust/lib-hwengine-future/src/lib.rs
branchtransitional_engine
changeset 16064 0caa3dfb3ba2
parent 16063 09beeec033ba
equal deleted inserted replaced
16063:09beeec033ba 16064:0caa3dfb3ba2
   139     let seed: &str = unsafe { CStr::from_ptr(seed) }.to_str().unwrap();
   139     let seed: &str = unsafe { CStr::from_ptr(seed) }.to_str().unwrap();
   140     let template_type: &str = unsafe { CStr::from_ptr(template_type) }.to_str().unwrap();
   140     let template_type: &str = unsafe { CStr::from_ptr(template_type) }.to_str().unwrap();
   141 
   141 
   142     let mut random_numbers_gen = LaggedFibonacciPRNG::new(seed.as_bytes());
   142     let mut random_numbers_gen = LaggedFibonacciPRNG::new(seed.as_bytes());
   143 
   143 
   144     let map_gen = MapGenerator::<MazeTemplate>::new(data_path);
   144     let yaml_templates =
       
   145         fs::read_to_string(data_path.join(Path::new("maze_templates.yaml")).as_path())
       
   146             .expect("Error reading map templates file");
       
   147 
       
   148     let mut map_gen = MapGenerator::<MazeTemplate>::new(data_path);
       
   149     map_gen.import_yaml_templates(&yaml_templates);
       
   150 
   145     let distance_divisor = feature_size.pow(2) / 8 + 10;
   151     let distance_divisor = feature_size.pow(2) / 8 + 10;
   146     let params = LandGenerationParameters::new(0u16, 0x8000u16, distance_divisor, false, false);
   152     let params = LandGenerationParameters::new(0u16, 0x8000u16, distance_divisor, false, false);
   147     let template = MazeTemplate {
   153 
   148         width: 4096,
   154     let template = map_gen
   149         height: 2048,
   155         .get_template(template_type, &mut random_numbers_gen)
   150         cell_size: 225,
   156         .expect("Error reading maze templates file")
   151         inverted: false,
   157         .clone();
   152         distortion_limiting_factor: 120,
   158 
   153         braidness: 10,
       
   154     };
       
   155     let landgen = map_gen.build_generator(template);
   159     let landgen = map_gen.build_generator(template);
   156     let collision = landgen.generate_land(&params, &mut random_numbers_gen);
   160     let collision = landgen.generate_land(&params, &mut random_numbers_gen);
   157     let size = collision.size().size();
   161     let size = collision.size().size();
   158 
   162 
   159     let game_field = Box::new(GameField {
   163     let game_field = Box::new(GameField {