Kid dream, part II: Game engine

Hello again, as I've promised I'm here with the newest information about game development that I've announced in previous article. Today I will focus on development of game engine and support tools.

Just for reminder I want to create an isometric strategy game. Well it is not a real isometric projection at all. And that is because lines at real isometric projection are not smooth. So instead of it a dimetric projection is used in video games. For more information about this topic you can read this article on Wikipedia.

Game Engine
There was an idea at first and that was create an isometric strategy game. Then I started working on rendering a diamond shape with 'isometric' tiles. And when I've finished it was the right time for development of a map editor. Well I had developed a collection manager before that but that is not so interesting. 🙂

So about the map editor I though that Windows GDI+ for drawing graphics which is a standard interface in .NET would provide sufficient performance for my "small game". Well this was true until I've started rendering tile textures. After that the performance was very poor and the rendering was slow. I used double buffering and drawing into a bitmap which was entire drawn at the end. And the bitmap had resolution the clipped frame only. You can see an image of old GDI+ map editor below.

Well I thought that my problems could by solved by some optimization but I've chosen a different way. And that was to learn OpenGL and the best arguments for it were that it is multi platform standard and suddenly I was thinking about porting to Android in future where is OpenGL ES integrated.

Old map editor (GDI+)

Learning OpenGL
So I've started learning OpenGL and the most important started to practise some drawing, and reading a few OpenGL books. I discovered that the hardest thing for me was setting a camera for isometric projection but thanks to NeHe's OpenGL tutorials, kind uncle Google and a few books I've read I was able to set the camera. And start rendering tiles and then covering them by textures. So concept was proved and I was so happy that I've developed this simple demo and you can see it too on the next image. 🙂

OpenGL Map Editor concept
After that I started refactoring map editor and use OpenGL for map rendering. Well because I am using MVP (Model-View-Presenter) architecture it wasn't such a big deal and as you can see below I've  also redesigned redesigned the view.

One of the main challenge was how to convert the screen coordinates into world coordinates. I find out that OpenGL function gluUnProject should do it for me. I was trying for almost two days to get expected results but it was blind alley. So I've used own function giving me [X,Y] coordinates and the Z coordinate is specified manually.

MapEditor OpenGL draft

Project complexity
I've started with map editor and collection manager project but I've soon realized that project complexity grows and many features will be used in another projects connected with the game. So that was a moment to think and switch from coding to modelling and start using software engineering practices. I've decided to create an UML model of my projects and perhaps redesign and check correctness of architecture. It was a damn right choice because instead of  looking to code you can see a lot more things on diagram and change it easier and code the 'final' design.

I am using Visual Paradigm UML (Community edition)  modelling software and I like it because it is very intuitive for me so I don't need any manual. 🙂

During the modelling I've created a GameEngine package that include common parts of game projects (map, isometric projection). It is not a final design because I think there is a lot of things missing e.g. collision detection system etc.

The Map Editor
The last version of map editor is a big step in compare with the first version. It is able to create model of terrain with different Z coordinates. I reprogrammed the map load/save function yesterday for the new map model specified by UML model. There are a few bugs to fix and some functions to code e.g. the tilesToCover which should allow designer to cover more then one tile at time.

The map rendering engine is almost done and there is one thing that missing covering the tiles with textures but for me it is the last thing to do.:)  Actually I am updating the UML model because I've created some service layer that shorten code and makes it more readable.

The actual Map Editor

So I am so excited that I was able to develop such map editor it is not too complex but I think that it is enough for the moment. And as you can see the development of GameEngine should be a side product. 🙂

Starting with traditional waterfall process is not necessary I rather prefer agile development because I do not know what I want exactly (I am the man with the requirements). A lot of requirements have just showed me during the development process.

And when the project rapidly grows it is time to think start modelling and maybe redesign because having a actual picture of a code, classes, models, etc is harder then having a computer screen with appropriate diagrams.