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)
{
}