-
Notifications
You must be signed in to change notification settings - Fork 0
/
GjeTeA.cpp
87 lines (67 loc) · 2.34 KB
/
GjeTeA.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//============================================================================
// Name : GjeTeA.cpp
// Author : Piotr Piórkowski, Mateusz Nojek
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include "appwindow.h"
//#define BEZ_SERWERA
int main()
{
SSJ::DataContainer::mutex.lock();
SSJ::DataContainer::ScreenWidth = 1240;
SSJ::DataContainer::ScreenHeight = 600;
SSJ::DataContainer::ScreenMargin = 64;
time_t timev;
time(&timev);
ostringstream oss;
oss << (int)timev;
SSJ::Config::PlayerId = oss.str();
SSJ::Point screenPosition;
screenPosition.x = 0;
screenPosition.y = 0;
SSJ::DataContainer::ScreenPosition = screenPosition;
SSJ::AppWindow *Game = new SSJ::AppWindow;
SSJ::Map *mapa = new SSJ::Map("mapa.txt");
SSJ::GameLayer *pierwsza = mapa;
SSJ::GameLayer *druga = new SSJ::GameLayer("druga", true);
SSJ::GameLayer *trzecia = new SSJ::GameLayer("trzecia", true);
SSJ::GameLayer *czwarta = new SSJ::GameLayer("czwarta", true);
SSJ::LayerContainer::AddGameLayer(pierwsza);
SSJ::LayerContainer::AddGameLayer(druga);
SSJ::LayerContainer::AddGameLayer(trzecia);
SSJ::LayerContainer::AddGameLayer(czwarta);
#ifdef BEZ_SERWERA
SSJ::MainPlayer * mainPlayer = new SSJ::MainPlayer;
trzecia->addObject(mainPlayer);
#endif
/*sf::Texture cursor;
cursor.loadFromFile("aim.png");
sf::Sprite sprite(cursor);
sprite.setPosition(sf::Mouse::getPosition(Game).x, sf::Mouse::getPosition(Game).y);*/
Game->AddLayer(pierwsza);
Game->AddLayer(druga);
Game->AddLayer(trzecia);
Game->AddLayer(czwarta);
SSJ::LayerContainer::GetGameLayer("czwarta")->addObject(Game->hud);
SSJ::DataContainer::window = Game->appWindow;
sf::Clock clk;
float fps = 0;
Game->LoadObjects();
SSJ::DataContainer::mutex.unlock();
while( Game->appWindow->isOpen())
{
SSJ::DataContainer::mutex.lock();
Game->Events();
Game->Update();
Game->Draw();
Game->appWindow->display();
SSJ::DataContainer::mutex.unlock();
sf::sleep(sf::milliseconds(10));
fps = 1/ clk.getElapsedTime().asSeconds();
clk.restart();
//cout << "FPS: " << fps << endl;
}
return 0;
}