Skip to content

Latest commit

 

History

History
27 lines (22 loc) · 701 Bytes

README.md

File metadata and controls

27 lines (22 loc) · 701 Bytes

State-Machine

This is python state pattern implementation for games or other things

How to use

  1. Clone repository https://github.com/GitRenhl/State-Machine.git
  2. Copy state folder to your project directory
  3. Import and code:
  4. Done

Example:

import state as StateManagment


class Game:
    def __init__(self):
        self.states = ("state_1", "state_2")

        state_dict = {
            self.states[0]: StateManagment.ExampleState1,
            self.states[1]: StateManagment.ExampleState2
        }
        self.game_state = StateManagment.StateMachine(self, state_dict)

        self.game_state.change('state_1')

    def update(self):
        self.game_state.update()