Dolda2000 GitWeb
/
kaka
/
rust-sdl-test.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use durations everywhere!
[kaka/rust-sdl-test.git]
/
src
/
core
/
game.rs
diff --git
a/src/core/game.rs
b/src/core/game.rs
index
bf7d2df
..
80e1e36
100644
(file)
--- a/
src/core/game.rs
+++ b/
src/core/game.rs
@@
-1,5
+1,4
@@
use AppState;
use AppState;
-use common::Nanoseconds;
use common::Point2D;
use core::controller::Controller;
use core::controller::ControllerManager;
use common::Point2D;
use core::controller::Controller;
use core::controller::ControllerManager;
@@
-11,6
+10,7
@@
use sdl2::video::Window;
use sprites::SpriteManager;
use std::cell::RefCell;
use std::rc::Rc;
use sprites::SpriteManager;
use std::cell::RefCell;
use std::rc::Rc;
+use time::Duration;
////////// GAMESTATE ///////////////////////////////////////////////////////////
////////// GAMESTATE ///////////////////////////////////////////////////////////
@@
-36,7
+36,7
@@
impl AppState for GameState {
fn leave(&mut self) {}
fn leave(&mut self) {}
- fn update(&mut self, dt:
Nanoseconds
) {
+ fn update(&mut self, dt:
Duration
) {
self.world.update(dt);
}
self.world.update(dt);
}
@@
-66,7
+66,7
@@
impl World {
}
}
}
}
- pub fn update(&mut self, dt:
Nanoseconds
) {
+ pub fn update(&mut self, dt:
Duration
) {
let mut breeding_ground = vec!();
for i in (0..self.objects.len()).rev() {
let mut breeding_ground = vec!();
for i in (0..self.objects.len()).rev() {
@@
-116,7
+116,7
@@
impl Level {
type Objects = Vec<Box<dyn Object>>;
pub trait Object {
type Objects = Vec<Box<dyn Object>>;
pub trait Object {
- fn update(&mut self, objects: &mut Objects, lvl: &Level, dt:
Nanoseconds
) -> ObjectState;
+ fn update(&mut self, objects: &mut Objects, lvl: &Level, dt:
Duration
) -> ObjectState;
fn render(&self, _canvas: &mut Canvas<Window>, _sprites: &mut SpriteManager) {}
}
fn render(&self, _canvas: &mut Canvas<Window>, _sprites: &mut SpriteManager) {}
}
@@
-147,7
+147,7
@@
impl Character {
}
impl Object for Character {
}
impl Object for Character {
- fn update(&mut self, objects: &mut Objects, lvl: &Level,
_dt: Nanoseconds
) -> ObjectState {
+ fn update(&mut self, objects: &mut Objects, lvl: &Level,
dt: Duration
) -> ObjectState {
self.vel += lvl.gravity;
self.pos += self.vel;
self.vel += lvl.gravity;
self.pos += self.vel;
@@
-173,7
+173,7
@@
impl Object for Character {
bounces: 2,
}));
}
bounces: 2,
}));
}
- ctrl.rumble(1.0,
_dt as u32 / 1_000_000
);
+ ctrl.rumble(1.0,
dt
);
}
match ctrl.mov.x {
}
match ctrl.mov.x {
@@
-223,7
+223,7
@@
pub struct Boll {
}
impl Object for Boll {
}
impl Object for Boll {
- fn update(&mut self, _objects: &mut Objects, lvl: &Level, _dt:
Nanoseconds
) -> ObjectState {
+ fn update(&mut self, _objects: &mut Objects, lvl: &Level, _dt:
Duration
) -> ObjectState {
self.vel += lvl.gravity;
self.pos += self.vel;
self.vel += lvl.gravity;
self.pos += self.vel;