use {SCREEN_HEIGHT, SCREEN_WIDTH};
use common::Point2D;
-pub struct Boll {
+pub trait Boll {
+ fn update(&mut self);
+ fn draw(&mut self, canvas: &mut Canvas<Window>, size: u32);
+}
+
+pub struct SquareBoll {
pub pos: Point2D<f64>,
pub vel: Point2D<f64>,
}
-impl Boll {
- pub fn update(&mut self) {
+impl Boll for SquareBoll {
+ fn update(&mut self) {
self.vel.y += 0.1;
self.pos += self.vel;
}
}
- pub fn draw(&mut self,canvas: &mut Canvas<Window>, size: u32) {
+ fn draw(&mut 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,