pub async fn run(
        mut self,
        terminal: &mut Terminal,
        tick: Duration,
    ) -> Result<EndKind, Error> {
        // Interval between ticks.
        let mut interval = time::interval(tick);
        loop {
            match self.state {
                State::Running => {
                    // Immediately acquires a terminal locked session.
                    let mut session = terminal.lock_now().await?;
                    // Let's interact with the event, change state, and see if
                    // it ended.
                    self.tick(session.event());
                    // But before, we will render what we have.
                    self.render(&mut session.screen());
                },

                State::BadScreen => {
                    let mut session = terminal.lock_now().await?;
                    // If there is an event, it potentially resized the screen
                    // to a valid size.
                    if let Some(event) = session.event() {
                        self.restricted_event(event);
                    }
                },

                // Game ended so we can stop the loop.
                State::Ended(end) => break Ok(end),
            }

            interval.tick().await;
        }
    }
/// Runs the game, given the initial state, terminal handle, and interval
/// between ticks.
Runs the game, given the initial state, terminal handle, and interval
between ticks.
Runs the game given the initial state terminal handle and interval between ticks .
pub async fn run(
        mut self,
        terminal: &mut Terminal,
        tick: Duration,
    ) -> Result<EndKind, Error> {
        // Interval between ticks.
        let mut interval = time::interval(tick);
        loop {
            match self.state {
                State::Running => {
                    // Immediately acquires a terminal locked session.
                    let mut session = terminal.lock_now().await?;
                    // Let's interact with the event, change state, and see if
                    // it ended.
                    self.tick(session.event());
                    // But before, we will render what we have.
                    self.render(&mut session.screen());
                },
                State::BadScreen => {
                    let mut session = terminal.lock_now().await?;
                    // If there is an event, it potentially resized the screen
                    // to a valid size.
                    if let Some(event) = session.event() {
                        self.restricted_event(event);
                    }
                },
                // Game ended so we can stop the loop.
                State::Ended(end) => break Ok(end),
            }
            interval.tick().await;
        }
    }
pub async fn run ( mut self , terminal : & mut Terminal , tick : Duration , ) -> Result < EndKind , Error > { // Interval between ticks. let mut interval = time :: interval ( tick ) ; loop { match self . state { State :: Running => { // Immediately acquires a terminal locked session. let mut session = terminal . lock_now ( ) . await ? ; // Let's interact with the event, change state, and see if // it ended. self . tick ( session . event ( ) ) ; // But before, we will render what we have. self . render ( & mut session . screen ( ) ) ; } , State :: BadScreen => { let mut session = terminal . lock_now ( ) . await ? ; // If there is an event, it potentially resized the screen // to a valid size. if let Some ( event ) = session . event ( ) { self . restricted_event ( event ) ; } } , // Game ended so we can stop the loop. State :: Ended ( end ) => break Ok ( end ) , } interval . tick ( ) . await ; } }
Runs the game, given the initial state, terminal handle, and interval
between ticks.
Runs the game given the initial state terminal handle and interval between ticks .
mut self
terminal
&mut Terminal
tick
Duration
mut self
terminal
&mut Terminal
tick
Duration