Dolda2000 GitWeb
/
kaka
/
rust-sdl-test.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
7991463
)
Character is pushed up when within ground
author
Tomas Wenström
<tomas.wenstrom@gmail.com>
Sat, 30 Jan 2021 15:10:53 +0000
(16:10 +0100)
committer
Tomas Wenström
<tomas.wenstrom@gmail.com>
Sat, 30 Jan 2021 15:10:53 +0000
(16:10 +0100)
src/core/game.rs
patch
|
blob
|
blame
|
history
diff --git
a/src/core/game.rs
b/src/core/game.rs
index
e8893de
..
36e6ed5
100644
(file)
--- a/
src/core/game.rs
+++ b/
src/core/game.rs
@@
-165,11
+165,12
@@
impl Object for Character {
let x = (self.pos.x / lvl.grid.cell_size as f64).min(lvl.grid.width as f64 - 1.0).max(0.0) as usize;
let y = (self.pos.y / lvl.grid.cell_size as f64).min(lvl.grid.height as f64 - 1.0).max(0.0) as usize;
let x = (self.pos.x / lvl.grid.cell_size as f64).min(lvl.grid.width as f64 - 1.0).max(0.0) as usize;
let y = (self.pos.y / lvl.grid.cell_size as f64).min(lvl.grid.height as f64 - 1.0).max(0.0) as usize;
+ self.vel += lvl.gravity;
if lvl.grid.cells[x][y] {
if lvl.grid.cells[x][y] {
- self.vel += lvl.gravity;
if self.vel.y > 0.0 && !(ctrl.mov.down() && ctrl.jump.is_pressed) {
self.vel.y = 0.0;
self.vel.x *= 0.9;
if self.vel.y > 0.0 && !(ctrl.mov.down() && ctrl.jump.is_pressed) {
self.vel.y = 0.0;
self.vel.x *= 0.9;
+ self.pos.y -= 1.0;
}
if !ctrl.mov.down() {
}
if !ctrl.mov.down() {
@@
-177,8
+178,6
@@
impl Object for Character {
self.vel.y = -5.0;
}
}
self.vel.y = -5.0;
}
}
- } else {
- self.vel += lvl.gravity;
}
self.pos += self.vel;
}
self.pos += self.vel;