State

class game_state.State

The State class which works as an individual screen.

Attributes:
state_name: str

The name of the state. Has to be unique among other states.

window: pygame.Surface

The main game window.

manager: StateManager

The manager to which the state is binded to.

on_setup()

This listener is only called once while being loaded into the StateManager. This is also called when reloading the State. :rtype: None

Warning

This method need not be called manually.

on_enter(prevous_state)

This listener is called once when a state has been switched and is entering the current state.

Warning

This method need not be called manually.

Parameters:

prevous_state (Optional[State]) –

The state that was running previously. If there are no previous states,
None is passed

Return type:

None

on_leave(next_state)

This listener is called once when the state has been switched and is exiting the current one.

Warning

This method need not be called manually.

Parameters:

next_state (State) –

The next state that is going to be applied.

Return type:

None

process_event(event)

To be called when a pygame event needs to be processed.

Note

This method needs to be called manually.

Parameters:

event (Event) –

The pygame event object.

Return type:

None

process_update(*args)

The main game loop method to be executed by the StateManager.

Note

This method needs to be called manually.

Parameters:

*args (Any) –

The arguments to be passed on to the update counter.

Return type:

None