I'm not sure if this is exactly the right forum for this, so I apologise if it isn't.
Im writing game code for a basic slot machine. To test fuctionality I've written a basic prototype. When ever a certain area of teh screen is clicked, the pictures on display are radomised and redisplayed. The three possible images can come from a group of 6.
The program compiles and links fine, however as soon as I open it it crashes, ive never come across a problem like this, however could it be caused by a memory managment mistake I'm not seeing?
The problem should be within this code, as the game engine and all other include files come as example with a book I'm learning from, and have caused no problems in past. The code of the main program is included below.
Thanks in advance for your help.
Code://----------------------------------------------------------------- // Include Files //----------------------------------------------------------------- #include "slot.h" //----------------------------------------------------------------- // Game Engine Functions //----------------------------------------------------------------- BOOL GameInitialize(HINSTANCE hInstance) { // Create the game engine g_pGame = new GameEngine(hInstance, TEXT("UFO"), TEXT("UFO"), NULL, NULL, 600, 600); if (g_pGame == NULL) return FALSE; // Set the frame rate g_pGame->SetFrameRate(0); // Store the instance handle g_hInstance = hInstance; return TRUE; } void GameStart(HWND hWindow) { // Create and load the background and saucer bitmaps int randselect; HDC hDC = GetDC(hWindow); g_pBackground = new Bitmap(hDC, IDB_BACKGROUND, g_hInstance); g_pTile[0] = new Bitmap(hDC, IDB_TILE1, g_hInstance); g_pTile[1] = new Bitmap(hDC, IDB_TILE2, g_hInstance); g_pTile[2] = new Bitmap(hDC, IDB_TILE3, g_hInstance); g_pTile[3] = new Bitmap(hDC, IDB_TILE4, g_hInstance); g_pTile[4] = new Bitmap(hDC, IDB_TILE5, g_hInstance); g_pTile[5] = new Bitmap(hDC, IDB_TILE6, g_hInstance); srand(GetTickCount()); // Set the initial saucer position and speed randselect = rand() % 5; g_pTile1 = g_pTile[randselect]; randselect = rand() % 5; g_pTile2 = g_pTile[randselect]; randselect = rand() % 5; g_pTile3 = g_pTile[randselect]; g_iTile1X = 50; g_iTile1Y = 100; g_iTile2X = 200; g_iTile2Y = 100; g_iTile3X = 400; g_iTile3Y = 100; } void GameEnd() { // Cleanup the background and saucer bitmaps delete g_pBackground; delete g_pTile[6]; delete g_pTile1; delete g_pTile2; delete g_pTile3; // Cleanup the game engine delete g_pGame; } void GameActivate(HWND hWindow) { } void GameDeactivate(HWND hWindow) { } void GamePaint(HDC hDC) { // Draw the background and saucer bitmaps g_pBackground->Draw(hDC, 0, 0); g_pTile1->Draw(hDC, g_iTile1X, g_iTile1Y, TRUE); g_pTile2->Draw(hDC, g_iTile2X, g_iTile2Y, TRUE); g_pTile3->Draw(hDC, g_iTile3X, g_iTile3Y, TRUE); } void GameCycle() { } void HandleKeys() { } void MouseButtonDown(int x, int y, BOOL bLeft) { int randselect; if (bLeft) { if ((x >= 200 && x <= 400) && (y >= 500 && y <= 600 )) { randselect = rand() % 5; g_pTile1 = g_pTile[randselect]; randselect = rand() % 5; g_pTile2 = g_pTile[randselect]; randselect = rand() % 5; g_pTile3 = g_pTile[randselect]; InvalidateRect(g_pGame->GetWindow(), NULL, FALSE); } else { InvalidateRect(g_pGame->GetWindow(), NULL, FALSE); } } else { InvalidateRect(g_pGame->GetWindow(), NULL, FALSE); } } void MouseButtonUp(int x, int y, BOOL bLeft) { } void MouseMove(int x, int y) { }



LinkBack URL
About LinkBacks


