X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fcore%2Fgame.rs;h=b0d996839ffe4f317f05fe2b47743dbf76d5b30c;hb=b5332019b30abd70698c9cdd7b7b9d42502681c2;hp=8fbbef04059a7c971cd32eb1bd0a7cc72b4a55bd;hpb=b0137bb6d47c158bff30f2d4fd1faab9d4945d54;p=kaka%2Frust-sdl-test.git diff --git a/src/core/game.rs b/src/core/game.rs index 8fbbef0..b0d9968 100644 --- a/src/core/game.rs +++ b/src/core/game.rs @@ -173,8 +173,8 @@ impl Object for Character { fn update(&mut self, objects: &mut Objects, lvl: &Level, dt: Duration) -> ObjectState { let ctrl = self.ctrl.borrow(); - let x = (self.pos.x / lvl.grid.cell_size.width as f64).min(lvl.grid.size.width as f64 - 1.0).max(0.0) as usize; - let y = (self.pos.y / lvl.grid.cell_size.height as f64).min(lvl.grid.size.height as f64 - 1.0).max(0.0) as usize; + let x = (self.pos.x / lvl.grid.scale.width as f64).min(lvl.grid.size.width as f64 - 1.0).max(0.0) as usize; + let y = (self.pos.y / lvl.grid.scale.height as f64).min(lvl.grid.size.height as f64 - 1.0).max(0.0) as usize; self.vel += lvl.gravity; if lvl.grid.cells[x][y] { if self.vel.y > 0.0 && !(ctrl.mov.down() && ctrl.jump.is_pressed) { @@ -287,23 +287,6 @@ impl Object for Boll { ..*self })); } - // let x = (self.pos.x / lvl.grid.cell_size.width as f64).min(lvl.grid.size.width as f64 - 1.0).max(0.0) as usize; - // let y = (self.pos.y / lvl.grid.cell_size.height as f64).min(lvl.grid.size.height as f64 - 1.0).max(0.0) as usize; - // if lvl.grid.cells[x][y] { - // if self.bounces == 0 { - // return Dead - // } - // self.vel *= -0.25; - // self.pos += self.vel; - // self.bounces -= 1; - // use rand::distributions::{Distribution, Normal}; - // let mut rng = rand::thread_rng(); - // let a = Radians(self.vel.to_radians().0 + Normal::new(0.0, 0.75).sample(&mut rng)); - // objects.push(Box::new(Boll { - // vel: Point::from(a) * Normal::new(1.0, 0.25).sample(&mut rng) * self.vel.length(), - // ..*self - // })); - // } Alive }