Jump to content
  • Advertisement
Sign in to follow this  
Xpyder

missing '' before 'if' - Direct Input

This topic is 4913 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey - i create the Dinput interface as follows: LPDIRECTINPUT8 lpdi = NULL; /***/if (FAILED(DirectInput8Create(hinstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void***)&lpdi,NULL))) return (0); yet it always says missing ';' before 'if' on * line(cmmnted) i know there is a bug in my compiler like this on try blocks (MSVC++ 6.0), but does anyone else have this problem?

Share this post


Link to post
Share on other sites
Advertisement
APpears to me as though the line causing the error is nothing to do with that code segment there. Post the code to the entire code file betwee [source][/source] tags.

ace

[Edit: Use [ to write '[' without causing GDNet to interpret it as a tag.]

[Edited by - Oluseyi on March 3, 2005 5:03:27 PM]

Share this post


Link to post
Share on other sites
Have you included the direct input header file? Sometimes this error message occurs if a type (in this case LPDIRECTINPUT8) is unknown.

Share this post


Link to post
Share on other sites
bakery2k1 is most likely correct in his suppposition. However, in addition to that errr, you are casting parameter four in the wrong way, it should be (void **)&lpdi and not (void****)&lpdi since you are not passing an array of lpdis or some similar. Just another thing to watch out for.

Share this post


Link to post
Share on other sites
hmm, the source is:


#include "Includes.h"

#include "Menu Values.h"

//-----------------------------------------------------------------------------
// Globals
//-----------------------------------------------------------------------------


unsigned short int animation_frame = 0;
unsigned short int i;
unsigned short int j;
unsigned short int k;
unsigned short int z;
unsigned short int x = 0;

const unsigned short int size_x = 64;
const unsigned short int size_y = 32;
const unsigned short int screen_width = 520;
const unsigned short int screen_height = 360;
const unsigned short int tile_width = 64;
const unsigned short int tile_height = 32;
const unsigned short int tile_move_x = 32;
const unsigned short int tile_move_y = 16;
const unsigned short int tile_start_x = 400;
const unsigned short int tile_start_y = 600;
const unsigned short int tile_x = (j*size_x) + (z*32);

LPDIRECTINPUT8 lpdi = NULL;


if (FAILED(DirectInput8Create(hinstance,
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(void**)&lpdi,NULL)))
return (0);


class TILE
{
public:
int itsX;
int itsY;
int quad[3];
int isAnimated;
};

// custom vertex structure for our quads
struct CCustomVertex
{
float x, y, z, rhw; // The transformed position for the vertex.
DWORD dwColor; // The vertex colour.
float tu, tv; // Texture co-ordinates.

static const DWORD FVF;
};
const DWORD CCustomVertex::FVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1;

///////////change later to quad
struct CRectangularObject
{
IDirect3DTexture9 *pTexture;
CCustomVertex vertices[4];
};


HWND main_window_handle = NULL; // globally track main window
HINSTANCE main_instance = NULL; // globally track hinstance
int MouseX,MouseY,MouseButtons;

CRectangularObject *g_pObjects;
UINT g_nObjectBufferSize, g_nNewObjectPointer;

#include "BungEngine.h"

LPDIRECT3DTEXTURE9 tTexture;
LPDIRECT3DTEXTURE9 tAnimTexture;
LPDIRECT3DTEXTURE9 tGrassTextures;
LPDIRECT3DTEXTURE9 tSand;

TILE qTile[3][19][10];

int GameInit()
{
InitD3d(1024,768);

g_pObjects = new CRectangularObject[800];
g_nObjectBufferSize = 800;

tTexture = LoadTexture(_T("Grass.png"));
tAnimTexture = LoadTexture (_T("Water Files2.png"));
tGrassTextures = LoadTexture(_T("GRASS_TRANSITION.png"));
tSand = LoadTexture(_T("Sand.png"));
for (k=0;k<2;k++, z=0)
{
for (i=0; i<19; i++)
{
for (j=0; j<10; j++)
{
switch (MAP_STRUCTURE[0][j])
{
case 0:
{
qTile[k][j].itsX = (j*size_x) + (z*32) + (200);
qTile[k][j].itsY = (i*size_y)-(i*16) + (200);
qTile[k][j].quad[0] = 0;
qTile[k][j].isAnimated = 0;
}break;

case 10:
{
qTile[k][j].itsX = (j*size_x) + (z*32) + (200);
qTile[k][j].itsY = (i*size_y)-(i*16) + (200);
qTile[k][j].quad[0] = CreateQuad(qTile[k][j].itsX, qTile[k][j].itsY, 64, 32, tTexture, 0, 0);
qTile[k][j].isAnimated = 0;
}break;

case 20:
{
qTile[k][j].itsX = (j*size_x) + (z*32) + (200);
qTile[k][j].itsY = (i*size_y)-(i*16) + (200);
qTile[k][j].quad[0] = CreateQuad(qTile[k][j].itsX, qTile[k][j].itsY, 64, 32, tSand, 0, 0);
qTile[k][j].isAnimated = 0;
}break;

case 40:
{
qTile[k][j].itsX = (j*size_x) + (z*32) + (200);
qTile[k][j].itsY = (i*size_y)-(i*16) + (200);
qTile[k][j].quad[0] = CreateQuad(qTile[k][j].itsX, qTile[k][j].itsY, 64, 32, tAnimTexture, 0, 0);
qTile[k][j].quad[1] = CreateQuad(qTile[k][j].itsX, qTile[k][j].itsY, 64, 32, tAnimTexture, 64, 0);
qTile[k][j].quad[2] = CreateQuad(qTile[k][j].itsX, qTile[k][j].itsY, 64, 32, tAnimTexture, 128, 0);
qTile[k][j].isAnimated = 1;
}break;

}
}


if (z==1)
z=0;
else z=1;
}
}


g_pd3dDevice->CreateVertexBuffer(g_nNewObjectPointer * 4 * sizeof(CCustomVertex),
D3DUSAGE_WRITEONLY, ///look into this---------------
CCustomVertex::FVF,
D3DPOOL_MANAGED, &g_pVB, NULL);
return(1);
}


int GameMain()
{

BeginRender();
// Clear the backbuffer to black
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,000,000,000)/*D3DCOLOR_XRGB(0,0,255)*/, 1.0f, 0);


for (k=0;k<3;k++)
for (i=0; i<19; i++)
for (j=0; j<10; j++)
{
if (qTile[k][j].isAnimated == 0)
DrawQuad(qTile[k][j].quad[0]);

if (qTile[k][j].isAnimated == 1)
DrawQuad(qTile[0][j].quad[animation_frame]);
}



FinishRender();
return(1);
}

int GameShutdown()
{
tTexture->Release();
tAnimTexture->Release();
tGrassTextures->Release();
tSand->Release();
CloseD3d();
return(1);
}

//-----------------------------------------------------------------------------
// Window Proc Function
// Description: the windows procedure
//-----------------------------------------------------------------------------
LRESULT CALLBACK WindowProc(HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam)
{
PAINTSTRUCT ps;
HDC hdc;

switch(msg)
{
case WM_CREATE:
{
SetTimer(hwnd, 1, 500, NULL);
return(0);
} break;

case WM_PAINT:
{
hdc = BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
return(0);
} break;

case WM_MOUSEMOVE:
{
MouseX = (int)LOWORD(lparam);
MouseY = (int)HIWORD(lparam);
MouseButtons = (int)wparam;

case WM_TIMER:
{
animation_frame++;
if (animation_frame == 2)
animation_frame = 0;
} break;

} break;

case WM_LBUTTONDOWN:{ MouseButtons = (int)wparam; } break;
case WM_LBUTTONUP: { MouseButtons = (int)wparam; } break;
case WM_RBUTTONDOWN:{ MouseButtons = (int)wparam; } break;
case WM_RBUTTONUP: { MouseButtons = (int)wparam; } break;

SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, NULL);
/*HTCAPTION = the caption/titlebar area
HTBOTTOMRIGHT = the resizing corner
*/





case WM_DESTROY:
{
PostQuitMessage(0);
KillTimer(hwnd, 1);
return(0);
} break;

default:break;
}

return (DefWindowProc(hwnd, msg, wparam, lparam));
}
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow)
{
WNDCLASSEX winclass; // this will hold the class we create
HWND hwnd; // generic window handle
MSG msg; // generic message
// HDC hdc; // graphics device context

winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = NULL;//LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ICON1));
winclass.hCursor = NULL;//LoadCursor(hinstance, MAKEINTRESOURCE(IDC_CURSOR1));
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = "EditorControlsMenu";
winclass.lpszClassName = "WINCLASS1";
winclass.hIconSm = NULL;//LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ICON1));


// save hinstance in global
main_instance = hinstance;

if (!RegisterClassEx(&winclass))
return(0);

//MessageBox(NULL, "Creating window.", "Manual Debug Operation", MB_OK);
if (!(hwnd = CreateWindowEx(WS_EX_APPWINDOW,
"WINCLASS1",
"ToW: Map Editor Rendered Display",
WS_POPUP | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX
| WS_SYSMENU,
(GetSystemMetrics(SM_CXSCREEN)/2)-(520/2),(GetSystemMetrics(SM_CYSCREEN)/2)-(360/2),
520,360,
NULL,
LoadMenu(hinstance, "EditorControlsMenu"),
hinstance,
NULL)))
return(0);

//HMENU hmenuhandle = LoadMenu(hinstance, "EditorControlsMenu");
//
//SetMenu(hwnd, hmenuhandle);

// save main window handle
main_window_handle = hwnd;

ShowCursor(TRUE);

GameInit();

// enter main event loop
while(TRUE)
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;

TranslateMessage(&msg);
DispatchMessage(&msg);
}

GameMain();
}

GameShutdown();

return(0);//msg.wParam);
}




and i have:

#define INITGUID
#define WIN32_LEAN_AND_MEAN // just say no to MFC

#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>
#include <objbase.h>
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <math.h>
#include <io.h>
#include <fcntl.h>
#include <tchar.h>

#include <C:\SDK (C++)\include\d3d9.h>
#include <C:\SDK (C++)\include\d3dx9.h>
#include <C:\SDK (C++)\include\dinput.h>
//#include <C:\SDK (C++)\include\dxerr.h>
//#include <C:\SDK (C++)\include\dxerr8.h>
#include <C:\SDK (C++)\include\dxerr9.h>
//#include <C:\SDK (C++)\include\dinput8.h>

//#include "Tile Values.h"
#include "Texture Values.h"
#include "array main.h"
#include "Transitional Layering.h"
#include "Menu.cpp"
#include "Menu Values.h"

Share this post


Link to post
Share on other sites
yea thats probably it- i just got it out of a book and the if is for error testing, but ur prob right - i just need to sort out the hinstance thing now - thakns

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!