.. A7 GameApp class .. _game-label: Class GameApp ============= This is the primary class for creating a game. To implement a game, you subclass this class and override three methods. The three methods are as follows: **start**: This method initializes the game state, defining all of the game attributes. This method is like `__init__` except that you should not override that method. Overriding `__init__` will break your game. Hence we have provided build as an alternative. **update**: This method updates the game state at the start of every animation frame. Any code that moves objects or processes user input (keyboard or mouse) goes in this method. **draw**: This method draws all of the objects to the screen. The only thing you should have in this method are calls to `self.view.draw()`. Constructor ----------- .. autoclass:: game2d.app.GameApp Immutable Attributes -------------------- These attributes may be read (e.g. used in an expression), but not altered. .. currentmodule:: game2d.app .. autoattribute:: GameApp.view .. autoattribute:: GameApp.width .. autoattribute:: GameApp.height .. autoattribute:: GameApp.fps Methods ------- Methods to Override ~~~~~~~~~~~~~~~~~~~ You will need to replace all of these methods in your subclass. .. automethod:: GameApp.start .. automethod:: GameApp.update .. automethod:: GameApp.draw Methods to Inherit ~~~~~~~~~~~~~~~~~~ You should never override these methods. .. automethod:: GameApp.run .. automethod:: GameApp.stop :ref:`Return to top level <top-label>`