Advertisement
andoru

game.cpp intro

Jul 21st, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.49 KB | None | 0 0
  1. #include <fstream>
  2. #include <string.h>
  3. #include <stdarg.h>
  4. #include <typeinfo>
  5. #include <dirent.h>
  6. #include <sstream>
  7.  
  8. #ifdef VISUAL_STUDIO_BUILD
  9.   #include <direct.h>
  10.   #include "io.h"
  11. #else
  12.   #include <unistd.h>
  13. #endif
  14.  
  15. #ifdef SFML_SYSTEM_WINDOWS
  16.   #include <windows.h>
  17.   #include "zip.h"
  18.   #include "unzip.h"
  19. #endif
  20.  
  21. #ifdef SFML_SYSTEM_MACOS
  22.   #include <ApplicationServices/ApplicationServices.h>
  23.   #include "ZIPHandler.h"
  24. #endif
  25.  
  26. #ifdef SFML_SYSTEM_LINUX
  27.     #include <X11/Xlib.h>
  28.     #include <unistd.h>
  29.     #include <pwd.h>
  30.     #include <iostream>
  31.     #include <stdlib.h>
  32. #endif
  33.  
  34. #ifdef DEBUG
  35.   #define DEBUG_LOG
  36. #endif
  37.  
  38. using namespace game;
  39.  
  40. Game::~Game()
  41. {
  42.   clear();
  43. }
  44.  
  45. #ifdef DEBUG
  46. std::ofstream out("out.txt");
  47. #endif // DEBUG
  48.  
  49. #ifdef SFML_SYSTEM_LINUX
  50.     XInitThreads();
  51. #endif
  52.  
  53. void Game::init()
  54. {
  55.   /*Overworld * testObject = new Overworld(0);
  56.   void * testObjectVoidPtr = new Game();
  57.  
  58.   printf("typeid: %s\n", typeid(testObject).name());
  59.   printf("typeid: %s\n", typeid(testObjectVoidPtr).name());
  60.  
  61.   if (dynamic_cast<GameState *>(testObject)) {
  62.     printf("Is game state ... \n");
  63.   }
  64.   else {
  65.     printf("Is not game state ... \n");
  66.   }
  67.  
  68.   return;*/
  69.  
  70. #ifdef DEBUG
  71.  
  72.   // std::streambuf *coutbuf = std::cout.rdbuf();
  73.   //std::cout.rdbuf(out.rdbuf());
  74.   sf::err().rdbuf(out.rdbuf());
  75. #endif // DEBUG
  76.  
  77.  
  78.  
  79.   STRING configFilePath = Utils::getPlatformSpecificResourcePath() + "data/conf.dat";
  80.  
  81.   configurationStorage = new Configuration();
  82.   configurationStorage->readConfigFile(configFilePath.c_str());
  83.  
  84. #ifdef SFML_SYSTEM_MACOS
  85.   CreateApplicationSupportFolder();
  86. #endif
  87.  
  88.   nativeScreenSize.x = sf::VideoMode::getDesktopMode().width;
  89.   nativeScreenSize.y = sf::VideoMode::getDesktopMode().height;
  90.   unsigned int WndFlags = sf::Style::Close;
  91.  
  92. #ifdef DEBUG_LOG
  93.   sf::err() << "Native screen size: " << nativeScreenSize.x << "x" << nativeScreenSize.y << std::endl;
  94. #endif
  95.  
  96.   if (strcmp(configurationStorage->getParameter("fullscreen"), "yes") == 0) {
  97.     WndFlags |= sf::Style::Fullscreen;
  98.   }
  99.  
  100.   srand((unsigned)time(0));
  101.  
  102.   unsigned int screenWidth = atoi(configurationStorage->getParameter("width"));
  103.   unsigned int screenHeight = atoi(configurationStorage->getParameter("height"));
  104.  
  105. #ifdef DEBUG_LOG
  106.   sf::err() << "Requesting screen size: " << screenWidth << "x" << screenHeight << std::endl;
  107.   sf::err() << "Requesting fullscreen: " << (strcmp(configurationStorage->getParameter("fullscreen"), "yes") == 0) << std::endl;
  108. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement