Monday, January 21, 2008

DaTetris v0.65

In this update you can see several new features like next block preview, scoring (but without storing the scores yet), new ui images like pause and level frame, and clicking New Game will always start a new game. Also, I got rid of some useless new\deletes and fixed a memory leak which resulted in about 4MB per hour of leakage.
But whats really important, is the fact I shifted from using the original HGE. This game engine is really nice and simple, but it has imo some flaws in its design. The most important one, is that it is designed in every its part to use with pointers. Now, I dont have anything against pointers, BUT! Almost all helper classes had their default constructor at protected part of the class. And the proper constructor which takes some arguments and is necessary to initialize the classes is the only proper way of initialization. It means, that if I want to have instances of these classes, my only way is to use the initialization line in constructor of the class which contains these instances. And heres the problem - one of the arguments which I have to pass to the constructor is a texture, which I have to load before. So my only way here is to initialize the objects through the 'new' operator, and thats not good - I avoid using new\delete if there is another way.
And there is a way - Ive got into the source code of HGE and made the necessary changes, enabling default constructor and creating additional function Init() with all needed arguments.
This is where I have to decide, whether I should continue with my changes to HGE (and I already noticed much places I would like to make MY WAY), or I should take everything I learned from HGE's pros and cons into account, and polish my own framework to the decent level.
Anyway, I will finish this game prototype first of all. Oh, here is the link to DaTetris_v0.65 8)

1 comment:

Brad said...

Nothing wrong with the new operator, especially if you use smart pointers like boost::shared_ptr!