An introduction to finite state machines and the state pattern for game development