Skip to content

Commit 72e82d9

Browse files
author
Alessio Linares
committed
suff
1 parent 87a5e06 commit 72e82d9

File tree

6 files changed

+37
-28
lines changed

6 files changed

+37
-28
lines changed

Core/Clock.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,25 @@
55

66
namespace hb
77
{
8+
//! A class for measuring time intervals
89
class Clock
910
{
1011
public:
12+
//! Class constructor
13+
/*!
14+
Initializes a new instance of Clock wich starts measuring
15+
the time since it is created.
16+
*/
1117
Clock();
18+
//! Class destructor
1219
~Clock();
20+
//! Returns the Time elapsed since creation or last reset
1321
Time getElapsedTime() const;
22+
//! Returns the Time elapsed since creation or last reset and resets the counter
1423
Time reset();
1524

1625
private:
1726
std::chrono::high_resolution_clock::time_point m_time_point;
1827
};
1928
}
20-
#endif
29+
#endif

Core/Game.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,26 @@ Game::~Game()
2323
}
2424

2525

26+
GameObject* Game::makeGameObject(std::map<std::string, std::string>& properties)
27+
{
28+
std::map<std::string, Plugin::ComponentFactory> list = Game::getAllComponentFactories();
29+
GameObject* go = new GameObject;
30+
for (auto it : list)
31+
{
32+
if (properties.find(it.first + ".count") != properties.end())
33+
{
34+
int count = atoi(properties[it.first + ".count"].c_str());
35+
for (int i = 0; i < count; ++i)
36+
{
37+
GameObject::Component* c = it.second(properties, i);
38+
go->addComponent(c);
39+
}
40+
}
41+
}
42+
return go;
43+
}
44+
45+
2646
void Game::addScene(Scene&& scene)
2747
{
2848
s_scenes.insert(std::pair<std::string, Scene>(scene.getName(), scene));

Core/Game.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ namespace hb
2222
Scene(Scene&& other);
2323
~Scene();
2424

25-
static GameObject* makeGameObject(std::map<std::string, std::string>& properties);
2625

2726
void init();
2827
void exit();
2928
const std::string& getName() const;
3029
void setExit(std::function<void(void)>&& exit);
3130

32-
private:
31+
protected:
3332
std::function<void(void)> m_init, m_exit;
3433
std::string m_name;
3534
};
3635

3736
~Game();
3837

38+
static GameObject* makeGameObject(std::map<std::string, std::string>& properties);
3939
static void addScene(Scene&& scene);
4040
static void setScene(const std::string& name);
4141
static void run();

Core/Scene.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,6 @@ Game::Scene::~Scene()
2929
}
3030

3131

32-
GameObject* Game::Scene::makeGameObject(std::map<std::string, std::string>& properties)
33-
{
34-
std::map<std::string, Plugin::ComponentFactory> list = Game::getAllComponentFactories();
35-
GameObject* go = new GameObject;
36-
for (auto it : list)
37-
{
38-
if (properties.find(it.first + ".count") != properties.end())
39-
{
40-
int count = atoi(properties[it.first + ".count"].c_str());
41-
for (int i = 0; i < count; ++i)
42-
{
43-
GameObject::Component* c = it.second(properties, i);
44-
go->addComponent(c);
45-
}
46-
}
47-
}
48-
return go;
49-
}
50-
51-
5232
void Game::Scene::init()
5333
{
5434
m_init();

Core/Time.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ double Time::asSeconds() const
2020
}
2121

2222

23-
int Time::asMiliseconds() const
23+
int Time::asMilliseconds() const
2424
{
2525
return m_microseconds/1000;
2626
}
@@ -40,10 +40,10 @@ Time Time::seconds(double seconds)
4040
}
4141

4242

43-
Time Time::miliseconds(int miliseconds)
43+
Time Time::milliseconds(int milliseconds)
4444
{
4545
Time t;
46-
t.m_microseconds = miliseconds * 1000;
46+
t.m_microseconds = milliseconds * 1000;
4747
return t;
4848
}
4949

Core/Time.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ namespace hb
99
Time();
1010
~Time();
1111
double asSeconds() const;
12-
int asMiliseconds() const;
12+
int asMilliseconds() const;
1313
long long asMicroseconds() const;
1414

1515
static Time seconds(double seconds);
16-
static Time miliseconds(int miliseconds);
16+
static Time milliseconds(int milliseconds);
1717
static Time microseconds(long long microseconds);
1818
static Time deltaTime;
1919

0 commit comments

Comments
 (0)