View Full Version: REVISION 428

CloneKeenPlus > Programming > REVISION 428


Title: REVISION 428


gerstrong - September 25, 2009 10:32 AM (GMT)
This REVISION has a little problem. As some of the latest it is not usable for release and not even for testing, but it is an evolution of the engine, so very important.

I didn't want to commit it, but I will leave for one week and I don't want to leave you without my latest implementations.

One thing must be clear here. The new code is object oriented and bases on new classes.

Some special classes have the following methods:

init(), process(), cleanup()

I want that all the developers use this structure, because it assures that no segfaults can be generated and if so, it's easily seen where the new, delete, malloc, free are incorrectly used.

I tried to make the classes very readable (also commenting much more), so I hope you take them to improve like we really wish it. And please, no more strange workarounds. The entire CG is filled with workarounds and gave us a lot of problems and understanding issues. We should avoid that in future.

There is a main game loop. This is run all time. I want to use this loop to control all the game. Some of you might remember, that we had many loops, we made the game was stuck until something happened and ran other input/output processes. I want to change that and did it in this revision, because we need a more interactive structure. With this structure we can handle more tasks at time in one thread. So it is very important for you to check CGame, CGameControl and CPassive. Please try to understand them, before you perform changes. Those classes are like switches that go through the game and control everything using only one main game loop.

init() is called normally after the class was created or something in the class is changed, which needs some setup. Constructors are still used, but they are not for changes. This function should only be called one time in a cycle per change.

process() this one is run every time the main gameloop runs. It check the switches that are set in the class and performs it works like drawing a menu.

cleanup() is called when something changes in the classes, and needs to be cleaned. For example the destruction of a screen that is not used anymore. This is also called when user chooses something that make some changes in the class. Like init() it is called occasionally and not every time main Gameloop is performed. The destructor can also be used, of course, but it is not suitable for changes within the class, because the class itself is destroyed by calling it.

I hope this Introduction explains a bit on what structure I think we should work on.

I know, that it is much for so less time but there are many advantages for that structure:

- If we change rendering mode, timer config (fps), Input polling, etc. Only one loop has to be changed and not about 20 like in the old one.

- More interactive. Pizza2004 can continue on the menu and add features, while the Intro, Demo, and Title screen run in the background. You see, two task in one thread. That would never work in the old structure so easily.

- Better memory check. new and delete of other objects are within a class and its logic can be seen.

- Better general control over the game

- No more global or external variables ( happy :-) )

- Real OOP

- Better control over the time of the timer, because the timer itself only is called in the main game loop.

I know, that it is much code for now, but it will be reduced when everything is working. All will be more readable, like the main() function. Just give it a chance and I promise that you will like it.

It's a rush decision and it worries me, but I won't be here for a week and needed to do this. The time has run out for me now. I know you will do the best for our project.

Also some investigation of Keen 4 has been done and if we use this structure, and add Galaxy support, I promise that this will be a very good and stable engine!

Just give it a chance...

Pickle - September 25, 2009 02:27 PM (GMT)
Sounds like a very good direction to go in.



Hosted for free by InvisionFree