• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..09-Jul-2020-

debug/H09-Jul-2020-146122

fonts/H03-May-2022-2616

player/H03-May-2022-924736

screenshots/H07-May-2022-

state_machine/H09-Jul-2020-10473

Demo.tscnH A D09-Jul-2020804 2617

README.mdH A D09-Jul-2020856 3119

icon.png.importH A D09-Jul-2020640 3529

project.godotH A D09-Jul-20206 KiB10490

README.md

1# Hierarchical Finite State Machine
2
3This example shows how to apply the State machine programming
4pattern in GDscript, including Hierarchical States, and a
5pushdown automaton.
6
7Language: GDScript
8
9Renderer: GLES 2
10
11## Why use a state machine
12
13States are common in games. You can use the pattern to:
14
151. Separate each behavior and transitions between behaviors,
16   thus make scripts shorter and easier to manage.
17
182. Respect the Single Responsibility Principle.
19   Each State object represents one action.
20
213. Improve your code's structure. Look at the scene tree and
22   FileSystem tab: without looking at the code, you'll know
23   what the Player can or cannot do.
24
25You can read more about States in the excellent
26[Game Programming Patterns ebook](https://gameprogrammingpatterns.com/state.html).
27
28## Screenshots
29
30![Screenshot](screenshots/fsm-attack.png)
31