![]() ![]() RenderSurface = Surface((self._renderWidth, self._renderHeight)) The new implementations of the Game Loop methods call the similar method in the current game mode (if any): def processInput (self): for event in ():ĭef update (self): if self._gameMode is not None: In the other case, we have to store and copy this data every time. It is handier to refer to an instance of this class in all UI components. The Theme class contains all data related to the user interface, like the size of tiles or tilesets. They will work with no change to the UserInterface class. Later, we will create other implementations with new features. We create this class to edit the ground layer. The EditGameMode class is one implementation of the GameMode abstract class. For instance, the render() method calls the game mode to get a rendering (world, menu, etc.) and then rescales to window size. It runs all the low-level processing and calls an implementation of the GameMode abstract class for the high-level processing. The UserInterface class still has the Game Loop patterns methods. We can solve these issues with the following design: We can do the same reasoning for input processing and state updating in the current game implementation, they do nothing, but later, we will face the same problem as the rendering. Rescaling is low-level processing that does not depend on context: whatever we render, we always have to rescale to the window size. World rendering is high-level processing that depends on context (playing, editing, menu, etc.). The last step runs two processing: world rendering and rescaling. render(): render the world and rescale to window size.update(): updates game state (nothing right now).processInput(): parses low-level input events (only exit, nothing specific to the game for now).Main game loop: repeatedly calls the Game Loop pattern methods.Here is the list of what this class current does: As usual, we want to split classes with too many features. In the current state of our game, the UserInterface class is the single class that handles what is related to the user interface. This post is part of the 2D Strategy Game series Theme and game mode Separate low-level and high-level processing As usual, I propose a nice design to implement this! I add mouse handling to edit the ground tiles. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |