[][src]Struct mief::elements::player::Player

pub struct Player {
    field_side: FieldSide,
    movement: Movement,
    position: (f64, f64),
    score: isize,
    size: (f64, f64),
    speed: f64,
}

The player.

Fields

field_side: FieldSide

The player's position on the field.

movement: Movement

The current direction of movement.

position: (f64, f64)

The current position of the player: (x, y).

score: isize

The points the player achieved so far.

size: (f64, f64)

The size of the player's handle: (width, height).

speed: f64

The current speed of the player (the player can only move in y-direction).

Methods

impl Player[src]

pub fn new(side: FieldSide, field_width: u32) -> Player[src]

Create a new player at position (x, y).

pub fn change_speed(&mut self, amount: f64)[src]

Change the player's speed by the given amount.

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

Draw the player.

pub fn get_bounding_box(&self) -> [f64; 4][src]

Get the bounding box of the player's handle.

pub fn get_score(&self) -> isize[src]

Get the player's current score.

pub fn set_movement(&mut self, movement: Movement)[src]

Move the player.

pub fn update(&mut self, dt: f64, height: u32)[src]

Update the player's position.

pub fn update_score(&mut self, additional_points: isize)[src]

Update the player's score with additional_points.

If the new score would overflow (in either direction), the score is set to isize::MAX or isize::MIN, respectively.

pub fn update_position(&mut self, new_field_width: u32)[src]

Update the player's position depending on the new width of the field.