-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCWorld.cpp
executable file
·88 lines (69 loc) · 1.99 KB
/
CWorld.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
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
#include "Cworld.h"
#include "defFonctions.h"
CWorld::CWorld( HINSTANCE hInstance , HINSTANCE hPrevInstance , LPSTR lpCmdLine , int nShowCmd)
{
//grab instance handle
hInst = hInstance ;
//fill in window class
WNDCLASSEX wc ;
wc.cbClsExtra = 0 ; //no extra class information
wc.cbSize = sizeof ( WNDCLASSEX ) ; //size of structure
wc.cbWndExtra = 0 ; //no extra window information
wc.hbrBackground = ( HBRUSH ) GetStockObject ( BLACK_BRUSH ) ; //black brush
wc.hCursor = NULL ; //no cursor
wc.hIcon = NULL ; //no icon
wc.hIconSm = NULL ; //no small icon
wc.hInstance = hInstance ; //instance handle
wc.lpfnWndProc = DefWindowProc ; //window procedure
wc.lpszClassName = WINDOWCLASS ; //name of class
wc.lpszMenuName = NULL ; //no menu
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC ; //class styles
//register window class
RegisterClassEx ( &wc ) ;
//create window
mainHwnd = CreateWindowEx ( 0 , WINDOWCLASS , WINDOWTITLE , WS_OVERLAPPEDWINDOW , 0 , 0 , 640 , 480 , NULL , NULL , hInstance , NULL ) ;
//show the window
ShowWindow ( mainHwnd , nShowCmd ) ;
//initialization
if (!initD3D())
PostQuitMessage(0);
if (FAILED(input.initDInput()))
PostQuitMessage(0);
input.setFunc(DIK_ESCAPE, quit);
loadMap("map/map1.txt");
CGod *player;
POINT ms;
ms.x = 1;
ms.y = 1;
player = new CGod(ms);
player->setAnimeSet(_units);
_dobjects = new CGoList();
_dobjects->_current = player;
MSG msg ;
//message pump
for ( ; ; )
{
//check for a message
if ( PeekMessage( &msg , NULL , 0 , 0 , PM_REMOVE ) )
{
//message exists
//check for quit message
if ( msg.message == WM_QUIT ) break ;
//translate the message
TranslateMessage ( &msg ) ;
//dispatch the message
DispatchMessage ( &msg ) ;
}
else
gameLoop();
}
}
void CWorld::gameLoop() {
input.getInput();
renderFrame(NULL, NULL);
}
CWorld::~CWorld(void)
{
clearD3D();
input.clearDInput();
}