Aaron Franke f9e7456b70 Add descriptions to all projects with README files há 5 anos atrás
..
debug 9975c95065 Update Finite State Machine demo há 5 anos atrás
fonts 5b744fa1e6 Add HFSM + pushdown automaton demo há 7 anos atrás
player dda0bd7e20 Update other 2D demos for Godot 3.2 há 5 anos atrás
screenshots a24ac796b6 Add README files to 2D demos há 5 anos atrás
state_machine 222f94444a Fix incorrect comment in hierarchical FSM demo script há 5 anos atrás
Demo.tscn 9975c95065 Update Finite State Machine demo há 5 anos atrás
README.md a24ac796b6 Add README files to 2D demos há 5 anos atrás
default_env.tres a45b84a5ad Handle multiple resolutions in most demos há 5 anos atrás
icon.png 184b0fe5f8 Optimize all images using `oxipng -o6 --strip all --zopfli` há 6 anos atrás
icon.png.import a45b84a5ad Handle multiple resolutions in most demos há 5 anos atrás
project.godot f9e7456b70 Add descriptions to all projects with README files há 5 anos atrás

README.md

Hierarchical Finite State Machine

This example shows how to apply the State machine programming pattern in GDscript, including Hierarchical States, and a pushdown automaton.

Language: GDScript

Renderer: GLES 2

Why use a state machine

States are common in games. You can use the pattern to:

  1. Separate each behavior and transitions between behaviors, thus make scripts shorter and easier to manage.

  2. Respect the Single Responsibility Principle. Each State object represents one action.

  3. Improve your code's structure. Look at the scene tree and FileSystem tab: without looking at the code, you'll know what the Player can or cannot do.

You can read more about States in the excellent Game Programming Patterns ebook.

Screenshots

Screenshot