-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSystem.cpp
More file actions
81 lines (62 loc) · 1.39 KB
/
System.cpp
File metadata and controls
81 lines (62 loc) · 1.39 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
/** @file System.cpp */
#include "System.h"
#include "SDL.h"
#include <iostream>
#include "VideoManager.h"
#include "InputEvent.h"
#include "FileTools.h"
#include "TextSurface.h"
#include "Sprite.h"
#include "Random.h"
#include "Sound.h"
uint32_t System::ticks = 0;
/** @brief Missing multiple initializations and destructors */
void System::initialize(int argc, char** argv)
{
if((SDL_Init(SDL_INIT_VIDEO) == -1))
{
std::cout << "Could not initialize SDL: " << SDL_GetError();
}
//files
FileTools::initialize(argc, argv);
//video
VideoManager::initialize(argc, argv);
Color::initialize();
TextSurface::initialize();
Sprite::initialize();
//audio
Sound::initialize(argc, argv);
//input
InputEvent::initialize();
Random::initialize();
}
/** @brief Many objects need to be destroyed */
void System::quit()
{
Random::quit();
InputEvent::quit();
Sound::quit();
//Sprite::quit();
//TextSurface::quit();
Color::quit();
VideoManager::quit();
//FileTools::quit();
SDL_Quit();
}
/** @brief Add Sound::update() */
void System::update()
{
ticks = SDL_GetTicks();
//Sound::update();
}
/** @brief Returns the number of milliseconds elapsed since the beginning of the program */
uint32_t System::now()
{
return ticks;
}
/** @brief Makes the program sleep
* @param duration duration of the sleep in milliseconds */
void System::sleep(uint32_t duration)
{
SDL_Delay(duration);
}