Update engine class to make this engine a state based engine

State based engines run different code depending on the state of this
engine. This is useful for controlling different parts of the program
(e.g. the main menu, the loading screen). If the state is unspecified,
throws an IllegalStateException specifying the illegal state.