-
Notifications
You must be signed in to change notification settings - Fork 160
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
Implement "Game State" interface and several implementations #2332
Implement "Game State" interface and several implementations #2332
Conversation
Hey, great work, this looks very good! I noticed you split Run and Draw, is this done for some future where ticks (logic update) and fps (screen update) are somehow disconnected? More curious though, it's good because it helps to more quickly understand what's happening in that state. |
This is done generally to let call a substate update and substate drawing separately, from different places, or with some extra actions in between. But yes, if logic update and rendering will be disconnected, then these function also must be separate. Right now I'm still calling Draw from Run, but it should not be there in the end. |
620b839
to
d4dd94f
Compare
d4dd94f
to
d253e64
Compare
d253e64
to
e472892
Compare
Backported a fix for ShakeScreen to not use arbitrary Delay (from ags4), and made it into a game state. There are two checks remaining: blocking video playback and built-in dialogs. I think these two are better done as a separate PRs. |
This turns TopBarSettings, DisplayVars and display_message_aschar into function args.
This state runs while the game is in waiting loop, replaces RestrictUntil struct.
This refactors the blocking ShakeScreen to be running proper frame Waits and render with our fps, rather than doing platform->Delay() with hardcoded time. Keep using hardcoded shake delay and duration still, but use them as factors for calculating generic parameters.
d22f6fa
to
7e777b6
Compare
I don't know how to test the legacy inventory you mention but the other things appear to be working fine. Tested in test games and in a few AGS games I have. |
For #1349 (one of the steps). This work is not complete, but has enough material to make a draft PR.
Currently is based on top of #2223 for convenience.
The idea of this batch change is to have a GameState interface that defines, well, a game substate, which has its own Run and Draw methods; then create an implementation of GameState for each case where engine has an nested update/wait loop.
This particular PR does not "unwind" these nested loops yet, but reorganizes the code into classes. This prepares the code for an actual "unwinding" into the single main loop. In the end there likely will be a global pointer to the current GameState (or, if necessary, a stack of state pointers), and engine will operate with this GameState object right from the main update routine. But this is for the later.
What is done here:
Implemented following GameStates:
What is possibly left:
- ShakeScreen().UPDATE
I think these two remaining things are better done as a separate PRs.
For PlayVideo it may be a good idea to backport couple of first commits from #2338, with BlockingVideoPlayer class. which is practically a ready game state.
The dialogs are an annoying issue, because their message system likely have to be rewritten completely in order to make them suitable for the state machine logic.