#ifndef CORE_H_ # define CORE_H_ #include #include #include #include #include #include #include "QuadTree.hh" #include "../IRenderable.hh" # ifndef __DWIDTH # define __DWIDTH 1920 # define __DHEIGHT 1080 # endif #ifndef __DQUADTREE_COMPLEXITY__ #define __DQUADTREE_COMPLEXITY__ 6 #endif #if __DQUADTREE_COMPLEXITY__ > 10 #warning "you will use more than 300 Mb =O" #endif namespace DamnCute { class APhysics; class Core { public: Core(const Core&) = delete; Core(const Core&&) = delete; Core& operator=(const Core&) = delete; Core& operator=(const Core&&) = delete; static Core* getInstance(); void closeWin(); void reset(); void freeAll(); void addObject(IRenderable*); void delObject(IRenderable*); void hideObject(IRenderable*); void addOnBg(IRenderable*); void flushScene(); void flushEvent(); template void createWindow(unsigned int width = 0, unsigned int height = 0, bool full = false) { unsigned int style = full << 3 | sf::Style::Titlebar; sf::VideoMode v; if (full) { v = sf::VideoMode::getFullscreenModes()[0]; } else if (width == 0 && height == 0) { v = sf::VideoMode::getDesktopMode(); } else { v = sf::VideoMode(width, height); } _win = new sf::RenderWindow(v, "DamnCute Engine", style); _Rtex.create(SIZEX, SIZEY); _Rtex.setSmooth(true); _rsp.setTexture(_Rtex.getTexture()); _rsp.setScale((float)getWindowSizeX() / (float)__DWIDTH , (float)getWindowSizeY() / (float)__DHEIGHT); _win->setVerticalSyncEnabled(true); _win->setFramerateLimit(60); } int getWindowStatus(); int getWindowSizeX(); int getWindowSizeY(); sf::Music& getMusic(); void musicPath(std::string); void musicPlay(int); int getMusicListSize(); inline bool getGameStatus() const { return _gameStatus; } inline void switchGameStatus() { _gameStatus = !_gameStatus; } inline sf::Event getEvent() const { return event; } inline void setFPSDisplay(bool value) { _displayFPS = value; } inline void addBulletsCounter() { ++_numberOfBullets; } inline QuadTree, __DQUADTREE_COMPLEXITY__>* getQuadTree() { return &_physicTree; } private: Core(); ~Core(); void refresh(); static Core* __coreInstance; QuadTree, __DQUADTREE_COMPLEXITY__> _physicTree; sf::RenderWindow* _win; sf::RenderTexture _Rtex; std::list _objects; bool _gameStatus; bool _displayFPS; unsigned int _numberOfBullets; unsigned int _Pframmes; unsigned int _tmpFrammes; sf::Sprite _rsp; sf::Clock _gameClock; sf::Event event; sf::Music _music; std::string _musicPath; std::vector _musicList; void saveFolderMusic(std::string); bool supportedFileFormat(std::string); }; } #define sCore Core::getInstance() #endif /* !CORE_H_ */