I may be able to work a little bit on my game engine during summer and I'm starting to investigate in which order the events in the main loop should be processed.
For the point of view of the user, everything seems to happen instantaneously but we know that it's just some sequential pattern that is processed in the background.
For now my current tentative main loop could look like this:
For now this is the skeleton code that I have but I have many functionality missing like how to define enemy information and their weapons shot, how to interact between the main actor and any threat coming at him etc.
In which order do you process your event and for what reason? Does one method has advantage over another?
I guess when I will write more code and see what happen it will become more clear.
For the point of view of the user, everything seems to happen instantaneously but we know that it's just some sequential pattern that is processed in the background.
For now my current tentative main loop could look like this:
Code:
- Process user input
+ process actor movement
* process actor collision against wall
+ process weapon
- Process enemy
+ move enemy
* process enemy collision against wall (when appropriate)
? process enemy weapon (if any)
? Maybe process object/enemy collision with actor here
- Move camera based on user input
- Process metatile column buffer
- Process background animation (if any)
- Wait nmi
- Finally read new user input
+ process actor movement
* process actor collision against wall
+ process weapon
- Process enemy
+ move enemy
* process enemy collision against wall (when appropriate)
? process enemy weapon (if any)
? Maybe process object/enemy collision with actor here
- Move camera based on user input
- Process metatile column buffer
- Process background animation (if any)
- Wait nmi
- Finally read new user input
For now this is the skeleton code that I have but I have many functionality missing like how to define enemy information and their weapons shot, how to interact between the main actor and any threat coming at him etc.
In which order do you process your event and for what reason? Does one method has advantage over another?
I guess when I will write more code and see what happen it will become more clear.