Sunday, May 11, 2008

De-PImpl'ed and Unicode'ized

This is what I was(and am) working on last 3 days.

The PImpl - Private Implementation

When I just started DGE I knew I must find a way to separate the interface from implementation. And since I did not use boost's smart pointers back then, I tried to avoid every 'new' call in DGE itself and in its design as well, so there wont be something like DGE *engine = new DGE(); Thats why private section of DGE class definition looked like this: DGE_Data *m_data; and all calls to private members were like this: m_data->some_memeber.SomeFunction(); which is very ugly IMO.
Now Im using boost's libraries pretty much everywhere, as well as the smart_pointers, and since I dont have to avoid 'new' calls now, I decided to make some changes. I created a DGE_Implementation class which derives from DGE which was turned into abstract interface with all pure virtual methods and with no members. I added a new global function, DGE_Create() which returns a pointer to DGE interface, pretty standard technique 8) DGE_Data was finally eliminated, as well as those ugly m_data->some_member.SomeFunction(); and it feels much better now. Im sure I will not regret I did this 8)

Unicode

Boy, multilingual support was the last thing I was thinking about when the core of DGE was written 8) All I ever needed was good ol' std::string. But then I accidentally found this article: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
It reminded me of very much really nasty problems with encoding, like the website or mail encoding guessed wrong by app, or like youre working with some really cool library and that damn piece of software understands only ASCII >_<
So I decided to Unicode'ize DGE. All std::strings were replaced with std::wstrings, and I thought thats it, end of story :D Actually there are more to it than it seems. All I did by replacing std::strings with std::wstrings is changed the way the text data was handled inside the application, when whats really important its the application's interaction with the user - i/o. So I had to hack into font loading and displaying code as well to make it understand unicode fonts and display them correctly. Also, after deciding thatI should save DGE's log in UTF-8 format I spent much time just surfing the web for info about Unicode, its encodings and its use in C++. Unfortunately actual Unicode support is still in C++0x, so I ended up using this neato library for UTF-8 logging (btw, I made reverting back to ANSI logging really easy, just in case).
Now Im considering making changes to *.das file format (Da Game Engine Sprite) to make it UTF-8 as well, but this is not the top priority right now.

Next, Im planning to extend text rendering features, like newline support, wrapping text inside specified box, and more GUI controls.

Oh yes, I will release the Unicode'ized version after I finish the testing of every feature that has any relation to text.

Friday, May 9, 2008

DGE 0.16.13 update

Another DGE update, go here for somewhat a changelist, and here is the rapidshare link, as usual.

Monday, May 5, 2008

DGE v0.16.00a

Weee, first release of Da Game Engine 8)
Here is the rapidshare link, as usual.
By the way, I created a website for DGE on a free hosting, though I will still post any major DGE updates here. You will find all info there, here is the link.

Sunday, April 27, 2008

DGE_DaTetris

I guess Im not a blogger type 8) So, lets get straight to business without long introductions. This is DaTetris, ported to my DGE(Da Game Engine). Not much changed in the game itself, except some minor speed tweaks and engine. I guess I want to make this Tetris clone more playable, so any suggestions\bugreports are welcome 8)
Im planning to add instant drop in the next update btw.
So, here is the link, and I hope it wont crash ^.^

Tuesday, March 4, 2008

This devblog isnt dead!

Its just being rarely updated when there arent much visual features to show. Im currently developing animated sprites support for my framework. It includes easy to use sprite interface, binary and/or text sprite file format, and a sprite editing tool. Im working on a sprite compilation tool right now. Since this is a first version, a draft if you like, it is console app which only goal is to compile sprite descriptor file which includes info about each frame of each animation, and produce single texture which contains all image data for frames from a sequence of separate images. Currenty there is only binary sprite descriptor, but I think it might be useful to add XML based one later. In future I will probably make visual sprite editor, or just a GUI wrapper for the console app, anyway the GUI part most probably will be programmed using my framework's GUI simple classes (which are yet to be developed), since I detest every part of WinAPI code and I dont intend to waste my time on learning MFC or whatever, its much easier and faster for me to write some basic GUI classes (I did this before). Maybe only in a far future I will introduce myself to WinAPI stuff, I cant say for sure now. Im hoping to finish basic sprite's features this week and post here a simple demo, maybe even with some source code, so you can tell me if you think I can improve the framework design in some way. Even though not much ppl read me, every opinion which isnt mine is worthless in terms of development. It is important, since I plan the framework to be used not only by myself - thats why Im trying to make it easy to use and flexible for average user.
Yea, I wanted to start porting DaTetris about 2 weeks ago, but I decided to wait until all core features of the framework will have somewhat constant design. I redesigned the sprite class about 5 times for instance, and Im not sure if I wont redesign it again soon. So, no DaTetris port until sprites, simple GUI and fonts are finished. The good part is that sprites are almost finished - I have a stable core right now, all I have to do is finish the compile tool and polish that core. For fonts and GUI I will be using my old code as a base, as I did with the Direct3D part of my current framework. IMO its almost always better to take old code that works, and refactor it to the new level than writing everything from scratch. It speeds up the development and improves the overall quality, since refactoring only improves the code, while writing the code from scratch you can, for instance, repeat your old errors. Also you spend much more time to write everything from scratch and make it work, while when you refactor you already have your working code. And the result code is often indistinguishable from the old one, like in case of the Direct3D part of my framework. If I was writing it from scratch, it would take at least twice as much time to achieve the current state. So, refactoring is one of the most useful techniques in programmer's arsenal IMO.

Saturday, February 16, 2008

Whats going on...

Its been almost 20 days since my last post. The reason of lack of updates is quite simple - there is nothing to "show". Im currently coding simple framework for 2d games development, and it means that there isnt much to see in screenshots and binaries. But I do can describe it, I didnt so before since there wasnt clear structure of the framework. I am designing the structure and coding at the same time, so it is hard to make "previews", since it changes all the time here and there, some kind of real-time morphing 8)

Certainly, one would ask "Why would you create another game engine?". In fact, I like all this low-level stuff, like playing with Direct3D. Also, I like to do things myself, and by that I mean that while using another game engines I may dislike some aspects and/or design, and it naturally awakes the desire to make something by myself, in my way. The prefect example is Haaf's Game Engine, I actually described some issues with it in my earlier posts. This engine is very good, the best one I used, and it gave me some ideas for my own framework, though I must note that I didnt copy-paste anything at all 8)

I will start porting DaTetris to the new framework as soon as I polish every feature it needs, and simultaneously continue to develop the framework. Expecting to start porting next week or so.

Monday, January 28, 2008

DaTetris v0.99b


There we go, the game is finished. All that remains is fixing bugs, and polish it up. Archive is here.

DaTetris v0.79 - v0.99b
Added:
- [add] Speed selection.
- [add] Score saving.

Tuesday, January 22, 2008

DaTetris v0.79


DaTetris v0.65 - v0.79
Added:
- [add] Speed increases with each 10 removed lines.
- [add] Removed lines counter.
- [add] Speed counter.
- [add] Continue button in main menu.
- [add] Counters for each type of figure.
Updated/Fixed:
- [fix] Scoring. Now the score for amount of passed rows by figure is updated only after the figure falls down.
- [upd] Level frame texture.

DaTetris v0.79

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)

Friday, January 18, 2008

DaTetris v0.45

This is the first DaTetris update so far >_<
Yeah... It has simple half-working menu, and sort of playable as well, though I still have not implemented the feature of next block preview, but I guess its not that critical right now. The biggest problem was the main menu screen and coloring the tetriminos - my ass is still aches in pain after these 3-4 hours of trying, trying and trying different color palettes... After all I came up with the colors you see at the screen (click to enlarge), and it was sort of the best choice out of all others - at least it does not hurts my eyes(its not so bright and contrast) and also I dont have to struggle to see the action(and not very dark as well). Yep, no scores - and the game doesnt throw you out when you reach the top - but you cant move the tetriminos up there. You have to restart the game to begin from scratch. While testing I did not run into any bugs - but it does not mean that there arent any 8) I really hope it will start well without squeaking on any other pc - so download it, check it out, play it and even test - if ya want to 8) Heres the link to the archive.

Feel free to comment! >.<

Wednesday, January 16, 2008

Many moons later

Its been a long time with no updates. I was busy on my exams in april-july, and therefore could not post anything - there was nothing to post about. But since summer Ive been working on my tiny games here and there, and moved much further towards being a game developer, though I still have a lot to learn. 

Now, a little detail on what I did since mid summer. I wanted to continue developing my remake of EvilMonkeys, but after I looked at the code, I realized it was way too crappy. I realized also that SDL isnt suitable for my game's needs. SDL is very nice and friendly framework to work with, but the cons overweighted pros. First, and worst - SDL is slow. I know that the problem wasnt in SDL itself, but in my code. And at that point I couldnt write code using SDL which runs above 50 unlimited fps and has only level and player objects on the screen. Second, is SDL's limits in manipulating graphics - it just blits bitmaps onto screen, with no way to even rotate the surfaces. And I made a decision: I will move to Direct3D and start from even lower level, than SDL's.

Months and months later, I had in my hands a crude framework, which core was rewritten at least 5 times (and I suspect that it will be rewritten again), and which holds in each component a different step in the evolution of my code, and even different style. Same bad code, same mistakes, a little more experience and a little more programming books ahead - and there it is, teh "game engine" made by me, myself and I :D The downfall was quick and painful, when I spawned around 50 game entities; my techdemo's performance started to degrade like in equation f(x) = y2 and reached pause within 5 seconds. I suspect that this was due to my kinematics and collision detection code, which had more sin()'s, cos()'s and vector operations than in my high school math book. At that point it was too much for me; I freezed the project and started looking for a decent 2d game framework - and I found one. The Haaf's Game Engine or HGE is a small, cute and Direct3D based 2d game engine. It is very well documented, totally free and open-source. Heck, I could read its source code and understand everything!

And so I decided to make a small Tetris clone to check out HGE's features and get used to it. After I finish Tetris clone, I will once again try to revive my own framework using some ideas I got by reading HGE's sources, and possibly port DaTetris to my framework. The actual gameplay part of DaTetris is finished - I have a level, all 7 figures-tetriminos, they rotate, fall, move and merge to level's structure when fell down. The level removes completed lines of tetriminos and moves all of above down - well, all is like in the original Tetris. So its playable, though endlessly without scores and defeat. Currently Im working on main menu, interface and game states. I will post an update in the next few days with playable demo hopefully featuring main menu and basic interface.

Thursday, April 19, 2007

Something new

Whoa, theres much time went from my last post. And actually there arent much news to tell. Im continuing to develop my 2D reincarnation of EvilMonkeys, not as fast as I wanted to though. Since this little project was rebuilt from a scratch 3 times, Ill provide its most important features for the moment:
I wrote a simple surface manipulating class, which is very easy to use.
I wrote a sprite class which is able to load any image, and has the ability to move framarate-independently.
I wrote a level class, which can be loaded from file, or generated randomly. The sprite can move in the level, and there is even a collision detecion, so the sprite cant run through walls.
The level could be edited in very simple editor.
Also, I implemented a crude system which can handle keyboard input for level saving and loading.
The levels dimensions can be easily changed.
The level can support many tile types, although there are only 2 tiles at the moment - wall, and empty.
The editor can also be easily extended with new tiles. But its still very crude.
There is an enemy class, with very buggy and glitchy path finding. For now, its good cause it at least works sometimes.

Actually Ive implemented every single feature I wanted this game to have. But there are much work ahead - I must debug and improve every single feature of my game, and there are much to be improved. And yeah - no screen. The game is still black n' white. I will load in some textures this weekend, and only then I will upload a screen.