rust/lib-hedgewars-engine/src/world.rs
changeset 15757 c7332c7f64cd
parent 15755 2eb3469a28a0
child 15758 6c939e6de981
equal deleted inserted replaced
15756:1d652bca512e 15757:c7332c7f64cd
   104         let params = LandGenerationParameters::new(0u32, u32::max_value(), 5, false, false);
   104         let params = LandGenerationParameters::new(0u32, u32::max_value(), 5, false, false);
   105         let landgen = TemplatedLandGenerator::new(template);
   105         let landgen = TemplatedLandGenerator::new(template);
   106         let land = landgen.generate_land(&params, &mut self.random_numbers_gen);
   106         let land = landgen.generate_land(&params, &mut self.random_numbers_gen);
   107 
   107 
   108         self.game_state = Some(GameState::new(land, physics));
   108         self.game_state = Some(GameState::new(land, physics));
       
   109 
       
   110         if let Some(ref mut state) = self.game_state {
       
   111             let position = Point::new(
       
   112                 (self.random_numbers_gen.next().unwrap() % state.land.width() as u32) as i32,
       
   113                 0,
       
   114             );
       
   115             self.create_gear(position);
       
   116         }
   109     }
   117     }
   110 
   118 
   111     pub fn move_camera(&mut self, position_shift: Point, zoom_shift: f32) {
   119     pub fn move_camera(&mut self, position_shift: Point, zoom_shift: f32) {
   112         self.camera.zoom += zoom_shift;
   120         self.camera.zoom += zoom_shift;
   113         self.camera.position += Point::new(
   121         self.camera.position += Point::new(
   146     }
   154     }
   147 
   155 
   148     pub fn step(&mut self) {
   156     pub fn step(&mut self) {
   149         if let Some(ref mut state) = self.game_state {
   157         if let Some(ref mut state) = self.game_state {
   150             let next = self.random_numbers_gen.next().unwrap();
   158             let next = self.random_numbers_gen.next().unwrap();
   151             if next % 32 == 0 {
   159             /*if next % 32 == 0 {
   152                 let position = Point::new(
   160                 let position = Point::new(
   153                     (self.random_numbers_gen.next().unwrap() % state.land.width() as u32) as i32,
   161                     (self.random_numbers_gen.next().unwrap() % state.land.width() as u32) as i32,
   154                     0,
   162                     0,
   155                 );
   163                 );
   156                 self.create_gear(position);
   164                 self.create_gear(position);
   157             }
   165             }*/
   158         }
   166         }
   159 
   167 
   160         if let Some(ref mut state) = self.game_state {
   168         if let Some(ref mut state) = self.game_state {
   161             state.physics.step(Millis::new(1), &state.land);
   169             state.physics.step(Millis::new(1), &state.land);
   162         }
   170         }