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

Timing Mechanism for Pausing/Unpausing game #8

Closed
obscurelyme opened this issue Oct 3, 2021 · 4 comments · Fixed by #36
Closed

Timing Mechanism for Pausing/Unpausing game #8

obscurelyme opened this issue Oct 3, 2021 · 4 comments · Fixed by #36
Labels
enhancement New feature or request utility

Comments

@obscurelyme
Copy link
Owner

CoffeeMaker needs a way to pause/unpause the game. I think that the best way to do this will be to leverage timers. All game entities will use a game timer to progress their state. When the game is paused so too will the game entities.

@obscurelyme obscurelyme added enhancement New feature or request utility labels Oct 3, 2021
@obscurelyme obscurelyme linked a pull request Oct 21, 2021 that will close this issue
@obscurelyme
Copy link
Owner Author

A global timer was used. It gets reset after each update step in the core game loop. Scenes will inject a deltaTime float into any Update method (which now accepts a floating point value).

@obscurelyme
Copy link
Owner Author

Another learning experience here is that SDL_USEREVENT. CoffeeMaker has some additional event loop implementation that looks to be a bit naive. I'd rather take advantage of SDL's event loop instead. SDL_USEREVENT gives CoffeeMaker that option.

So far with the working PR, I have 4 generic Game events.

  • GAME_PAUSE
  • GAME_UNPAUSE
  • SCENE_LOAD
  • SCENE_UNLOAD

These events, along side a PushCoffeeMakerEvent function means that the engine can theoretically push any event into SDL's loop that it will understand and take action on. When it comes time to introduce Audio (which may require multithreading) This will be the preferred solution as opposed to spinning up threads manually.

@obscurelyme
Copy link
Owner Author

@obscurelyme
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request utility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant