-
Notifications
You must be signed in to change notification settings - Fork 0
/
ao.cpp
executable file
·110 lines (88 loc) · 2.47 KB
/
ao.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "stdafx.h"
/**********************************************************************/
HINSTANCE g_hinstance;
HWND g_hwnd;
bool g_running = true;
const char* g_appName = "Albertum-OnLine";
/****************** FUNCIONES EXTERNAS ********************************/
LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM w, LPARAM l);
/**********************************************************************/
bool createWindow();
/**********************************************************************/
int APIENTRY WinMain(HINSTANCE hinstance, HINSTANCE,
LPSTR cmdLine, int)
{
g_hinstance = hinstance;
if(!createWindow())
return -1;
SetFocus(g_hwnd);
ShowWindow(g_hwnd, SW_SHOWNORMAL);
UpdateWindow(g_hwnd);
// STARTUP
if(!game_startup())
{
game_shutdown();
return -1;
}
/************** IMPORTANTE ****************/
game_main();
/************** IMPORTANTE ****************/
while(g_running)
{
MSG msg;
if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
return msg.wParam;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
game_update();
}
// SHUTDOWN
game_shutdown();
return 0;
}
/*********************************************************************/
bool createWindow()
{
WNDCLASSEX wc;
ZeroMemory(&wc, sizeof(wc));
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hIconSm = LoadIcon(0, IDI_WINLOGO);
wc.hInstance = g_hinstance;
wc.lpfnWndProc = wndProc;
wc.lpszClassName = g_appName;
wc.cbSize = sizeof(wc);
wc.style = CS_VREDRAW | CS_HREDRAW;
if(RegisterClassEx(&wc))
{
#ifndef DEBUG_MODE
g_hwnd = CreateWindowEx(
WS_EX_TOPMOST,
g_appName,
g_appName,
WS_POPUP | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, g_hinstance, 0);
#else
g_hwnd = CreateWindow(g_appName,
g_appName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
g_hinstance,
NULL);
#endif
return g_hwnd != 0;
}
return false;
}
/**********************************************************************/