Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
//Hauptklasse #ifndef GAME #define GAME #include "DDraw.h" #include "Player.h" #include <list> #include "Fire.h" class Game { private: DDraw Game_DDraw; Player MainPlayer; list<Fire*> lFire; // Verkettete Liste list<Fire*>::iterator iFire; // Iterator int Fire_Count; float time_old; float time_new; float time_diff; int Check; public: bool Init_All(); void Release_All(); void Render(); void Clear_Scren(); void Blit_Bitmap(RECT, LPDIRECTDRAWSURFACE7); DDraw getDirectDrawInstance (); void Check_Input(); float get_Time_Diff(); void Add_Fire(); }; #endif |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
void Game::Add_Fire() { Fire *Temp = NULL; Temp = new Fire(Fire_Count); Fire_Count = Fire_Count + 1; lFire.push_back (Temp); iFire = lFire.end(); (*iFire)->LoadBitmap("Fire.bmp"); float x, y; x = MainPlayer.get_Koordinate_x(); y = MainPlayer.get_Koordinate_y(); (*iFire)->set_Koordinaten(x,y); } |
C-/C++-Quelltext |
|
1 2 3 4 5 |
lFire.push_back (Temp); iFire = lFire.end(); iFire--; (*iFire)->LoadBitmap("Fire.bmp"); |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
void Game::Render() { float x, y; for(iFire=lFire.begin(); iFire!=lFire.end(); ++iFire) { x = (*iFire)->get_Koordinate_x(); y = (*iFire)->get_Koordinate_y(); x -= 2; y -= 2; if (x<0 || y<0) { delete (*iFire); (*iFire) = NULL; } else { (*iFire)->set_Koordinaten(x, y); (*iFire)->Draw_Object(); } } MainPlayer.Draw_Object(); MainPlayer.Act_Position(); Game_DDraw.DrawAll(); time_new = timeGetTime(); time_diff = time_new - time_old; time_diff = time_diff/24; } |
C-/C++-Quelltext |
|
1 2 3 4 5 |
if (x<0 || y<0) { delete (*iFire); (*iFire) = NULL; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 |
if (x<0 || y<0) { delete (*iFire); iFire=lFire.erase(iFire); if (iFire==lFire.end()) break; } |
Werbeanzeige