That also means that the thread can not alter the graphics on it's own.
I was about to create an experimental fork in Git and refactor the whole game. The plan was to put in a proper input -> update -> render loop. Using a thread appears to be a dead end. Makes sense, the original code base was not designed for one. I should of refactored this mess anyway, and actually set it as a goal at the beginning of phase 2. However, it was working (kind of) and I thought I could cheat with a thread (That I kept commented out for two months. Should of been a warning sign right there)
The "normal" thing to do is to set up an event system that can get polled by the main game. It will simply look in the queue and see if 55 milliseconds has passed and then run a function. Time and time again I try to explain why ROE does not have a main loop, and it's not possible to implement an event queue because there is no central place to poll the queue from.The game is made up of "screens" and each have their own loops, but some loops don't render anything and some don't take user input. It was only when I looked up overlays on Wikipedia did it show an example of this type of linking
+--------------+ | Root Segment | | MOD1, MOD2 | +--------------+ | +----------+----------+ | | +-------------+ +-------------+ | Overlay A | | Overlay B | | MOD3 | | MOD7 | +-------------+ +-------------+ | +--------+--------+ | | +-------------+ +-------------+ | Overlay AA | | Overlay AB | | MOD4, MOD5 | | MOD6 | +-------------+ +-------------+
This was why I was having a hard time explaining it. The program flow is hierarchical and control does not stay in the root segment. Each part of the game is loaded when it's needed from the HDD and then purged when another overlay is needed. I had long since combined everything into one big executable, but the program flow was the same. The root segment hangs out in memory, and that where my graphics lib hangs out, but nothing really loops there. This is also why, when I implemented the graphics lib with the Allegro wrapper, everything downstream started to "just work" for the most part. The 1Ch thread was independent of this tree and why I thought a thread would be a good idea.
GrafX2 - A common kinship |
It took a new function and 4 entry points.... I felt so stupid.
I was about ready to rip apart this whole program and now I have a functioning "inner loop" I guess. Now my next goal is to work on the game proper. I already have to abstract the file system in that part of the code to load/save/create and existing game. I also have to make the Race Builder stand alone so the artist can make some cool alien bits .
No comments:
Post a Comment