-
Notifications
You must be signed in to change notification settings - Fork 0
The Engine
The Unnamed engine is an hobby project build using java.
This chapter will explore the basic internal working of the engine.
The engine has three main input states including NONE, GAME and GUI
This input state has no effect and only allows the force quit command (LEFT_CTRL + LEFT_ALT + Q). While the engine starts up in this mode, it should never be reached during a normal application cycle.
The game input state is the most complex input state as well as the state that the developer must add actions to. This state handles all gameplay related inputs such as interactions, camera movement, etc. These actions are added as events and are executed in the order of creation. These events include the interfaces that can be found here. Of these I prefer to use the IInputHandler but this is just personal preference.
The gui input state pass all inputs to the NiftyGui library for handeling. Just note that custom input events such as the ones described in the Game state above, will not work. Therefor all interaction should be done via the GUI.
Timer events are registered through the custom Timer class by calling one of three methods depending on the frequency of the required task. New tasks can be registered from everywhere in the codebase but will only execute if a valid Timer instance is running.
Timer frequencies:
- Once off:
registerNewOnceOffEventMillis(long timeToCompletionMillis, ITimedEvent event) - Repeat for 'n' times:
registerNewRepeatEventMillis(long timeToCompletionMillis, int amountOfRepeats, ITimedEvent event) - Repeat indefinitely:
registerNewInfiniteRepeatEventMillis(long timeToCompletionMillis, int amountOfRepeats, ITimedEvent event)
Logic events describe a core engine functionality. As of this moment there is IInputHandler, IResizeHandler, IDisposeHandler, IUpdateHandler. Any class can subscribe to these events by calling the register function pertaining to the specific event if the class implements the corresponding Handler interface. The methods added to these classes are then automatically called from the main game loop when applicable etc. dispose() on the disposal of the program and onResize(int width, int height) on any window resize event.
Events handles
-
IInputHandler
handleInput(Input input, float deltaTime)Process input events here. -
IResizeHandler
onResize(int width, int height)Handle window resize events here. -
IDisposeHandler
dispose()Dispose objects here. Called on program stop. -
IUpdateHandler
update(float delta)Called every frame while the object is registered as an IUpdateHandler.