Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Move terminal init and update logic out of main_loop #353

Open
sparr opened this issue Oct 22, 2023 · 0 comments
Open

Request: Move terminal init and update logic out of main_loop #353

sparr opened this issue Oct 22, 2023 · 0 comments

Comments

@sparr
Copy link

sparr commented Oct 22, 2023

I would like to be able to set up a terminal, then later run one iteration of the update loop at a time, from a loop under my own control, rather than having to surrender control to main_loop and only get control back in my code during tick.

Naively imagined, this might involve moving the top part of main_loop into a initialization function, then the function inside el.run (the event handlers, including the one that calls tock) into a separate function. Then main_loop for hal/native would look something like this:

pub fn main_loop<GS: GameState>(mut bterm: BTerm, mut gamestate: GS) -> BResult<()> {
    let el: EventLoop<()> = init_loop(bterm, gamestate);
    el.run(one_tick(bterm, gamestate));
}

and roughly equivalent changes in the other implementations of main_loop.

I expect it would actually be a bit more complex than this, but I hope this illustrates the idea. My goal would be to call init_loop myself, then later call one_tick once per tick in my own game loop.

@sparr sparr changed the title Request: Move terminal update logic out of main_loop Request: Move terminal init and update logic out of main_loop Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant