Last active
January 28, 2017 21:06
-
-
Save PoetaKodu/c467c406177b305f7367181d3e01b7fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGame::CGame() // Konstruktor klasy. | |
: // Korzystamy z listy inicjalizacyjnej. | |
m_status(Status::Initializing), // Status w konstruktorze ustawiamy na Initializing | |
m_window(sf::VideoMode(800, 600, 32), "Tworzenie gier - ekspansywny kod.", sf::Style::Close) // Tworzymy okno SFMLa. Typowe okienko 800x600. | |
{ | |
} | |
///////////////////////////////////////////////////////// | |
CGame::~CGame() // Destruktor klasy. | |
{ | |
// Zamknijmy okno gry jesli zostalo otwarte. | |
if (m_window.isOpen()) | |
{ | |
m_window.close(); | |
} | |
} | |
///////////////////////////////////////////////////////// | |
void CGame::Run() // Glowny kod gry. | |
{ | |
// Pamietamy zeby ustawic odpowiedni status aplikacji. | |
m_status = Status::Running; | |
// Ciemnoszary kolor. | |
sf::Color bgColor(30, 30, 30); | |
// Wykonujemy petle glowna. | |
// Przerywamy kiedy status zmienimy na CleaningUp | |
// czyli po prostu gdy chcemy zamknac aplikacje. | |
while (m_status != Status::CleaningUp) | |
{ | |
sf::Event windowEvent; | |
while (m_window.pollEvent(windowEvent)) | |
{ | |
if (windowEvent.type == sf::Event::Closed) | |
m_status = Status::CleaningUp; // Reszta zostanie wykonana w konstruktorze. | |
} | |
m_window.clear(bgColor); | |
m_window.display(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment