Hallo!
Momentan programmiere ich den Klassiker Pong.
Nun habe ich Probleme beim Framework. Es ist fertig, jedenfalls in der groben Fassung, aber in der Funktion Init sind manche Variablen und Funktionen völlig unbekannt! Dabei stehen sie in der Klasse!!
Alles mit den rot BBCode wird nicht erkannt.
Framework.hpp:
Alles anzeigen
Framework.cpp:
Alles anzeigen
Momentan programmiere ich den Klassiker Pong.
Nun habe ich Probleme beim Framework. Es ist fertig, jedenfalls in der groben Fassung, aber in der Funktion Init sind manche Variablen und Funktionen völlig unbekannt! Dabei stehen sie in der Klasse!!
Alles mit den rot BBCode wird nicht erkannt.
Framework.hpp:
Quellcode
- #ifndef FRAMEWORK_HPP
- #define FRAMEWORK_HPP
- #include <iostream>
- #include "Singleton.hpp"
- #include "Timer.hpp"
- using namespace std;
- #define g_pFramework CFramework::Get()
- class CFramework : public TSingleton<CFramework>
- {
- public:
- bool Init (int ScreenWidth, int ScreenHeight,
- int ColorDepth, bool bFullscreen);
- void Quit ();
- void Update ();
- void Clear ();
- void Flip ();
- bool KeyDown (int Key_ID);
- SDL_Surface *GetScreen () {return m_pScreen;}
- private:
- SDL_Surface *m_pScreen; // Surface für den Screen
- Uint8 *m_pKeystate; // Array für aktuellen Tastaturstatus
- };
- #endif
Framework.cpp:
Quellcode
- #include "Framework.hpp"
- //Init
- bool Init (int ScreenWidth, int ScreenHeight,
- int ColorDepth, bool bFullscreen)
- {
- if(SDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1)
- {
- cout << "SDL konnte nicht richtig initialisiert werden." << endl;
- cout << "Fehlermeldung: " << SDL_GetError();
- [color=#ff0000]Quit();[/color]
- return(false);
- }
- if(bFullscreen == true)
- {
- [color=#ff0000]m_pScreen[/color] = SDL_SetVideoMode(ScreenWidth, ScreenHeight, ColorDepth,
- SDL_HWSURFACE | SDL_DOUBLEBUF |
- SDL_FULLSCREEN);
- }
- else
- {
- [color=#ff0000]m_pScreen[/color] = SDL_SetVideoMode(ScreenWidth, ScreenHeight, ColorDepth,
- SDL_HWSURFACE | SDL_DOUBLEBUF);
- }
- if([color=#ff0000]m_pScreen[/color] == 0)
- {
- cout << "VideoMode konnte nicht gesetzt werden." << endl;
- cout << "Fehlermeldung: " << SDL_GetError();
- [color=#ff0000]Quit();[/color]
- exit(1);
- }
- [color=#ff0000]m_pKeystate[/color] = SDL_GetKeyState (NULL);
- return(true);
- }
- //Init Ende
- //Quit
- void CFramework::Quit ()
- {
- SDL_Quit ();
- }
- //Quit Ende
- //Update
- void CFramework::Update ()
- {
- g_pTimer->Update();
- SDL_PumpEvents();
- }
- //Update Ende
- //KeyDown
- bool CFramework::KeyDown (int Key_ID)
- {
- return(m_pKeystate[Key_ID] ? true : false);
- }
- //KeyDown Ende
- //Clear
- void CFramework::Clear ()
- {
- SDL_FillRect (m_pScreen, NULL, SDL_MapRGB(m_pScreen->format, 0, 0, 0));
- }
- //Clear Ende
- //Flip
- void CFramework::Flip ()
- {
- SDL_Flip (m_pScreen);
- }
- //Flip Ende