Module containing the base controller class.
Base controller class for the MVC pattern implementation.
Shouldn’t be instanciated manually but subclassed then registered in a State class.
Empty method to override.
Parameters: | event (Event) – a pygame event |
---|---|
Returns: | bool – True to stop the current state, False (or None) otherwise. |
An overwritten version of this method should regiser actions to the model.
Example:
def handle_event(event):
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
return self.model.register_up() # OR
# return self.register("up")
Note: It is probably a bad idea to return directly True since stopping the current state should be the model decision.
Empty method to override if needed.
Called at initialization.
Define what a quit event is. Include pygame.Quit and Alt+F4.
Can be overriden to include more quit events.
Parameters: | event (Event) – a pygame event |
---|---|
Returns: | bool – True if event is a quit event |
Convenience function to register an action to the model.
Parameters: |
|
---|---|
Returns: | bool – True to indicate that the model wants to stop the current state, False otherwise. |