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 |
class Level { public: Level(void); ~Level(void); void LevelMain (); bool CreatLevel_01 (int Anzahl); bool DeleteLevel_01 (int Anzahl); void Print (int Anzahl); private: int LevelStatus; bool Creat, Delete; spirit* Objekt [20]; }; |
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 |
bool Level::CreatLevel_01 (int Anzahl) { int I; // Erzeugen der Objekte for (I = 0; I < Anzahl; I++) { Objekt [I] = new spirit(); } // Wete Festsetzen int Objekt_01_Art = Dreieck; float Objekt_01_X[10] = {0.1f, 0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; float Objekt_01_Y[10] = {0.1f, 0.8f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; float Objekt_01_Z[10] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; float Objekt_01_viewX = 0.8f; float Objekt_01_viewY = 0.2f; float Objekt_01_viewZ = 3.8f; float Objekt_01_R = 1.0f; float Objekt_01_G = 0.025f; float Objekt_01_B = 1.0f; float Objekt_01_A = 0.0f; //Initalisiren Objekt [1]->InitSpirit (Objekt_01_Art, Objekt_01_X, Objekt_01_Y, Objekt_01_Z, Objekt_01_viewX, Objekt_01_viewY, Objekt_01_viewZ, Objekt_01_R, Objekt_01_G, Objekt_01_B, Objekt_01_A); return true; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
class spirit { public: spirit(void); ~spirit(void); void PrintSpirit (); bool InitSpirit (int art, float x[10], float y[10], float z[10], float ViewX, float ViewY, float ViewZ, float r, float g, float b, float a); private: int Art; float X [10], Y[10], Z[10]; float viewX, viewY, viewZ; float R, G, B, A; }; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
spirit::spirit(void) { Art = 0; for (int i = 0; i < 10; i++) { X [i] = 0; Y [i] = 0; Z [i] = 1; } viewX = 0; viewY = 0; viewZ = 0; R = 0; G = 0; B = 0; A = 0; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
bool spirit::InitSpirit (int art, float x[10], float y[10], float z[10], float ViewX, float ViewY, float ViewZ, float r, float g, float b, float a) { Art = art; X[0] = x[0]; X[1] = x[1]; X[2] = x[2]; X[3] = x[3]; X[4] = x[4]; X[5] = x[5]; X[6] = x[6]; X[7] = x[7]; X[8] = x[8]; X[9] = x[9]; Y[0] = y[0]; Y[1] = y[1]; Y[2] = y[2]; Y[3] = y[3]; Y[4] = y[4]; Y[5] = y[5]; Y[6] = y[6]; Y[7] = y[7]; Y[8] = y[8]; Y[9] = y[9]; Z[0] = z[0]; Z[1] = z[1]; Z[2] = z[2]; Z[3] = z[3]; Z[4] = z[4]; Z[5] = z[5]; Z[6] = z[6]; Z[7] = z[7]; Z[8] = z[8]; Z[9] = z[9]; viewX = ViewX; viewY = ViewY; viewZ = ViewZ; R = r; G = g; B = b; A = a; return true; } |
Jetzt werden es wohl GeisterDu erstellst 'Anzahl' viele Spirit (sind das wirklich Geister, oder meinst du Sprite?)
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
switch (Art) { case Dreieck: { glTranslatef(viewX, viewY,viewZ); // 1.5 Einheiten nach Links dann 6.0 Einheiten in den Bildschirm hinein glColor3f(R, G, B); // Setzt die Farbe auf Blau glBegin(GL_TRIANGLES); // Zeichne Dreiecke for (I = 0; I < 3; I++) { glVertex3f( X[I], Y[I], Z[I]); // Oben } glEnd(); // Fertig gezeichnet break; } ... |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Volker_Neff« (05.05.2013, 15:33)
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// Grafik.cpp int grafik::InitGL(GLvoid) // Der ganze Setup Kram für OpenGL kommt hier rein { glShadeModel(GL_SMOOTH); // aktiviert weiches Shading (Smooth Shading) glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Schwarzer Hintergrund glClearDepth(1.0f); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); // aktiviert Depth Test glDepthFunc(GL_LEQUAL); // Die Art des auszuführenden Depth Test glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // wirklich nette Perspektiven Berechnungen return true; } int grafik::Rest () { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Lösche den Bildschirm und den Depth-Buffer glLoadIdentity(); // Resettet die aktuelle Modelview Matrix / Setzt die Position mitig return true; // Alles war OK } |
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 36 37 38 |
Grafik.h #ifndef grafik_H_ #define grafik_H_ class grafik { public: grafik(void); ~grafik(void); static GLvoid ReSizeGLScene(GLsizei width, GLsizei height); int InitGL(GLvoid); // Der ganze Setup Kram für OpenGL kommt hier rein int Rest (); bool CreatWindow (char* title, int width, int height, int bits, bool fullscreenflag); GLvoid KillWindow (GLvoid); static LRESULT CALLBACK WndProc( HWND hWnd, // Handle für dieses Fenster UINT uMsg, // Nachricht für dieses Fenster WPARAM wParam, // Weitere Nachrichten Informationen LPARAM lParam); // Weitere Nachrichten Informationen void setFullsreen (bool a); bool getFullscreen (); int getActive (); HDC gethDC (); private: HGLRC hRC; // Permanenter Rendering Context HDC hDC; // Privater GDI Device Context HWND hWnd; // Enthält unser Fenster-Handle HINSTANCE hInstance; // Enthält die Instanz der Applikation static bool active; // Fenster Aktiv Flag standardmäßig auf TRUE gesetzt bool fullscreen; // Fullscreen Flag ist standardmäßig auf TRUE gesetzt public: static bool keys[256]; // Array das für die Tastatur Routine verwendet wird }; #endif |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Werbeanzeige