[Added] Services for assets and audio, main screen, simplified drawing, [Updated] Dockerfile, so the libraries get their own folder
This commit is contained in:
+12
-60
@@ -2,80 +2,32 @@
|
||||
#define STATE_SERVICE_H
|
||||
|
||||
#include "Screen.h"
|
||||
#include "ScreenState.h"
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include "EScreen.h"
|
||||
#include "Service.h"
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
class StateService
|
||||
class StateService : public Service<StateService>
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<Screen> currentScreen;
|
||||
|
||||
static StateService* instance;
|
||||
// StateService() {}
|
||||
|
||||
// StateService() = default;
|
||||
// friend StateService* StateService::getInstance();
|
||||
StateService()
|
||||
{
|
||||
std::cout << "Singleton instance created."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
// Private destructor to prevent external deletion
|
||||
~StateService()
|
||||
{
|
||||
std::cout << "Singleton instance destroyed."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
public:
|
||||
StateService(const StateService&) = delete;
|
||||
StateService& operator=(const StateService&) = delete;
|
||||
// ~StateService() = default;
|
||||
// StateService(const StateService &) = delete;
|
||||
// StateService &operator=(const StateService &) = delete;
|
||||
|
||||
// StateService& myStateService = StateService::instance();
|
||||
// StateService(const StateService&) = delete;
|
||||
// StateService& operator=(const StateService&) = delete;
|
||||
|
||||
// static StateService* getInstance();
|
||||
|
||||
// static std::shared_ptr<StateService> getInstance() {
|
||||
// static std::shared_ptr<StateService> instance = std::make_shared<StateService>();
|
||||
// return instance;
|
||||
// }
|
||||
static StateService& getInstance()
|
||||
{
|
||||
if (instance == nullptr) {
|
||||
instance = new StateService();
|
||||
}
|
||||
return *instance;
|
||||
}
|
||||
|
||||
// static StateService* getInstance();
|
||||
|
||||
// {
|
||||
// if (!instance)
|
||||
// {
|
||||
// instance = std::make_unique<StateService>(); // This works because of the friend declaration
|
||||
// }
|
||||
// return instance.get(); // Return the raw pointer of the unique_ptr
|
||||
// }
|
||||
|
||||
void setScreen(ScreenState screen);
|
||||
void setScreen(EScreen screen);
|
||||
Screen *getScreen();
|
||||
|
||||
void gameloop();
|
||||
/**
|
||||
* Start the game loop
|
||||
*/
|
||||
void startGame();
|
||||
/**
|
||||
* One step of the gameloop
|
||||
*/
|
||||
void step();
|
||||
};
|
||||
|
||||
// StateService* StateService::instance = nullptr;
|
||||
|
||||
// std::unique_ptr<StateService> StateService::instance = nullptr;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user