1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #include "Scene.h"
- #include <unistd.h>
-
- int Scene::xMax;
- int Scene::yMax;
- int Scene::points = 0;
- bool Scene::initialized = false;
- bool Scene::freezed = false;
- bool Scene::running = false;
- std::mutex Scene::ncursesMutex;
- std::mutex Scene::freezeMutex;
- std::condition_variable Scene::freezeCondition;
-
- Scene::Scene()
- {
-
- }
-
- Scene::~Scene()
- {
-
- }
-
- void Scene::init(int xRes, int yRes)
- {
- xMax = xRes;
- yMax = yRes;
- running = true;
- initialized = true;
- }
-
- int Scene::getPoints()
- {
- return points;
- }
-
- bool Scene::isFreezed()
- {
- return freezed;
- }
-
- void Scene::freeze()
- {
- const int idleSeconds = 10;
-
- std::unique_lock<std::mutex> freezeLock(freezeMutex);
- freezed = true;
- sleep(idleSeconds);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- freezed = false;
- freezeCondition.notify_all();
- }
-
- void Scene::terminateAll()
- {
- Scene::running = false;
- }
|