remove `get_frame_time()`

This commit is contained in:
sparshg 2022-10-10 01:42:23 +05:30
parent 4084a43acc
commit 6e1b0f9d3b
2 changed files with 7 additions and 7 deletions

View File

@ -64,8 +64,8 @@ impl Asteroid {
pub fn update(&mut self) { pub fn update(&mut self) {
// if self.alive { // if self.alive {
self.pos += self.vel * get_frame_time(); self.pos += self.vel;
self.rot += self.omega * get_frame_time(); self.rot += self.omega;
if self.pos.x.abs() > screen_width() * 0.5 + self.radius { if self.pos.x.abs() > screen_width() * 0.5 + self.radius {
self.pos.x *= -1.; self.pos.x *= -1.;
} }

View File

@ -57,11 +57,11 @@ impl Player {
pub fn update(&mut self) { pub fn update(&mut self) {
let mut mag = 0.; let mut mag = 0.;
if is_key_down(KeyCode::Right) { if is_key_down(KeyCode::Right) {
self.rot += 5. * get_frame_time(); self.rot += 5.;
self.dir = vec2(self.rot.cos(), self.rot.sin()); self.dir = vec2(self.rot.cos(), self.rot.sin());
} }
if is_key_down(KeyCode::Left) { if is_key_down(KeyCode::Left) {
self.rot -= 5. * get_frame_time(); self.rot -= 5.;
self.dir = vec2(self.rot.cos(), self.rot.sin()); self.dir = vec2(self.rot.cos(), self.rot.sin());
} }
if is_key_down(KeyCode::Up) { if is_key_down(KeyCode::Up) {
@ -78,8 +78,8 @@ impl Player {
} }
} }
self.vel += (mag * self.dir - self.drag * self.vel.length() * self.vel) * get_frame_time(); self.vel += (mag * self.dir - self.drag * self.vel.length() * self.vel);
self.pos += self.vel * get_frame_time(); self.pos += self.vel;
if self.pos.x.abs() > screen_width() / 2. + 10. { if self.pos.x.abs() > screen_width() / 2. + 10. {
self.pos.x *= -1.; self.pos.x *= -1.;
} }
@ -125,7 +125,7 @@ struct Bullet {
impl Bullet { impl Bullet {
fn update(&mut self) { fn update(&mut self) {
self.pos += self.vel * get_frame_time(); self.pos += self.vel;
} }
fn draw(&self) { fn draw(&self) {
draw_circle(self.pos.x, self.pos.y, 2., WHITE); draw_circle(self.pos.x, self.pos.y, 2., WHITE);