Verbessere Formatierung und Fehlerbehandlung im Ball-Update und der Eingabeverarbeitung
Some checks failed
Continuous integration / Test Suite (push) Has been cancelled
Continuous integration / Rustfmt (push) Has been cancelled
Continuous integration / Clippy (push) Has been cancelled
Continuous integration / build (push) Has been cancelled
Continuous integration / Check (push) Has been cancelled
Some checks failed
Continuous integration / Test Suite (push) Has been cancelled
Continuous integration / Rustfmt (push) Has been cancelled
Continuous integration / Clippy (push) Has been cancelled
Continuous integration / build (push) Has been cancelled
Continuous integration / Check (push) Has been cancelled
This commit is contained in:
10
src/main.rs
10
src/main.rs
@ -112,7 +112,9 @@ impl Ball {
|
|||||||
self.color = [
|
self.color = [
|
||||||
0.2 + 0.8 * (self.position[0].abs() / bounds_x),
|
0.2 + 0.8 * (self.position[0].abs() / bounds_x),
|
||||||
0.2 + 0.8 * (self.position[1].abs() / bounds_y),
|
0.2 + 0.8 * (self.position[1].abs() / bounds_y),
|
||||||
0.2 + 0.6 * ((self.position[0].abs() + self.position[1].abs()) / (bounds_x + bounds_y)),
|
0.2 + 0.6
|
||||||
|
* ((self.position[0].abs() + self.position[1].abs())
|
||||||
|
/ (bounds_x + bounds_y)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
// if the y position plus the radius is greater than the bounds_y or the y position minus the radius is less than -bounds_y, then bounce off the wall
|
// if the y position plus the radius is greater than the bounds_y or the y position minus the radius is less than -bounds_y, then bounce off the wall
|
||||||
@ -124,7 +126,9 @@ impl Ball {
|
|||||||
self.color = [
|
self.color = [
|
||||||
0.2 + 0.8 * (self.position[0].abs() / bounds_x),
|
0.2 + 0.8 * (self.position[0].abs() / bounds_x),
|
||||||
0.2 + 0.8 * (self.position[1].abs() / bounds_y),
|
0.2 + 0.8 * (self.position[1].abs() / bounds_y),
|
||||||
0.2 + 0.6 * ((self.position[0].abs() + self.position[1].abs()) / (bounds_x + bounds_y)),
|
0.2 + 0.6
|
||||||
|
* ((self.position[0].abs() + self.position[1].abs())
|
||||||
|
/ (bounds_x + bounds_y)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -561,7 +565,7 @@ impl ApplicationHandler for App {
|
|||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(wgpu::SurfaceError::Lost) => state.resize(state.size),
|
Err(wgpu::SurfaceError::Lost) => state.resize(state.size),
|
||||||
Err(wgpu::SurfaceError::OutOfMemory) => event_loop.exit(),
|
Err(wgpu::SurfaceError::OutOfMemory) => event_loop.exit(),
|
||||||
Err(e) => eprintln!("{:?}", e),
|
Err(e) => eprintln!("{e:?}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request another frame for continuous animation
|
// Request another frame for continuous animation
|
||||||
|
Reference in New Issue
Block a user