-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
163 lines (143 loc) · 5.27 KB
/
Copy pathmain.cpp
File metadata and controls
163 lines (143 loc) · 5.27 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include <SFML/Graphics.hpp>
#include <string>
#include "../koporso/ShapeSO.h"
#include "../koporso/SimpleImage.h"
#include "../koporso/Creature.h"
#include "../koporso/Thing.h"
#include "../koporso/Protagonist.h"
#include "gameview.h"
#include "utility.h"
#include "fixedground.h"
#include "Background.h"
#include "../koporso/Animation.h"
#include "../koporso/TestingAnimation.h"
#include "sceneHandler.h"
#include "ScreenRoot.h"
int main()
{
initializeUtility();
ShapeSO sos;
/* FixedGround fg("../koporso/Resources/fixedGround.jpg",-5000,1000,0,10880,696);
//Thing thing("../koporso/Resources/The_Thing.png",0,0,-1000);
Creature thing("../koporso/Resources/The_Thing.png", 0, 0, -1000, 1977, 1939);
Creature creature1("../koporso/Resources/Creature.png", 30, 800, 2, 319, 308);
Background background("../koporso/Resources/background.jpg", 0, 0, -10000, 0.2);
ScreenRoot::access().addBackground(&background);
ScreenRoot::access().addStaticSo(&fg);
ScreenRoot::access().addStaticSo(&thing);
ScreenRoot::access().addStaticSo(&creature1);
///test junk being added
*/
///loadFileFromScene will call ScreenRoot::WipeRoot() and wipe junk
///then load all objects from file except the protagonist
loadSceneFromFile("../koporso/Resources/fileLoadTest.txt");
Protagonist protagonist("../koporso/Resources/protagonist.png",1500, 600, 10, (ScreenRoot::access()).theGround);
ScreenRoot::access().addDinamicSo(&protagonist);
// Initializing the screen
ScreenRoot::access().window = new sf::RenderWindow(desktop, "SFML Window", sf::Style::Fullscreen); //creates fullscreen window
ScreenRoot::access().window->setView(gameView.view);
while (ScreenRoot::access().window ->isOpen()) //while the window is open
{
sf::Event event;
while (ScreenRoot::access().window->pollEvent(event))
{
switch(event.type)
{
case sf::Event::KeyPressed :
{
switch(event.key.code)
{
case sf::Keyboard::Escape :
{
ScreenRoot::access().window->close();
break;
}
case sf::Keyboard::Right :
{
protagonist.getEvent(event);
break;
}
case sf::Keyboard::Left :
{
protagonist.getEvent(event);
break;
}
case sf::Keyboard::Up :
{
protagonist.getEvent(event);
break;
}
case sf::Keyboard::Down :
{
protagonist.getEvent(event);
break;
}
default:
{
///fill
}
///more keycases (lower case, upper case...etc) /// HA-HA
}
break;
}
case sf::Event::MouseButtonPressed:
{
if(sos.hit(sf::Mouse::getPosition())) ///test
{
sos.getEvent(event);
}
break;
}
case sf::Event::KeyReleased:
{
switch(event.key.code)
{
case sf::Keyboard::Escape:
{ ScreenRoot::access().window->close();
break;
}
case sf::Keyboard::Right :
{
protagonist.getEvent(event);
break;
}
case sf::Keyboard::Left :
{
protagonist.getEvent(event);
break;
}
case sf::Keyboard::Up :
{
protagonist.getEvent(event);
break;
}
case sf::Keyboard::Down :
{
protagonist.getEvent(event);
break;
}
default:
{
///fill
}
///more keycases (lower case, upper case...etc) /// HA-HA
}
break;
}
default:
{
///fill
}
}
}
//ScreenRoot::access().window->draw(sos.cs);
if (gameClock.getElapsedTime() > lastUpdate + updateTime)
{
ScreenRoot::access().window->clear();
ScreenRoot::access().draw();
ScreenRoot::access().window->display();
lastUpdate = gameClock.getElapsedTime();
}
}
return 0;
}