-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
executable file
·115 lines (95 loc) · 2.19 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
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
111
112
113
114
115
#include <windows.h>
#include "game.h"
HWND hwnd;
gfx* GFX;
int x, y, mstate;
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
GFX->KillDDraw();
delete GFX;
ShowCursor(TRUE);
PostQuitMessage(0);
break;
case WM_LBUTTONDOWN:
mstate = DOWN;
y = HIWORD(lparam);
x = LOWORD(lparam);
MouseBurgers(x,y,mstate);
break;
case WM_LBUTTONUP:
mstate = UP;
y = HIWORD(lparam);
x = LOWORD(lparam);
MouseBurgers(x,y,mstate);
break;
case WM_KEYDOWN:
switch(wparam)
{
case VK_ESCAPE:
DestroyWindow(hWnd);
break;
}
break;
case WM_RBUTTONUP:
mstate = RIGHT;
MouseBurgers(0,0,mstate);
break;
case WM_MOUSEMOVE:
y = HIWORD(lparam);
x = LOWORD(lparam);
break;
}
return DefWindowProc(hWnd,msg,wparam,lparam);
}
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinst, LPSTR CmdLine, int nShowCmd)
{
WNDCLASS wndclass;
MSG msg;
wndclass.cbClsExtra = 0;
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance = hinstance;
wndclass.lpszClassName = "shortclass";
wndclass.lpszMenuName = NULL;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = (WNDPROC)WndProc;
wndclass.cbWndExtra = 0;
RegisterClass(&wndclass);
hwnd = CreateWindow("shortclass","short order",WS_POPUP,0,0,320,240,NULL,NULL,hinstance,NULL);
ShowWindow(hwnd,nShowCmd);
UpdateWindow(hwnd);
GFX = new gfx;
GFX->InitDDraw(hwnd);
ShowCursor(FALSE);
g_timer.Init();
init();
while(1)
{
if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
{
if(!GetMessage(&msg,NULL,0,0))
return msg.wParam;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else{
GFX->Clear(0xFFFFFFFF);
UpdateOrders();
UpdateBurgers();
DrawBackground(GFX);
DrawOrders(GFX);
DrawScore(GFX);
DrawBurgers(GFX);
GFX->DrawImage(x-16,y-16,CURSOR);
GFX->Present();
}
}
return msg.wParam;
}