-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanager.cpp
69 lines (61 loc) · 1.09 KB
/
manager.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
#include "Gui.cpp"
class Manager
{
private:
World *world;
GUI *gui;
public:
Manager()
{
world = new World();
gui = new GUI();
}
void run()
{
bool running = true;
while (running)
{
while (gui->pollEvent())
{
if (gui->getEventType() == sf::Event::Closed)
running = false;
}
handleGame();
gui->show(world);
//sf::sleep(sf::milliseconds(world->getCycleTime()));
}
gui->close();
}
void handleGame()
{
Vector *pos = world->getupMan()->getPosition();
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
pos->y+=4;
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
pos->y-=4;
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
pos->x+=4;
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
pos->x-=4;
}
/*if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
{
dir1+=4;
handleGame2(dir, dir1);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
{
handleGameRT(dir, dir1);
if(b==0)
handleGameRB(dir1, b);
}*/
world->getupMan()->setPosition(pos->x, pos->y);
}
};