Advertisement
Guest User

SFMLApp.cpp

a guest
Nov 26th, 2013
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include "SFMLApp.h"
  2. #include "SFML/Window/VideoMode.hpp"
  3. #include "SFML/Window/Keyboard.hpp"
  4. #include "SFML/Graphics/Color.hpp"
  5.  
  6. SFMLApp::SFMLApp() {
  7.     MapGenerator generator;
  8.     this->currentMap = generator.GenerateMap(10, 10, 3);
  9. }
  10.  
  11. SFMLApp::~SFMLApp() {
  12.     delete this->window;
  13.     delete this->currentMap;
  14. }
  15.  
  16. bool SFMLApp::Init(const char * title) {
  17.     this->window = new sf::RenderWindow(sf::VideoMode(SFMLApp::WINDOW_WIDTH, SFMLApp::WINDOW_HEIGHT, 32), title);
  18.  
  19.     return (this->window != NULL);
  20. }
  21.  
  22. void SFMLApp::HandleEvent(sf::Event* event) {
  23.     if(event->type == sf::Event::Closed) this->running = false;
  24.  
  25.     if(event->type == sf::Event::KeyPressed) {
  26.         if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape)) this->running = false;
  27.     }
  28. }
  29.  
  30. void SFMLApp::Update(sf::Time elapsedTime) {
  31.  
  32. }
  33.  
  34. void SFMLApp::Render() {
  35.     this->window->clear(sf::Color::Black);
  36.  
  37.     this->currentMap->DrawTiles(this->window);
  38.  
  39.     this->window->display();
  40. }
  41.  
  42. void SFMLApp::Cleanup() {
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement