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
class CGame final | |
{ | |
public: | |
~CGame(); | |
CGame(const CGame &) = delete; | |
void operator=(const CGame &) = delete; | |
inline static CGame& Instance() | |
{ |
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. | |
{ | |
} | |
///////////////////////////////////////////////////////// | |
CGame::~CGame() // Destruktor klasy. | |
{ | |
} |
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
#include <SFML/Graphics.hpp> | |
#include <SFML/Window.hpp> | |
#include <SFML/System.hpp> | |
int main() | |
{ | |
sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Tworzenie gier - rozszerzalny kod wzorem Unreal Engine 4.", sf::Style::Close); | |
while(window.isOpen()) | |
{ |
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. | |
: | |
m_window(sf::VideoMode(800, 600, 32), "Tworzenie gier - rozszerzalny kod wzorem Unreal Engine 4.", sf::Style::Close) | |
{ | |
} | |
///////////////////////////////////////////////////////// | |
CGame::~CGame() // Destruktor klasy. | |
{ | |
if(m_window.isOpen()) |
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
enum Status | |
{ | |
Initializing = 0, // Ten status zostanie ustawiony gdy wejdziemy do konstruktora klasy gry. | |
Running = 1, // Ten status zostanie ustawiony gdy rozpoczniemy grę. | |
Paused = 2, // Ten status zostanie ustawiony gdy użytkownik zapauzuje gre. | |
CleaningUp = 3 // Ten status zostanie ustawiony gdy użytkownik zamknie aplikację. | |
}; |
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. | |
{ |
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
#include "Include/Game.hpp" | |
int main() | |
{ | |
auto &game = CGame::Instance(); | |
game.Run(); | |
return 0; | |
} |
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
#include <unordered_map> | |
/* Klasa do zarządzania teksturami | |
*/ | |
class CTextureManager final | |
{ | |
public: | |
/* Typedef dla umilenia życia. */ | |
typedef std::unordered_map<std::string, sf::Texture *> TTexturesUM; |
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
/* Statyczna metoda, ktora laduje teksture do pamieci i ustawia ją pod kluczem | |
podanym w [textureName]. Jeśli textura o tej nazwie już istniała, to zamieniamy ją. | |
Robimy to w taki sposób, by nie "psuć" spritów, które już korzystają z tamtej tekstury. | |
*/ | |
static sf::Texture* Load(const std::string &textureName, const std::string &texturePath); | |
/* Usuwa teksture o podanej nazwie [textureName] z pamięci. | |
*/ | |
static bool Unload(const std::string &textureName); |
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
////////////////////////////////////////////////////////////////////// | |
CTextureManager::CTextureManager() | |
{ | |
} | |
////////////////////////////////////////////////////////////////////// | |
CTextureManager::~CTextureManager() | |
{ | |
/* Usuwamy każdą teksturę. */ | |
for (auto textureData : m_textures) |
OlderNewer