Skip to content

Implementation of state pattern in Python for games or other things

License

Notifications You must be signed in to change notification settings

GitRenhl/State-Machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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()

About

Implementation of state pattern in Python for games or other things

Topics

Resources

License

Stars

Watchers

Forks

Languages