[−][src]Struct mief::elements::ball::Ball
The ball used for playing.
Fields
diameter: f64The diameter of the ball.
position: (f64, f64)The current position of the ball: (x, y).
speed: (f64, f64)The current speed of the ball: (x, y).
Methods
impl Ball[src]
pub fn new(window_size: [u32; 2]) -> Ball[src]
Create a new ball with a random speed at the center of the window (given by [width, height]).
pub fn change_speed(&mut self, amount: f64)[src]
Change the ball's speed by the given amount in both directions.
pub fn draw(&self, context: &Context, graphics: &mut G2d)[src]
Draw the ball.
pub fn update(
&mut self,
dt: f64,
width: u32,
height: u32,
obstacles: &[[f64; 4]]
) -> BallStatus[src]
&mut self,
dt: f64,
width: u32,
height: u32,
obstacles: &[[f64; 4]]
) -> BallStatus
Update the ball's position. dt is the change in time since the last update, width and height are the
window's size.
fn collide_with(&mut self, next_position: (f64, f64), object: &[f64; 4])[src]
Check if the ball will collide with object's bounding box at next_position and reverse the ball's
direction accordingly.