pub fn wait_frame(&mut self) {
        let mut captured_keyboard: Vec<KeyEvent> = vec![];
        let mut captured_mouse: Vec<MouseEvent> = vec![];

        // if there is time before next frame, poll keyboard and mouse events until next frame
        let mut elapsed_time = self.instant.elapsed();
        while self.time_limit > elapsed_time {
            let remaining_time = self.time_limit - elapsed_time;
            if event::poll(std::time::Duration::from_millis(
                (remaining_time.as_millis() % self.time_limit.as_millis()) as u64,
            ))
            .unwrap()
            {
                match event::read().unwrap() {
                    Event::Key(evt) => {
                        captured_keyboard.push(evt);
                    }
                    Event::Mouse(evt) => {
                        captured_mouse.push(evt);
                    }
                    // we ignore resize events for now
                    Event::Resize(_w, _h) => {}
                };
            }
            elapsed_time = self.instant.elapsed();
        }
        self.instant = std::time::Instant::now();
        self.frame_count += 1;

        // updates pressed / held / released states
        let held = utils::intersect(
            &utils::union(&self.keys_pressed, &self.keys_held),
            &captured_keyboard,
        );
        self.keys_released = utils::outersect_left(&self.keys_held, &held);
        self.keys_pressed = utils::outersect_left(&captured_keyboard, &held);
        self.keys_held = utils::union(&held, &self.keys_pressed);
        self.mouse_events = captured_mouse;
    }
/// Pause the execution until the next frame need to be rendered  
/// Internally gets user's input for the next frame
///
/// usage:
/// ```
/// // initializes a screen with a 10x10 screen and targetting 30 fps
/// let mut engine = console_engine::ConsoleEngine::init(10, 10, 30);
/// loop {
///     engine.wait_frame(); // wait for next frame
///     // do your stuff
/// }
/// ```
Pause the execution until the next frame need to be rendered
Internally gets user's input for the next frame


Pause the execution until the next frame need to be rendered Internally gets user ' s input for the next frame
pub fn wait_frame(&mut self) {
        let mut captured_keyboard: Vec<KeyEvent> = vec![];
        let mut captured_mouse: Vec<MouseEvent> = vec![];
        // if there is time before next frame, poll keyboard and mouse events until next frame
        let mut elapsed_time = self.instant.elapsed();
        while self.time_limit > elapsed_time {
            let remaining_time = self.time_limit - elapsed_time;
            if event::poll(std::time::Duration::from_millis(
                (remaining_time.as_millis() % self.time_limit.as_millis()) as u64,
            ))
            .unwrap()
            {
                match event::read().unwrap() {
                    Event::Key(evt) => {
                        captured_keyboard.push(evt);
                    }
                    Event::Mouse(evt) => {
                        captured_mouse.push(evt);
                    }
                    // we ignore resize events for now
                    Event::Resize(_w, _h) => {}
                };
            }
            elapsed_time = self.instant.elapsed();
        }
        self.instant = std::time::Instant::now();
        self.frame_count += 1;
        // updates pressed / held / released states
        let held = utils::intersect(
            &utils::union(&self.keys_pressed, &self.keys_held),
            &captured_keyboard,
        );
        self.keys_released = utils::outersect_left(&self.keys_held, &held);
        self.keys_pressed = utils::outersect_left(&captured_keyboard, &held);
        self.keys_held = utils::union(&held, &self.keys_pressed);
        self.mouse_events = captured_mouse;
    }
pub fn wait_frame ( & mut self ) { let mut captured_keyboard : Vec < KeyEvent > = vec ! [ ] ; let mut captured_mouse : Vec < MouseEvent > = vec ! [ ] ; // if there is time before next frame, poll keyboard and mouse events until next frame let mut elapsed_time = self . instant . elapsed ( ) ; while self . time_limit > elapsed_time { let remaining_time = self . time_limit - elapsed_time ; if event :: poll ( std :: time :: Duration :: from_millis ( ( remaining_time . as_millis ( ) % self . time_limit . as_millis ( ) ) as u64 , ) ) . unwrap ( ) { match event :: read ( ) . unwrap ( ) { Event :: Key ( evt ) => { captured_keyboard . push ( evt ) ; } Event :: Mouse ( evt ) => { captured_mouse . push ( evt ) ; } // we ignore resize events for now Event :: Resize ( _w , _h ) => { } } ; } elapsed_time = self . instant . elapsed ( ) ; } self . instant = std :: time :: Instant :: now ( ) ; self . frame_count += 1 ; // updates pressed / held / released states let held = utils :: intersect ( & utils :: union ( & self . keys_pressed , & self . keys_held ) , & captured_keyboard , ) ; self . keys_released = utils :: outersect_left ( & self . keys_held , & held ) ; self . keys_pressed = utils :: outersect_left ( & captured_keyboard , & held ) ; self . keys_held = utils :: union ( & held , & self . keys_pressed ) ; self . mouse_events = captured_mouse ; }
Pause the execution until the next frame need to be rendered
Internally gets user's input for the next frame
Pause the execution until the next frame need to be rendered Internally gets user ' s input for the next frame
&mut self
&mut self