#define WIN32_LEAN_AND_MEAN
#define STR(y) (LPTSTR)y.c_str()
//include files
#include <windows.h>
#include <stdlib.h>
#include "time.h"
#include <string>
#include "Core.h"
enum State
{
LEV_LOAD,
LEV_UPDATE,
MENU_LOAD,
MENU_UPDATE
};
using std::string;
int paintCount;
bool running = true;
LRESULT CALLBACK WndProc( HWND hWnd, UINT messg,
WPARAM wParam, LPARAM lParam );
void aFunction();
int WINAPI WinMain( HINSTANCE hInst, /*Win32 entry-point routine */
HINSTANCE hPreInst,
LPSTR lpszCmdLine,
int nCmdShow )
{
#pragma unused( lpszCmdLine )
WNDCLASS wc;
clsKeyboard keyboard;
MSG lpMsg;
HWND hWnd;
//register the window class
if(!hPreInst) /*set up window class and register it */
{
wc.lpszClassName = "Something";
wc.hInstance = hInst;
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.lpszMenuName = NULL;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.style = 0;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
if(!RegisterClass(&wc))
{
MessageBox(NULL, "Error Registering Window Class", "Error", MB_OK);
return false;
}
}
//load information from files
LPTSTR tempStr = "";
string root = "";
string directory = "";
string err = "";
DWORD temp;
//get the root directory
GetCurrentDirectory(temp, tempStr);
root = tempStr;
for(int x = 0; x < root.length(); x++)
if(root[x] == '\\')
root[x] = '/';
//start loading files
directory = root + "/Animations/Animations.ini";
InitFile *initAnim = new InitFile(STR(directory));
if(initAnim -> failed())
{
err = "Failed to Open " + directory;
MessageBox(NULL, STR(err), "Error", MB_OK);
return false;
}
directory = root + "/Objects.ini";
InitFile *initObj = new InitFile(STR(directory));
if(initObj -> failed())
{
err = "Failed to Open " + directory;
MessageBox(NULL, STR(err), "Error", MB_OK);
return false;
}
directory = root + "/Ships.ini";
InitFile *initShuttle = new InitFile(STR(directory));
if(initShuttle -> failed())
{
err = "Failed to Open " + directory;
MessageBox(NULL, STR(err), "Error", MB_OK);
return false;
}
directory = root + "/Weapons.ini";
InitFile *initWeapons = new InitFile(STR(directory));
if(initWeapons -> failed())
{
err = "Failed to Open " + directory;
MessageBox(NULL, STR(err), "Error", MB_OK);
return false;
}
directory = root + "/User.ini";
InitFile *initUser = new InitFile(STR(directory));
if(initUser -> failed())
{
err = "Failed to Open " + directory;
MessageBox(NULL, STR(err), "Error", MB_OK);
return false;
}
directory = root + "/Levels/Levels.ini";
InitFile *initLevels = new InitFile(STR(directory));
if(initUser -> failed())
{
err = "Failed to Open " + directory;
MessageBox(NULL, STR(err), "Error", MB_OK);
return false;
}
double totalTime = GetTickCount();
double currentTick = GetTickCount();
int elapsedTime = 2000;
State mode = LEV_LOAD;
while(running)
{
currentTick = GetTickCount();
aFunction();
if(keyboard.keyIsDown(VK_ESCAPE))
running = false;
else
{
if(GetMessage(&lpMsg, NULL, 0, 0))
{
TranslateMessage(&lpMsg);
DispatchMessage(&lpMsg);
}
UpdateWindow(hWnd);
}
while((GetTickCount() - currentTick) < ((1 / 60) * 100))
running = running;
elapsedTime = GetTickCount() - currentTick;
}
return( lpMsg.wParam );
}
void aFunction()
{
long currentX = 0;
long currentY = 0;
long currentWidth = 0;
long currentHeight = 0;
string bkg = "";
POINT sSize, lSize;
LPTSTR tempStr = "";
string root = "";
string err = "";
DWORD temp;
DEVMODE dm;
//get the root directory
GetCurrentDirectory(temp, tempStr);
root = tempStr;
//switch out all '/' with '\'
for(int x = 0; x < root.length(); x++)
if(root[x] == '\\')
root[x] = '/';
string path = "/";
}
LRESULT CALLBACK WndProc( HWND hWnd, UINT messg, /*callback procedure */
WPARAM wParam, LPARAM lParam )
{
switch(messg)
{
case WM_PAINT:
paintCount++;
break;
case WM_DESTROY:
PostQuitMessage(0);
running = false;
break;
default:
return( DefWindowProc( hWnd, messg, wParam, lParam ) );
}
return(0L);
}