Skip to content

Quinny/MonsterFighter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pokemon Engine Clone

A clone of the Pokemon game engine I made for fun during my kid's nap times on paternity leave.

Code Structure

Scenes

Each distinct screen is called a "scene" and can be found in the /scenes/ folder. Scenes have 4 mandatory interface methods:

  1. 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 battle
  2. render - Draw the state of the scene to the screen
  3. scene_transition - Optionally return a transition object 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 pokemon
  4. refocus - reset any required state when a scene comes back into focus. E.g. after a battle ends when the overworld comes back into view

Scene Manager

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

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.

About

A clone of the Pokemon game engine made for fun

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages