Posts

Es werden Posts vom April, 2022 angezeigt.

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

Zum Thema Religion

Meine Eltern entschieden sich dafür, mich nicht taufen zu lassen, weil sie wollten, dass ich, sobald ich das Erwachsenenalter erreicht habe, mich selbst entschließe, einer Religionsgemeinschaft beizutreten oder auch nicht. Tatsächlich bin ich bis heute ohne Bekenntnis, weil ich mir schon als Kind gedacht habe: Religion ist etwas, das sich ein Mensch ausgedacht hat. Und warum sollte dieser Mensch klüger sein als ich? Im Medizinstudium bin ich vielen Menschen in meinem Alter begegnet, die religiös waren, und offenbar spielte das auch bei der Karriere dieser Leute eine Rolle, denn ich machte die Beobachtung, dass vor allem Mitglieder des römisch-katholischen Cartellverbands nach ihrem Studium eine Anstellung an der Universität erhalten haben. Da ich nicht religiös bin, passe ich nicht in diese Gesellschaft. Leider hat dies auch bedeutet, dass ich keine Hochschulkarriere machen konnte. Obwohl konfessionslos, bin ich aber kein Atheist, denn wenn man Gott nicht unbedingt als ein menschenähnl