Welcome to the forum

register! and help us get started! with this new darkgdk forum !


dont forget to introduce yourself Razz

enjoy! and good luck with your programming Smile


Bad "IF" statment???

Go down

Bad "IF" statment???

Post  F4SHADO on Sun May 09, 2010 1:22 am

hey guys. so i started a project of an online FPS game. i havent gotten to the online portion yet. however, my if statements arent working. by this, i mean, if i use the statement

Code:
if (dbKeyState(W)==1)
            dbMoveCamera (1,5);
one would expect the behavior of the camera to move forward every 5 steps. however, i always get the error

Code:
Error   2   fatal error C1004: unexpected end-of-file found   c:\users\james\documents\visual studio 2008\projects\dark gdk - game1\dark gdk - game1\controls.h   18

here is the whole thing

Code:
#ifdef W 17
#ifdef S 31
#ifdef A 30
#ifdef D 32

void mouseControl()
{

}

void keyboardControl()
{
   if (dbKeyState(W)==1)
   dbMoveCamera(1,5);

}

i've used #ifdef in this manner before and never got an error

it started doing this after i applied the darkgdk update. any suggestions would be very helpful!!!

Kampai cheers

F4SHADO

Posts : 36
Join date : 2010-05-08
Location : Springfield, Illinois

View user profile https://www.youtube.com/user/F4SHADO

Back to top Go down

Re: Bad "IF" statment???

Post  F4SHADO on Sun May 09, 2010 2:19 am

okay, nevermind, i solved my own problem i forgot to put "{ }" underneath the if statement Embarassed

i am however still getting the end of file error in the "controls.h" header file. its not coming up in the "Setup.h" header file. i keep runnign into this error every so often, but cant figure out wat i did to solve it.

here is the "Setup.h" header

Code:
void setup ()
{
   dbSetDir ("Data");
   dbSyncOn ();
   dbSyncRate (300);
   dbBackdropOn();
}

"Controls.h" header

Code:
#ifdef W 17
#ifdef S 31
#ifdef A 30
#ifdef D 32

void mouseControl()
{

}

void keyboardControl()
{
   if (dbKeyState(W)==1)
   {
      dbMoveCamera (5);
   }   
}

Main.cpp file

Code:
void DarkGDK ( void )
{

   setup();
   
   // main loop
   while ( LoopGDK ( ) )
   {
   
      mouseControl ();
      keyboardControl ();
      
      // update the screen
      dbSync ( );
   }

   // back to windows
   return;
}

any help is appreciated

Kampai cheers

F4SHADO

Posts : 36
Join date : 2010-05-08
Location : Springfield, Illinois

View user profile https://www.youtube.com/user/F4SHADO

Back to top Go down

Re: Bad "IF" statment???

Post  pqowieuryt101 on Sun May 09, 2010 12:28 pm

That's quite strange as your code seems fine, however I wouldn't put "w" in the keystate command. It would work better if you used the keycode (17). I'll try and test out your code later and see if I can get it fixed.
avatar
pqowieuryt101
Admin

Posts : 97
Join date : 2010-04-22

View user profile http://darkgdk.forumotion.com

Back to top Go down

Re: Bad "IF" statment???

Post  pqowieuryt101 on Sun May 09, 2010 1:15 pm

ok I tested it and got it working Smile

basically where you had #ifdef, it should have been #define

I also added a cube so you could actually see the camera moving forward Razz

controls.h

Code:
#define w 17
#define s 31
#define a 30
#define d 32


void mouseControl()
{

}

void keyboardControl()
{
  if (dbKeyState(w)==1)
  {
      dbMoveCamera (0.5);
  } 
}

main.cpp

Code:
void DarkGDK ( void )
{

  setup();
  dbMakeObjectCube(1,10);
  dbPositionObject(1,dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ()+20);
  // main loop
  while ( LoopGDK ( ) )
  {
 
      mouseControl ();
      keyboardControl ();
     
      // update the screen
      dbSync ( );
  }

  // back to windows
  return;
}

-pqowieuryt101
avatar
pqowieuryt101
Admin

Posts : 97
Join date : 2010-04-22

View user profile http://darkgdk.forumotion.com

Back to top Go down

Re: Bad "IF" statment???

Post  F4SHADO on Sun May 09, 2010 4:44 pm

ah, okay, thanks a bunch. that really helps. i was looking at it last night and realized that #ifdef had to be the problem.

kampai cheers

F4SHADO

Posts : 36
Join date : 2010-05-08
Location : Springfield, Illinois

View user profile https://www.youtube.com/user/F4SHADO

Back to top Go down

Re: Bad "IF" statment???

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum