pub trait Boll {
fn update(&mut self);
- fn draw(&mut self, canvas: &mut Canvas<Window>, size: u32);
+ fn draw(&self, canvas: &mut Canvas<Window>, size: u32);
}
pub struct SquareBoll {
}
}
- fn draw(&mut self, canvas: &mut Canvas<Window>, size: u32) {
+ fn draw(&self, canvas: &mut Canvas<Window>, size: u32) {
canvas.set_draw_color(Color::RGBA(
255 - std::cmp::min(255, (self.vel.length() * 25.0) as u8),
(255.0 * (self.pos.x / SCREEN_WIDTH as f64)) as u8,
self.boll.update();
}
- fn draw(&mut self, canvas: &mut Canvas<Window>, size: u32) {
+ fn draw(&self, canvas: &mut Canvas<Window>, size: u32) {
let val = 255 - std::cmp::min(255, (self.boll.vel.length() * 20.0) as u8);
canvas.filled_circle(self.boll.pos.x as i16, self.boll.pos.y as i16, size as i16, Color::RGBA(
val,