Day 6 of the Level Editor project

I decided that I would make the level scrollable today, so that tiles could be placed outside the first screen. In game.h, we define two new variables unsigned int currentPosX; unsigned int currentPosY; which we set to zero in the Initialize method. These variables will store the current position in the world, where x,y = 0,0 is the bottom-left corner. We need to consider this position whenever we work with coordinates of tiles. So in the Update method, we have to write: case Solid: newElement->coordX0 += currentPosX; newElement->coordX1 += currentPosX; newElement->coordY0 += currentPosY; newElement->coordY1 += currentPosY; level.push_back(newElement); break; and evaluate the keypresses: if (g_keys->keyDown[VK_UP]) { currentPosY++; } if (g_keys->keyDown[VK_DOWN]) { if (currentPosY > 0) currentPosY--; } if (g_keys->keyDown[VK_LEFT]) { if (currentPosX > 0) currentPosX--; } if (g_keys->

Day 5 of the Level Editor project

I've decided that today we will implement a delete functionality. If levelEditorDrawMode is set to Delete, the user shall have the power to draw a rectangle and as a consequence all objects that are completely within the boundaries of this rectangle will be removed from the level. To the Update method, we have to add code that checks for the keypresses: If the user presses '0', Delete mode shall be activated, if he/she presses '1', Solid drawing mode. if (g_keys->keyDown['0']) { keyPressed->keyDown['0'] = true; } else if (keyPressed->keyDown['0'] && !g_keys->keyDown['0']) { levelEditorDrawMode = Delete; keyPressed->keyDown['0'] = false; } if (g_keys->keyDown['1']) { keyPressed->keyDown['1'] = true; } else if (keyPressed->keyDown['1'] && !g_keys->keyDown['1']) { levelEditorDrawMode = Solid; keyPressed->keyDown[&

Day 4 of the Level Editor project

Today we want to introduce saving and loading to our project. In game.h, we introduce these new variables: unsigned int levelSizeX; unsigned int levelSizeY; Keys *keyPressed; keyPressed stores keys that have been detected as pressed, so that we can perform an action as soon as the key is released. In the Initialize method of game.cpp, we initialize keyPressed:   keyPressed = new Keys(); Now we have to append the following code to the Update method so that the action is performed once the respective key is released: if (g_keys->keyDown['S']) { keyPressed->keyDown['S'] = true; } else if (keyPressed->keyDown['S'] && !g_keys->keyDown['S']) { SaveLevel(); keyPressed->keyDown['S'] = false; } if (g_keys->keyDown['L']) { keyPressed->keyDown['L'] = true; } else if (keyPressed->keyDown['L'] && !g_keys->keyDown['L']) { LoadLevel(); keyPre

Day 3 of the Level Editor project

Yesterday I wrote that today's objective would be to make the input more user-friendly, so that's exactly what I did. Instead of dragging and dropping the rectangle, the user now has to click once, then when he/she moves the mouse a rectangular shape will be shown, and as soon as he/she clicks again the rectangle will be drawn and stored in the level data. In order to achieve this I defined two new variables in game.h: LevelDrawElement* newElement; bool newElementActive; I set newElementActive = false; in Initialize and I modified Update and Draw as follows: void Game::Update_LevelEditor(DWORD tickCount, DWORD lastTickCount) { GlobalStatics globalStatics; if (g_mouse->buttonPressed != mouse->buttonPressed) { if (g_mouse->buttonPressed) { if (!newElementActive) { newElement = new LevelDrawElement(); newElement->type = levelEditorDrawMode; newElement->coordX0 = g_mouse->coordX; newElement->coordY0 = globalStatics.wo

Day 2 of the Level Editor project

We need to poll the mouse, so we define a new class: #ifndef _MOUSE_H_ #define _MOUSE_H_ class Mouse { public: BOOL buttonPressed; unsigned int coordX; unsigned int coordY; }; #endif In the class GL_Window we create a new variable Mouse *mouse; that references to this class. In our Initialize method of class Game, we write g_mouse = window->mouse; so that we can reference to the mouse data by means of g_mouse in analogy to g_keys. To the Window method, we add the following lines: case WM_LBUTTONDOWN: window->mouse->buttonPressed = true; window->mouse->coordX = GET_X_LPARAM(lParam); window->mouse->coordY = GET_Y_LPARAM(lParam); break; case WM_LBUTTONUP: window->mouse->buttonPressed = false; window->mouse->coordX = GET_X_LPARAM(lParam); window->mouse->coordY = GET_Y_LPARAM(lParam); break; Then we also need a new data structure for keeping up with the level details: class LevelDrawElement { public: LevelE

My latest private project

My latest private project is a level editor for 2D platform games. I started working on it today and I have decided that I would post about my experiences in implementing the project. The motivation is basically life-long interest in game development. As a child I designed a lot of platform games and made sketches using pen and paper. So far, I have not implemented any of these drafts. A level editor would be a good basis to change this. I am working with Visual C++ 2015 and OpenGL. I am using code from the website NeHe for window handling and bitmap drawing. Basically, I am re-using the code of my 2D shooter game "Evolution" since it is a good basis for such a project. The first thing I wanted to change was the shape of the mouse cursor. First of all, in "Evolution" the mouse cursor was disabled. I looked up on MSDN and found out that the mouse cursor can be displayed by writing ShowCursor(1); in the window method. Then I searched for information on how to change t

Österreichs Bildungswesen

Die Partei NEOS, der ich ja auch einige Jahre lang angehört habe, hat sich bekanntlich der Bildung verschrieben. Wenn man über das österreichische Bildungswesen diskutiert, dann müsste ich eigentlich als Referenz dienen, denn ich habe das gesamte öffentliche Bildungssystem von Volksschule bis Doktorat durchlaufen und dazu noch ein weiteres Bachelor-plus-Master-Studium abgeschlossen. Nach meiner Promotion habe ich mich einige Jahre lang mit der Frage beschäftigt, wie ich meine beiden Studienfächer (Medizin und Informatik) sinnvoll kombinieren könnte, und mich unter anderem der Computermodellierung biologischer Systeme zugewandt. Heute weiß ich, dass dieses Gebiet so gut wie tot ist und es keine noch nicht implementierten medizinische Anwendungsprogramme gibt. Es hat sich gezeigt, dass mein eigentliches Interesse der Entwicklung von Computerspielen gilt. Und dafür hätte ich nicht Medizin studieren müssen. Informatik auch nicht derart gründlich, wie ich es getan habe, denn wie man Compute