A clone of the Pokemon game engine I made for fun during my kid's nap times on paternity leave.
![]() |
![]() |
Each distinct screen is called a "scene" and can be found in the /scenes/ folder. Scenes have 4 mandatory interface methods:
update- Given all the events (keystrokes, mouse movements, etc.) that happened since the last frame, update the state of the scene. E.g. if the user picked a move to use in a battlerender- Draw the state of the scene to the screenscene_transition- Optionally return atransitionobject that directs the engine to switch to a new scene. E.g. the overworld scene would transition to a battle scene if you run into a wild pokemonrefocus- reset any required state when a scene comes back into focus. E.g. after a battle ends when the overworld comes back into view
graphics_main.py acts as the scene manager. Scenes are stored in a stack, with the scene at the top
of the stack being the "active" scene. The update method is only invoked on the active scene, the rest are frozen
and only rendered to preserve layering.
When a scene requests a transition to occur, the new scene is pushed to the stack. Returning a None value for the new
scene triggers the stack to be popped instead, and the previous active scene will be refocused.
Transitions run as coroutines along side the game loop. They expose surface and done methods.
When transitions are running the active scene will stop getting update calls, and the transition surface will be
drawn on top of the rendered active scene until it finishes. Once the transition finishes, the new scene will become
active.

