Hello, I have what seems to be a very common problem but after doing much research and trying to fix myself, I am unable to resolve the issue. I receive the following error when compiling my win32, directx 9 program:
e:\...\game.cpp(228) : fatal error C1004: unexpected end-of-file found
I receive this error and a bunch of preceding syntax errors. This occurs in three different files within my project...I'm using visual c++ 2008 express and DirectX SDK 2010(june)...shouldn't matter...
Here is the code from game.cpp:
#include "Game.h"
#include "Entity.h"
#include "dxManager.h"
#include "diManager.h"
/* Init the one and only ProjectManager */
static dxManager& dxMgr = dxManager::getInstance();
/* Get a reference to the DirectInput Manager */
static diManager& diMgr = diManager::getInstance();
CGame::CGame(IDirect3DDevice9 *device) : m_d3ddev(device)
{
m_entity = NULL;
curX = (SCREEN_WIDTH/2) - (IMAGE_WIDTH/2);
curY = (SCREEN_HEIGHT/2) - (IMAGE_HEIGHT/2);
arrows = dxMgr.getSurfaceFromBitmap(L"Cross Hairs.bmp");
mouseRect.top = 0;
mouseRect.bottom = mouseRect.top + 48;
mouseRect.left = 0;
mouseRect.right = mouseRect.left + 48;
if (NULL == arrows) {MessageBox(NULL, L"Unable to 'Load Cursor'", L"ERROR", MB_OK);}
mouseOldZ = diMgr.getCurMouseZ();
}
CGame::~CGame(void)
{
if (m_entity)
{
delete m_entity;
m_entity=0;
}
if (m_d3ddev)
{
m_d3ddev->Release();
m_d3ddev=0;
}
}
/********************************************************************
* init
* Initializes the game object. This involves setting the initial
* game state and preparing the timer
********************************************************************/
bool CGame::init(HWND wndHandle)
{
QueryPerformanceFrequency(&timerFreq);
// Initialize the in-game objects
/*if (!initGameObjects())
{
MessageBox(wndHandle, L"Unable to 'Init GameObjects'", L"ERROR", MB_OK);
return false;
}*/
// setup the camera for the game
//dxMgr.createCamera(1.0f, 450.0f); // near clip plane, far clip plane
//dxMgr.moveCamera(D3DXVECTOR3(0.0f, 2.0f, 10.0f));
//dxMgr.pointCamera(D3DXVECTOR3(0.0f, 0.0f, -20.0f));
//pCam = new CCamera(D3DXVECTOR3(0,0,-10.0));
return true;
}
/********************************************************************
* shutdown
* This function is used to release any memory that the game
* uses
********************************************************************/
void CGame::shutdown(void)
{
dxMgr.shutdown();
}
bool CGame::LoadXFile(LPCTSTR filename, unsigned int firstAnimSet)
{
if(m_entity)
{
MessageBox(NULL, L"Could not 'Create Entity'", L"ERROR", MB_OK);
delete m_entity;
m_entity = 0;
}
m_entity = new CEntity(m_d3ddev);
if(!m_entity->Load(filename))
{
MessageBox(NULL, L"Could not 'Create Entity'", L"ERROR", MB_OK);
delete m_entity;
m_entity = 0;
return false;
}
m_entity->SetAnimationSet(firstAnimSet);
return true;
}
/********************************************************************
* update
* This function is called once per frame. It's used to get the user
* input and move the objects in the game accordingly.
********************************************************************/
int CGame::update(void)
{
// Get the current user input
diMgr.getInput();
// set the destination rectangle
mouseDestRect.top = curY;
mouseDestRect.bottom = mouseDestRect.top + 48;
mouseDestRect.left = curX;
mouseDestRect.right = mouseDestRect.left + 48;
// If the mouse is moved to the left, rotate camera
if (diMgr.getCurMouseX() < 0)
{
//pMan->move(CMan::LEFT, anim_rate);
dxMgr.pCam->Yaw( sin(D3DXToRadian( (FLOAT)diMgr.getCurMouseX() ) )/ 8 );
}
// If the mouse is moved to the right, rotate camera
if (diMgr.getCurMouseX() > 0)
{
//pMan->move(CMan::RIGHT, anim_rate);
dxMgr.pCam->Yaw( sin(D3DXToRadian( (FLOAT)diMgr.getCurMouseX() ) ) / 8 );
}
if (diMgr.getCurMouseY() < 0)
{
dxMgr.pCam->Pitch(sin(D3DXToRadian( (FLOAT)diMgr.getCurMouseY() ) )/ 8 );
}
if (diMgr.getCurMouseY() > 0)
{
dxMgr.pCam->Pitch(sin(D3DXToRadian( (FLOAT)diMgr.getCurMouseY() ) )/ 8 );
}
if (KEYDOWN(diMgr.buffer, DIK_W) || (diMgr.getCurMouseZ() - mouseOldZ > 0))
{
dxMgr.pCam->MoveForward((FLOAT)CAMERA_MOVEMENT_INCREMENT);
}
if (KEYDOWN(diMgr.buffer, DIK_S) || (diMgr.getCurMouseZ() - mouseOldZ < 0))
{
dxMgr.pCam->MoveForward((FLOAT)-CAMERA_MOVEMENT_INCREMENT);
}
if (KEYDOWN(diMgr.buffer, DIK_A))
{
dxMgr.pCam->MoveRight((FLOAT)-CAMERA_MOVEMENT_INCREMENT);
}
if (KEYDOWN(diMgr.buffer, DIK_D))
{
dxMgr.pCam->MoveRight((FLOAT)CAMERA_MOVEMENT_INCREMENT);
}
if (KEYDOWN(diMgr.buffer, DIK_Q))
{
dxMgr.pCam->Roll((FLOAT)-CAMERA_ROTATION_INCREMENT);
}
if (KEYDOWN(diMgr.buffer, DIK_E))
{
dxMgr.pCam->Roll((FLOAT)CAMERA_ROTATION_INCREMENT);
}
// Move Cursor
if(diMgr.getCurMouseX()<=0 && curX>0 )
curX += diMgr.getCurMouseX();
if(diMgr.getCurMouseX()<=0 && curX<0)
curX = 0;
if(diMgr.getCurMouseX()>0 && curX<SCREEN_WIDTH)
curX += diMgr.getCurMouseX();
if(diMgr.getCurMouseX()>0 && curX>SCREEN_WIDTH - IMAGE_WIDTH)
curX = SCREEN_WIDTH - IMAGE_WIDTH;
if(diMgr.getCurMouseY()<=0 && curY>0)
curY += diMgr.getCurMouseY();
if(diMgr.getCurMouseY()<=0 && curY<0)
curY = 0;
if(diMgr.getCurMouseY()>0 && curY<SCREEN_HEIGHT)
curY += diMgr.getCurMouseY();
if(diMgr.getCurMouseY()>0 && curY>SCREEN_HEIGHT)
{
curY = SCREEN_HEIGHT;
}
return 1;
}
/********************************************************************
* render
* Renders the in-game objects based on a timer
********************************************************************/
void CGame::render(void)
{
// get the time before rendering
QueryPerformanceCounter(&timeStart);
static DWORD lastTime=timeGetTime();
// call our render function
dxMgr.beginRender();
dxMgr.blitToSurface(arrows, &mouseRect, &mouseDestRect);
if (m_entity)
{
float timeElapsed=0.001f*(timeGetTime()-lastTime);
lastTime=timeGetTime();
// Need to pass the high level matrix used to position and orientate the model
// Create this from current position and rotations:
D3DXMATRIX matRotX,matRotY,matRotZ,matTrans;
// Calculate rotation matrix
D3DXMatrixRotationX( &matRotX, 0 );
D3DXMatrixRotationY( &matRotY, 0 );
D3DXMatrixRotationZ( &matRotZ, 0 );
// Calculate a translation matrix
D3DXMatrixTranslation(&matTrans,0,0,0);
// Calculate our world matrix by multiplying the above (in the correct order)
D3DXMATRIX matWorld=(matRotX*matRotY*matRotZ)*matTrans;
// FrameMove carries out the animation while Render just draws
m_entity->AdjustFrame(timeElapsed,&matWorld);
m_entity->Render();
}
dxMgr.endRender();
// get the updated time
QueryPerformanceCounter(&timeEnd);
// determine the animation rate
anim_rate = ( (float)timeEnd.QuadPart - (float)timeStart.QuadPart ) / timerFreq.QuadPart;
}
I cannot seem to locate any out of place parenthesis, brackets, commas, or semi-colons...
I'd appreciate any help with this matter as it has consumed much time...is the problem related to something besides syntax? I read Microsoft threads and MSDN error library...still can't resolve. Thanks in advance for any help!