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 (parent:
4a7f4e2
)
Adjust the boll collisions
author
Tomas Wenström
<tomas.wenstrom@gmail.com>
Sun, 24 Jan 2021 20:44:50 +0000
(21:44 +0100)
committer
Tomas Wenström
<tomas.wenstrom@gmail.com>
Sun, 24 Jan 2021 20:44:50 +0000
(21:44 +0100)
src/core/game.rs
patch
|
blob
|
blame
|
history
diff --git
a/src/core/game.rs
b/src/core/game.rs
index
429a2ee
..
1e657cb
100644
(file)
--- a/
src/core/game.rs
+++ b/
src/core/game.rs
@@
-1,5
+1,5
@@
use AppState;
use AppState;
-use common::
Point2D
;
+use common::
{Point2D, Radians}
;
use core::controller::Controller;
use core::controller::ControllerManager;
use core::level::Level;
use core::controller::Controller;
use core::controller::ControllerManager;
use core::level::Level;
@@
-253,12
+253,14
@@
impl Object for Boll {
if self.bounces == 0 {
return Dead
}
if self.bounces == 0 {
return Dead
}
- self.vel *= -0.5;
+ self.vel *= -0.25;
+ self.pos += self.vel;
self.bounces -= 1;
use rand::distributions::{Distribution, Normal};
self.bounces -= 1;
use rand::distributions::{Distribution, Normal};
- let normal = Normal::new(0.5, 0.4);
+ 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 {
objects.push(Box::new(Boll {
- vel:
self.vel * normal.sample(&mut rand::thread_rng()
),
+ vel:
Point2D::from(a) * Normal::new(1.0, 0.25).sample(&mut rng) * self.vel.length(
),
..*self
}));
}
..*self
}));
}