[][src]Struct mief::elements::field::Field

pub struct Field {
    ball: Ball,
    last_speed_change: f64,
    players: [Player; 2],
    height: u32,
    width: u32,
}

The field where the game actually occurs.

Fields

ball: Ball

The ball used for playing.

last_speed_change: f64

The Δt since the last speed change.

players: [Player; 2]

The players.

height: u32

The height of the field.

width: u32

The width of the field.

Methods

impl Field[src]

pub fn new(size: [u32; 2]) -> Field[src]

Initialize a new playing field with the given size.

pub fn get_player_scores(&self) -> [isize; 2][src]

Get the scores of all players.

pub fn on_button_pressed(&mut self, button: Button)[src]

Handle button press events.

pub fn on_button_released(&mut self, button: Button)[src]

Handle button release events.

pub fn on_render(&self, context: Context, graphics: &mut G2d)[src]

Draw the field with its contents.

pub fn on_resize(&mut self, new_width: u32, new_height: u32)[src]

Resize the field.

pub fn on_update(&mut self, update_arguments: &UpdateArgs)[src]

Update the field state.

fn update_scores(&mut self, status: BallStatus)[src]

If the ball left the field on the left or right side, the other side's player will get a point.