Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Game.h"
- Game::Game(sf::RenderWindow &Window)
- :win(Window)
- {
- if(!res.loadTexturesFromArchive("data/gfx", "gfx.7z", "png", TEX_NUM)) // Loading textures from game resource.
- {
- std::cout << "/*/** Failed to load textures from archive, HALT! **/*/" << std::endl;
- exit(EXIT_FAILURE);
- }
- if(!gmap.open("data/maps/test.txt")) // Test map.
- {
- std::cout << "/*/** Failed to open game map, HALT! **/*/" << std::endl;
- exit(EXIT_FAILURE);
- }
- gmap.get(20);
- }
- void Game::renderBackgroundMap()
- {
- /*TODO*/
- }
- void Game::logic()
- {
- sf::Event event;
- while(win.pollEvent(event))
- {
- switch(event.type)
- {
- case sf::Event::Closed:
- win.close();
- break;
- default: break;
- }
- }
- fps.update(); // FPS time update.
- std::ostringstream o;
- o << APP_NAME << " |FPS: " << (unsigned int) fps.getFPS();
- win.setTitle(o.str()); // Setting title with FPS num.
- }
- void Game::render()
- {
- win.clear(); // Clear Background with default color - black (0,0,0)
- // Drawing.
- //this->renderBackgroundMap();
- win.display();
- }
- bool Game::run()
- {
- while(win.isOpen())
- {
- this->logic();
- this->render();
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement