File tree 6 files changed +37
-28
lines changed 6 files changed +37
-28
lines changed Original file line number Diff line number Diff line change 5
5
6
6
namespace hb
7
7
{
8
+ // ! A class for measuring time intervals
8
9
class Clock
9
10
{
10
11
public:
12
+ // ! Class constructor
13
+ /* !
14
+ Initializes a new instance of Clock wich starts measuring
15
+ the time since it is created.
16
+ */
11
17
Clock ();
18
+ // ! Class destructor
12
19
~Clock ();
20
+ // ! Returns the Time elapsed since creation or last reset
13
21
Time getElapsedTime () const ;
22
+ // ! Returns the Time elapsed since creation or last reset and resets the counter
14
23
Time reset ();
15
24
16
25
private:
17
26
std::chrono::high_resolution_clock::time_point m_time_point;
18
27
};
19
28
}
20
- #endif
29
+ #endif
Original file line number Diff line number Diff line change @@ -23,6 +23,26 @@ Game::~Game()
23
23
}
24
24
25
25
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
+
26
46
void Game::addScene (Scene&& scene)
27
47
{
28
48
s_scenes.insert (std::pair<std::string, Scene>(scene.getName (), scene));
Original file line number Diff line number Diff line change @@ -22,20 +22,20 @@ namespace hb
22
22
Scene (Scene&& other);
23
23
~Scene ();
24
24
25
- static GameObject* makeGameObject (std::map<std::string, std::string>& properties);
26
25
27
26
void init ();
28
27
void exit ();
29
28
const std::string& getName () const ;
30
29
void setExit (std::function<void (void )>&& exit);
31
30
32
- private :
31
+ protected :
33
32
std::function<void (void )> m_init, m_exit;
34
33
std::string m_name;
35
34
};
36
35
37
36
~Game ();
38
37
38
+ static GameObject* makeGameObject (std::map<std::string, std::string>& properties);
39
39
static void addScene (Scene&& scene);
40
40
static void setScene (const std::string& name);
41
41
static void run ();
Original file line number Diff line number Diff line change @@ -29,26 +29,6 @@ Game::Scene::~Scene()
29
29
}
30
30
31
31
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
-
52
32
void Game::Scene::init ()
53
33
{
54
34
m_init ();
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ double Time::asSeconds() const
20
20
}
21
21
22
22
23
- int Time::asMiliseconds () const
23
+ int Time::asMilliseconds () const
24
24
{
25
25
return m_microseconds/1000 ;
26
26
}
@@ -40,10 +40,10 @@ Time Time::seconds(double seconds)
40
40
}
41
41
42
42
43
- Time Time::miliseconds (int miliseconds )
43
+ Time Time::milliseconds (int milliseconds )
44
44
{
45
45
Time t;
46
- t.m_microseconds = miliseconds * 1000 ;
46
+ t.m_microseconds = milliseconds * 1000 ;
47
47
return t;
48
48
}
49
49
Original file line number Diff line number Diff line change @@ -9,11 +9,11 @@ namespace hb
9
9
Time ();
10
10
~Time ();
11
11
double asSeconds () const ;
12
- int asMiliseconds () const ;
12
+ int asMilliseconds () const ;
13
13
long long asMicroseconds () const ;
14
14
15
15
static Time seconds (double seconds);
16
- static Time miliseconds (int miliseconds );
16
+ static Time milliseconds (int milliseconds );
17
17
static Time microseconds (long long microseconds);
18
18
static Time deltaTime;
19
19
You can’t perform that action at this time.
0 commit comments