-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
60 lines (49 loc) · 1.07 KB
/
main.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
#include <Windows.h>
#include <cassert>
#include <cstdio>
#include "DiceInvaders.h"
#include "SpaceInvaderEngine.h"
#include "Gloabals.h"
class DiceInvadersLib
{
public:
explicit DiceInvadersLib(const char* libraryPath)
{
m_lib = LoadLibrary(libraryPath);
assert(m_lib);
DiceInvadersFactoryType* factory = (DiceInvadersFactoryType*)GetProcAddress(
m_lib, "DiceInvadersFactory");
m_interface = factory();
assert(m_interface);
}
~DiceInvadersLib()
{
FreeLibrary(m_lib);
}
IDiceInvaders* get() const
{
return m_interface;
}
private:
DiceInvadersLib(const DiceInvadersLib&);
DiceInvadersLib& operator=(const DiceInvadersLib&);
private:
IDiceInvaders* m_interface;
HMODULE m_lib;
};
int APIENTRY WinMain(
HINSTANCE instance,
HINSTANCE previousInstance,
LPSTR commandLine,
int commandShow)
{
DiceInvadersLib lib("DiceInvaders.dll");
IDiceInvaders* system = lib.get();
SpaceInvaderEngine &engine = Globals::GetSpaceInvaderEngine();
engine.SetSystem(system);
engine.Init();
engine.RunGame();
engine.Deinit();
//system->destroy();
return 0;
}