Sorry if this is a dumb question, but im rather new to Win32 programming. The error im getting is this:
Quote:Error 1 fatal error RC1004: unexpected end of file found c:\Documents and Settings\mads\Dokumenter\Visual Studio 2005\Projects\SexyEngine1\SexyEngine1\Resource.h 4
and has to do with this file .h file:
(Resource.h)
//iconer Range: 1000-1999
#define IDI_BLIZZARD 1000
#define IDI_BLIZZARD_SM 1001
however i cant realy see how i can mess 2 lines up.. So here goes the rest of the code:
(SexyEngine1.h)
//SexyEngine class
class SexyEngine
{
protected:
//medlems variabler
static SexyEngine* m_pSexyEngine;
HINSTANCE m_hInstance;
HWND m_hWindow;
TCHAR m_szWindowClass[32];
TCHAR m_szTitle[32];
WORD m_wIcon, m_wSmallIcon;
int m_iWidth, m_iHeight;
int m_iFrameDelay;
BOOL m_bSleep;
public:
//constructor/destructor
SexyEngine(HINSTANCE hInstance, LPTSTR szWindoClass, LPTSTR szTitle, WORD wIcon, WORD wSmallIcon, int iWidth = 640, int iHeight = 480);
virtual ~SexyEngine();
//generale metoder
static SexyEngine* GetEngine() {return m_pSexyEngine;};
BOOL Initialize(int iCmdShow);
LRESULT HandleEvent(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam);
//adgangs metoder
HINSTANCE GetInstance() {return m_hInstance;};
HWND GetWindow() {return m_hWindow;};
void SetWindow(HWND hWindow) { m_hWindow = hWindow;};
LPTSTR GetTitle() {return m_szTitle;};
WORD GetIcon() {return m_wIcon;};
WORD GetSmallIcon() {return m_wSmallIcon;};
int GetWidth() {return m_iWidth;};
int GetHeight() {return m_iHeight;};
int GetFrameDelay() {return m_iFrameDelay;};
void SetFrameRate (int iFrameRate) { m_iFrameDelay = 1000 / iFrameRate;};
BOOL GetSleep() {return m_bSleep;};
void SetSleep(BOOL bSleep) {m_bSleep = bSleep;};
};//end of SexyEngine class
(Storm.h)
#pragma once
//include filer
#include <windows.h>
#include "Resource.h"
#include "SexyEngine1.h"
//globale variabler
SexyEngine* g_pGame;
(Storm.rc)
#include "Resource.h"
//iconer
IDI_BLIZZARD ICON "C:\Documents and Settings\mads\Dokumenter\roflfjering.ico"
IDI_BLIZZARD ICON "C:\Documents and Settings\mads\Dokumenter\roflfjering.ico"
(SexyEngine.cpp)
[source lang ="cpp"]
#include "SexyEngine1.h"
//static variabel initialisation
SexyEngine* SexyEngine::m_pSexyEngine = NULL;
//windows funktioner
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
{
MSG msg;
static int iTickTrigger = 0;
int iTickCount;
if (GameInitialize(hInstance))
{
//initialiser(not to self: er begyndt at hade det ord..) SexyEngine
if (!SexyEngine::GetEngine()->Initialize(iCmdShow))
return FALSE;
while (TRUE)
{
if( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
//proces beskeden
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
//vær sikker på at engien ikke sover
if (!SexyEngine::GetEngine()->GetSleep())
{
iTickCount = GetTickCount();
if (iTickCount > iTickTrigger)
{
iTickTrigger = iTickCount + SexyEngine::GetEngine()->GetFrameDelay();
GameCycle();
}
}
}
}
return (int)msg.wParam;
}
GameEnd();
return TRUE;
}
LRESULT CALLBACK WndProc(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam)
{
return SexyEngine::GetEngine()->HandleEvent(hWindow, msg, wParam, lParam);
}
//game engine constructor(s) + destructor definationer
SexyEngine::SexyEngine(HINSTANCE hInstance, LPTSTR szWindowClass, LPTSTR szTitle, WORD wIcon, WORD wSmallIcon, int iWidth, int iHeight)
{
//sætter member variablerne for SexyEngine
m_pSexyEngine = this;
m_hInstance = hInstance;
m_hWindow = NULL;
if (lstrlen(szWindowClass) > 0)
lstrcpy(m_szWindowClass, szWindowClass);
if (lstrlen(szTitle) > 0)
lstrcpy(m_szTitle, szTitle);
m_wIcon = wIcon;
m_wSmallIcon = wSmallIcon;
m_iWidth = iWidth;
m_iHeight = iHeight;
m_iFrameDelay = 50; //20 fps default
m_bSleep = TRUE;
}
SexyEngine::~SexyEngine()
{
}
//SexyEngine generale Metoder
BOOL SexyEngine::Initialize(int iCmdShow)
{
WNDCLASSEX wndclass;
wndclass.cbSize =sizeof(wndclass);
wndclass.style =CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = m_hInstance;
wndclass.hIcon = LoadIcon(m_hInstance, MAKEINTRESOURCE(GetIcon()));
wndclass.hIconSm = LoadIcon(m_hInstance, MAKEINTRESOURCE(GetSmallIcon()));
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = m_szWindowClass;
//registrer window classen
if (!RegisterClassEx(&wndclass))
return FALSE;
//vidnuet bliver lavet i midten
int iWindowWidth = m_iWidth + GetSystemMetrics(SM_CXFIXEDFRAME) * 2, iWindowHeight = m_iHeight + GetSystemMetrics(SM_CYFIXEDFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION);
if (wndclass.lpszMenuName != NULL)
iWindowHeight += GetSystemMetrics(SM_CYMENU);
int iXWindowPos = (GetSystemMetrics(SM_CXSCREEN) - iWindowWidth) / 2, iYWindowPos = (GetSystemMetrics(SM_CYSCREEN) - iWindowHeight) / 2;
//Laver vinduet
m_hWindow = CreateWindow(m_szWindowClass, m_szTitle, WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZE, iXWindowPos, iYWindowPos, iWindowWidth, iWindowHeight, NULL, NULL, m_hInstance, NULL);
if (!m_hWindow)
return FALSE;
//vis og updater vinduet
ShowWindow(m_hWindow, iCmdShow);
UpdateWindow(m_hWindow);
return TRUE;
}
LRESULT SexyEngine::HandleEvent(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam)
{
//efter at have sendt alle 'beskeder' til SexyEngines HandleEvent()
switch (msg)
{
case WM_CREATE:
//sætter spille vinduet og starter spillet
SetWindow(hWindow);
GameStart(hWindow);
return 0;
case WM_SETFOCUS:
//activer spillevinduet og opdater sleep statusen
GameActivate(hWindow);
SetSleep(FALSE);
return 0;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC = BeginPaint(hWindow, &ps);
//tegn spillet
GamePaint(hDC);
EndPaint(hWindow, &ps);
return 0;
case WM_DESTROY:
//slut spillet og skrid fra applicationen
GameEnd();
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWindow, msg, wParam, lParam);
}
// mads ztyrer!
(Storm.cpp)
#include "Storm.h"
//game engine funktioner
BOOL GameInitialize(HINSTANCE hInstance)
{
g_pGame = new SexyEngine(hInstance, TEXT("Fjering"), TEXT("FJERING"), IDI_BLIZZARD, IDI_BLIZZARD_SM);
if (g_pGame == NULL)
return FALSE;
//sætter frame raten
g_pGame->SetFrameRate(15);
return TRUE;
}
void GameStart(HWND hWindow)
{
//Seeder RANDom nummer generatoren
srand(GetTickCount());
}
void GameEnd()
{
//rydder op i game engine
delete g_pGame;
}
void GameActivate(HWND hWindow)
{
HDC hDC;
RECT rect;
//tegn hvad der sker på skærmen
GetClientRect(hWindow,&rect);
hDC = GetDC(hWindow);
DrawText(hDC,TEXT("Her kommer der en storm!"), -1, &rect, DT_SINGLELINE| DT_CENTER | DT_VCENTER);
ReleaseDC(hWindow,hDC);
}
void GameDeactivate(HWND hWindow)
{
HDC hDC;
RECT rect;
//tegn deaktiverings tekst op skærmen
GetClientRect(hWindow, &rect);
hDC = GetDC(hWindow);
DrawText(hDC,TEXT("Stormen er ovre."), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
ReleaseDC(hWindow, hDC);
}
void GamePaint(HDC hDC)
{
}
void GameCycle()
{
HDC hDC;
HWND hWindow = g_pGame->GetWindow();
//tegn storm partiklerne på skærmen
hDC = GetDC(hWindow);
DrawIcon(hDC, rand() % g_pGame->GetWidth(), g_pGame->GetHeight(), (HICON)(WORD)GetClassLong(hWindow, GCL_HICON));
ReleaseDC(hWindow, hDC);
}
.. and thats it. Hopefully this isnt such a stupid question that i have to change my nick [embarrass]
thanks!, Mads
•°*”˜˜”*°•.˜”*°•..•°*”˜.•°*”˜˜”*°•..•°*”˜˜”*°•.˜”*°•.˜”*°•. Mads .•°*”˜.•°*”˜.•°*”˜˜”*°•.˜”*°•..•°*”˜.•°*”˜.•°*”˜ ˜”*°•.˜”*°•.˜”*°•..•°*”˜I am going to live forever... or die trying!