Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // the basic functions of a game engine
- #include "Enemy.h"
- #include "Game.h"
- #include "GameObject.h"
- #include "InputHandler.h"
- #include "Player.h"
- #include "LoaderParams.h"
- #include "TextureManager.h"
- #include "SDLGameObject.h"
- #include "Vector2d.h"
- //our game object
- Game* g_game = 0;
- const int FPS = 60;
- const int DELAY_TIME = 1000.0f / FPS;
- int main(int argc, char* argv[])
- {
- Uint32 frameStart, frameTime;
- std::cout <<"game init attempt";
- if(TheGame::Instance()->init("Chapter 1", 100, 100, 640, 480,
- false))
- {
- frameStart = SDL_GetTicks();
- std::cout <<"game init success!\n";
- while(TheGame::Instance()->running())
- {
- TheGame::Instance()->handleEvents();
- TheGame::Instance()->update();
- TheGame::Instance()->render();
- frameTime = SDL_GetTicks() - frameStart;
- if(frameTime< DELAY_TIME)
- {
- SDL_Delay((int) (DELAY_TIME - frameTime));
- }
- }
- }
- else
- {
- std::cout<<"game init failure - " << SDL_GetError() << "\n";
- return -1;
- }
- std::cout<<"game closing";
- TheGame::Instance()->clean();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement