I have a problem with a blizzard demo I am writing. It is from gaming programming book by michael morrison. I'm using dev-c++ ide. It involves drawing icons to a window in random locations. I did search the forums and found most people call it the skeleton program that draws skeletons not snowflakes. Anyway here is the main code.
Code:
#include "Blizzard.h"
#include <stdlib.h>
bool GameInitialize(HINSTANCE hInstance)
{
//create game engine
g_pGame = new GameEngine(hInstance, TEXT("Blizzard"),
TEXT("Blizzard"), IDI_BLIZZARD, IDI_BLIZZARD_SM);
if (g_pGame == NULL)
return FALSE;
// set frame rate
g_pGame ->SetFrameRate(1);
return TRUE;
}
void GameStart(HWND hWindow)
{
// seed random number generator
srand(GetTickCount());
}
void GameEnd()
{
// game clean up engine
delete g_pGame;
}
void GameActivate(HWND hWindow)
{
HDC hDC;
RECT rect;
// draw activation text on game screen
GetClientRect(hWindow, &rect);
hDC = GetDC(hWindow);
DrawText(hDC, TEXT("Here comes the Blizzard!"), -1, &rect, DT_SINGLELINE|DT_CENTER|DT_VCENTER);
ReleaseDC(hWindow, hDC);
}
void GameDeactivate(HWND hWindow)
{
HDC hDC;
RECT rect;
// draw deactivation text on game screen
GetClientRect(hWindow, &rect);
hDC = GetDC(hWindow);
DrawText(hDC, TEXT("The Blizzard has passed."), -1, &rect, DT_SINGLELINE|DT_CENTER|DT_VCENTER);
ReleaseDC(hWindow, hDC);
}
void GamePaint(HDC hDC)
{
}
void GameCycle()
{
HDC hDC;
HWND hWindow = g_pGame ->GetWindow();
// draw snowflake at random positisons on screen
hDC = GetDC(hWindow);
DrawIcon(hDC, rand() % g_pGame->GetWidth(), g_pGame->GetHeight(), (HICON)(WORD)GetClassLong(hWindow, GCL_HICON));
ReleaseDC(hWindow, hDC);
}
I hope the above is readable. Tried to follow the sticky FAQ
The error I get is
warning: cast to pointer from integer of different size related to the line DrawIcon etc, hopefully in bold above.
It compiles but when run I get a small icon in titlebar but no sign of any snowflakes appearing on the screen. Interestingly if I minimise the window and then maximise it displays text called "here comes the blizzard!". This must be invoking msg handler GameActivate.
Any help would be greatly appreciated (if you need to see other headers/resource let me know).