[][src]Struct evolution::State

struct State {
    config: Config,
    rng: ThreadRng,
    fish: Vec<Fish>,
    food: Vec<Food>,
    poison: Vec<Food>,
    fish_image: Image,
}

The application state that keeps track of all configurations and entities of the simulation

Fields

config: Config

The configuration information set from config.ron when the program was executed

rng: ThreadRng

Random number generator

fish: Vec<Fish>

A collection of fish

food: Vec<Food>

A collection of food

poison: Vec<Food>

A collection of poison

fish_image: Image

The spritesheet of the fish used for its animation

Methods

impl State[src]

fn new(ctx: &mut Context, config: Config) -> GameResult<State>[src]

Creates a new instance of the application state

fn add_food(food: &mut Vec<Food>, config: &Config, rng: &mut ThreadRng)[src]

Adds a peice of food to the collection

Trait Implementations

impl EventHandler for State[src]

fn update(&mut self, _ctx: &mut Context) -> GameResult[src]

Updates all elements of the current application state

fn draw(&mut self, ctx: &mut Context) -> GameResult[src]

Draws all elements of the current application state

fn mouse_button_down_event(
    &mut self,
    _ctx: &mut Context,
    _button: MouseButton,
    _x: f32,
    _y: f32
)

A mouse button was pressed

fn mouse_button_up_event(
    &mut self,
    _ctx: &mut Context,
    _button: MouseButton,
    _x: f32,
    _y: f32
)

A mouse button was released

fn mouse_motion_event(
    &mut self,
    _ctx: &mut Context,
    _x: f32,
    _y: f32,
    _dx: f32,
    _dy: f32
)

The mouse was moved; it provides both absolute x and y coordinates in the window, and relative x and y coordinates compared to its last position. Read more

fn mouse_wheel_event(&mut self, _ctx: &mut Context, _x: f32, _y: f32)

The mousewheel was scrolled, vertically (y, positive away from and negative toward the user) or horizontally (x, positive to the right and negative to the left). Read more

fn key_down_event(
    &mut self,
    ctx: &mut Context,
    keycode: VirtualKeyCode,
    _keymods: KeyMods,
    _repeat: bool
)

A keyboard button was pressed. Read more

fn key_up_event(
    &mut self,
    _ctx: &mut Context,
    _keycode: VirtualKeyCode,
    _keymods: KeyMods
)

A keyboard button was released.

fn text_input_event(&mut self, _ctx: &mut Context, _character: char)

A unicode character was received, usually from keyboard input. This is the intended way of facilitating text input. Read more

fn gamepad_button_down_event(
    &mut self,
    _ctx: &mut Context,
    _btn: Button,
    _id: GamepadId
)

A gamepad button was pressed; id identifies which gamepad. Use input::gamepad() to get more info about the gamepad. Read more

fn gamepad_button_up_event(
    &mut self,
    _ctx: &mut Context,
    _btn: Button,
    _id: GamepadId
)

A gamepad button was released; id identifies which gamepad. Use input::gamepad() to get more info about the gamepad. Read more

fn gamepad_axis_event(
    &mut self,
    _ctx: &mut Context,
    _axis: Axis,
    _value: f32,
    _id: GamepadId
)

A gamepad axis moved; id identifies which gamepad. Use input::gamepad() to get more info about the gamepad. Read more

fn focus_event(&mut self, _ctx: &mut Context, _gained: bool)

Called when the window is shown or hidden.

fn quit_event(&mut self, _ctx: &mut Context) -> bool

Called upon a quit event. If it returns true, the game does not exit (the quit event is cancelled). Read more

fn resize_event(&mut self, _ctx: &mut Context, _width: f32, _height: f32)

Called when the user resizes the window, or when it is resized via graphics::set_mode(). Read more

Auto Trait Implementations

impl !Send for State

impl !Sync for State

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,