I have made a code for gravity and jumping physics. It isn't done, but i got a lot of errors that I don't know how to solve...
the code
#include "DarkGDK.h"
#include "SC_Collision.h"
#include "KeyID's.h"
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
SC_Start ();
//Load the map
dbLoadObject ( "TunnelMap.x", 1 );
SC_SetupObject ( 1, 1, 0 );
//Load You
dbLoadObject ( "shotgun.x", 2 );
SC_SetupObject ( 2, 2, 0 );
dbPositionObject ( 2, 0.0f, 1.0f, 5.0f );
//Setup all the gravity and jumping things
int IJump=1;
bool BJump = false;
int IGravityPull=1;
bool BGravity = false;
int IUpForce=1;
bool BGround = false;
void Gravity();
void WhileLoops();
void Input();
while ( LoopGDK ( ) )
{
//Position You and Lock the Gun
dbLockObjectOn ( 2 );
//Gravity and Jumping
Gravity();
dbSync ( );
}
}
void Gravity()
{
if (BGround == false )
{
BGravity = true;
}
if (BGround == true )
{
BGravity = false;
}
if (BJump == true )
{
BGravity = false;
}
}
void Input()
{
if (KeyState (SpaceKey == 1 )
{
if (BGravity == false )
{
BJump = true;
}
}
}
void WhileLoops()
{
while ( BJump == true)
{
dbMoveCameraUp (0, IJump );
IJump = IJump+1;
if ( IJump == 10 ){
BJump = false;
BGravity = true;
IJump = 1;
}
}
while ( BGravity == true )
{
dbMoveCameraDown (0, IGravityPull );
if ( BGround == true )
{
BGraviy = false;
}
}
}
The errors
Compiling...
Main.cpp
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(53) : error C2065: 'BGround' : undeclared identifier
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(55) : error C2065: 'BGravity' : undeclared identifier
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(57) : error C2065: 'BGround' : undeclared identifier
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(57) : warning C4805: '==' : unsafe mix of type ''unknown-type'' and type 'bool' in operation
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(59) : error C2065: 'BGravity' : undeclared identifier
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(61) : error C2065: 'BJump' : undeclared identifier
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(61) : warning C4805: '==' : unsafe mix of type ''unknown-type'' and type 'bool' in operation
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(63) : error C2065: 'BGravity' : undeclared identifier
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(70) : error C2143: syntax error : missing ')' before '{'
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(69) : error C3861: 'KeyState': identifier not found
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(71) : error C2065: 'BGravity' : undeclared identifier
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(73) : error C2065: 'BJump' : undeclared identifier
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(80) : error C2065: 'BJump' : undeclared identifier
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(80) : warning C4805: '==' : unsafe mix of type ''unknown-type'' and type 'bool' in operation
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(80) : fatal error C1903: unable to recover from previous error(s); stopping compilation
I know how to solve some of the errors like the syntax ones, but the one where it says
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(80) : error C2065: 'BJump' : undeclared identifier
I don't know how to solve... Also the one that says
c:\users\byron\documents\visual studio 2008\projects\global warfare\global warfare\main.cpp(80) : warning C4805: '==' : unsafe mix of type ''unknown-type'' and type 'bool' in operation
Thanks.
Global Warfare