ControlObjectBehavior

Trait ControlObjectBehavior 

Source
pub trait ControlObjectBehavior<Img, Snd, Fnt, Spr, Rm, Data>: ControlObjectBehaviorClone<Img, Snd, Fnt, Spr, Rm, Data>{
    // Required method
    fn data(&self) -> Data;

    // Provided methods
    fn handle_sdl_event(&mut self, _event: &Event) { ... }
    fn update(
        &mut self,
        _delta: f64,
        _cur_room: &Rm,
        _others: &Vec<Box<dyn ControlObjectBehavior<Img, Snd, Fnt, Spr, Rm, Data>>>,
        _room_objs: &Vec<Box<dyn GameObjectBehavior<Img, Snd, Fnt, Spr, Rm, Data>>>,
    ) -> (Option<Rm>, Vec<Box<dyn GameObjectBehavior<Img, Snd, Fnt, Spr, Rm, Data>>>) { ... }
    fn render(
        &mut self,
        _cnv: &mut Canvas<Window>,
        _cur_room: &Rm,
        _imgs: &HashMap<Img, Image<'_>>,
        _snds: &HashMap<Snd, Sound<'_>>,
        _fonts: &HashMap<Fnt, Font<'_, '_>>,
        _creator: &TextureCreator<WindowContext>,
        _elapsed: f64,
    ) -> Result<(), String> { ... }
}
Expand description

Control objects are basically game objects, but they are aware of the current room and do not possess colliders. They are the way for doing dynamic memory

Required Methods§

Source

fn data(&self) -> Data

Provided Methods§

Source

fn handle_sdl_event(&mut self, _event: &Event)

Source

fn update( &mut self, _delta: f64, _cur_room: &Rm, _others: &Vec<Box<dyn ControlObjectBehavior<Img, Snd, Fnt, Spr, Rm, Data>>>, _room_objs: &Vec<Box<dyn GameObjectBehavior<Img, Snd, Fnt, Spr, Rm, Data>>>, ) -> (Option<Rm>, Vec<Box<dyn GameObjectBehavior<Img, Snd, Fnt, Spr, Rm, Data>>>)

Source

fn render( &mut self, _cnv: &mut Canvas<Window>, _cur_room: &Rm, _imgs: &HashMap<Img, Image<'_>>, _snds: &HashMap<Snd, Sound<'_>>, _fonts: &HashMap<Fnt, Font<'_, '_>>, _creator: &TextureCreator<WindowContext>, _elapsed: f64, ) -> Result<(), String>

Trait Implementations§

Source§

impl<Img, Snd, Fnt, Spr, Rm, Data> Clone for Box<dyn ControlObjectBehavior<Img, Snd, Fnt, Spr, Rm, Data>>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§