Пользователь
Регистрация: 22.12.2009
Сообщений: 20
|
Beta версия флеш игры =)
Здравствуйте граждане.
Не кидает в обработку сообщения TIMER не пойму почему
Код:
//2.cpp#include <Windows.h>
#include "resource.h"
class Wnd
{
protected:
WNDCLASSEX wc;
HWND hWnd;
public:
Wnd(LPCTSTR windowName, HINSTANCE hInst, int cmdShow, LRESULT (WINAPI *pWndProc)(HWND, UINT, WPARAM, LPARAM),
LPCTSTR menuName = NULL, int x = CW_USEDEFAULT, int y = 0, int width = CW_USEDEFAULT, int height = 0,
UINT classStyle = CS_HREDRAW | CS_VREDRAW, DWORD windowStyle = WS_OVERLAPPEDWINDOW, HWND hParent = NULL)
{
wc.cbClsExtra = 0;
wc.cbSize = sizeof(WNDCLASSEX);
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON));
wc.hIconSm = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON));
wc.hInstance = hInst;
wc.lpfnWndProc = pWndProc;
wc.lpszClassName = "Wnd";
wc.lpszMenuName = menuName;
wc.style = classStyle;
if (!RegisterClassEx(&wc))
MessageBox(NULL, "Не получается зарегестрировать класс Wnd", "Error", MB_OK | MB_SYSTEMMODAL | MB_ICONERROR);
hWnd = CreateWindow("Wnd", windowName, windowStyle, x, y, width, height, hParent, (HMENU)NULL, hInst, NULL);
if (!hWnd)
{
char text[100] = "Не получается создать окно ";
strcat(text, windowName);
MessageBox(NULL, text, "Error", MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
}
ShowWindow(hWnd, cmdShow);
}
HWND GetHwnd() { return hWnd; }
};
Код:
//1.cpp
#include "2.cpp"
#include <cstdlib>
#include <time.h>
BOOL CALLBACK DifficultyDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int InitOneCR(RECT &rect);
int IsInRect(int x, int y);
bool MaxPops();
void Draw(HDC &hDC, HDC &hMeMDC, HBITMAP &hBitmap, int i);
static struct CnT
{
int rTIMER;
RECT *rShotRects;
} *cnt;
static const int TIMER = WM_TIMER + 100;
static const int TIMER1 = WM_TIMER + 1;
static const int TIMER2 = WM_TIMER + 2;
static const int TIMER3 = WM_TIMER + 3;
static const int TIMER4 = WM_TIMER + 4;
static const int TIMER5 = WM_TIMER + 5;
static bool bStart = false, gameover = false;
static int difficulty;
static int amount;
static int speed;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iShowCmd)
{
MSG msg;
Wnd("Робин Гуд", hInstance, iShowCmd, WndProc, MAKEINTRESOURCE(IDR_MENU1),
200, 200, 700, 700);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
/*
// Определить объект совместимого контекста
HDC hMemDC;
// Создать совместимый контекст
hMemDC = CreateCompatibleDC(hDC);
// Выбрать DDB-растр в совместимый контекст
SelectObject(hMemDC. hBitmap);
// Скопировать изображение из hMemDC в hDC
BitBltChOC, 0. 0, bmpWidth, bmpHeight. hMemDC. 0, 0, SRCCOPY):
// Удалить совместимый контекст
DeleteDC(hMemDC):
*/
BOOL CALLBACK DifficultyDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_GOSU:
case IDC_HASU:
case IDC_NOOB:
bStart = true;
CheckRadioButton(hDlg, IDC_GOSU, IDC_NOOB, LOWORD(wParam));
difficulty = LOWORD(wParam);
return TRUE;
case IDOK:
EndDialog(hDlg, 1);
return TRUE;
}
return FALSE;
default:
break;
}
return FALSE;
}
int IsInRect(int x, int y)
{
for (int i = 0; i < amount; i++)
if ((y < cnt[i].rShotRects->top && y > cnt[i].rShotRects->bottom)
&& (x > cnt[i].rShotRects->left && x < cnt[i].rShotRects->right))
return i;
return 0;
}
bool MaxPops()
{
for (int i = 0; i < amount; i++)
if (cnt[i].rShotRects == NULL)
return false;
return true;
}
int InitOneCR(RECT &rect)
{
int i;
srand(time(NULL));
int x = rand() % (rect.right - 30) + rect.left;
srand(time(NULL));
int y = rand() % (rect.bottom - 30) + rect.top;
for (i = 0; i < amount; i++)
if (cnt[i].rShotRects == NULL)
break;
cnt[i].rShotRects = new RECT();
cnt[i].rShotRects->left = x;
cnt[i].rShotRects->top = y;
cnt[i].rShotRects->right = x + 30;
cnt[i].rShotRects->bottom = y + 30;
return i;
}
void Draw(HDC &hDC, HDC &hMemDC, HBITMAP &hBitmap, int i)
{
hMemDC = CreateCompatibleDC(hDC);
SelectObject(hMemDC, hBitmap);
BitBlt(hDC, cnt[i].rShotRects->left, cnt[i].rShotRects->top,
30, 30, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
}
}
|