Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions userspace/programs/src/bounce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,18 @@ fn run_window_loop(win: &mut Window, spheres: &mut [Sphere; NUM_SPHERES]) {
Event::KeyPress { ascii, .. } => {
match ascii {
b'+' | b'=' => {
for sphere in spheres.iter_mut() { sphere.impel(); }
// Scale all velocities up by ~15%
for sphere in spheres.iter_mut() {
sphere.vx = sphere.vx * 23 / 20;
sphere.vy = sphere.vy * 23 / 20;
}
}
b'-' => {
for sphere in spheres.iter_mut() { sphere.dampen(); }
// Scale all velocities down by ~15%
for sphere in spheres.iter_mut() {
sphere.vx = sphere.vx * 20 / 23;
sphere.vy = sphere.vy * 20 / 23;
}
}
_ => {}
}
Expand Down
Loading