Thanks Jason p sage, i change small o to big O and c-> C ond work but is other problem legs of robot are under level:
http://img329.imageshack.us/my.php?image=legsgu9.jpg
He is falling down and when is collision robot and level then robot stops and a cant to do nothing,
void makeLevel()
{
dbLoadObject ( "demomap1.x" ,1);
dbScaleObject (1, 300,300,300);
dbXRotateObject (1,90);
SC_SetupComplexObject( 1,1,0);
}
void makePlayer()
{
dbLoadObject("bot3.x",2);
dbPositionObject (2,0,150,-200);
SC_SetupObject( 2,1,2 );
}
int collide = SC_ObjectCollision ( 1,2 ) ;
i dont know why is that
There is my complete code
#include "DarkGDK.h"
#include "SC_Collision.h"
float x = 0;
float y = 60;
float z = -270;
char text[256];
////////////////////////////////////////////////////////////////////////////////////
//************** wartosci **************// ///
int rtimer = 0; ///
int stimer = 0;
int vtimer = 0; ///
float gravity = -0.1f;
float slope = 0.5f;
int ground = 0;
int jumptimer = 20;
///
int syncmode = 60;
int view = 1;
int hide = 0;
///
float vx = 0;
float vy = 0; ///
float vz = 0;
////////////////////////////////////////////////////////////////////////////////////
void makeLevel()
{
dbLoadObject ( "demomap1.x" ,1);
dbScaleObject (1, 300,300,300);
dbXRotateObject (1,90);
SC_SetupComplexObject( 1,1,0);
}
void makePlayer()
{
dbLoadObject("bot3.x",2);
dbPositionObject (2,0,150,-200);
SC_SetupObject( 2,1,2 );
}
void movePlayer()
{
dbYRotateObject( 2,dbObjectAngleY(2) + dbMouseMoveX()/3.0f );
dbXRotateObject( 2,dbObjectAngleX(2) + dbMouseMoveY()/3.0f );
float oldx = dbObjectPositionX(2);
float oldy = dbObjectPositionY(2);
float oldz = dbObjectPositionZ(2);
float angy = dbObjectAngleY(2);
vx = 0;
vz = 0;
if ( vy == 0 && jumptimer == 0 ) vy = vy + 10*gravity;
else vy = vy + gravity;
//
if (dbKeyState(32) == 1 ) { vx = vx + dbCos(angy); vz = vz - dbSin(angy); }
if (dbKeyState(30) == 1 ) { vx = vx - dbCos(angy); vz = vz + dbSin(angy); }
if (dbKeyState(31) == 1 ) { vx = vx - dbSin(angy); vz = vz - dbCos(angy); }
if (dbKeyState(17) == 1 ) { vx = vx + dbSin(angy); vz = vz + dbCos(angy); }
if ( ground == 1 )
{
if ( dbSpaceKey() == 1 && jumptimer == 0 )
{
vy = vy + 3.0f; // poz. y player + 3
jumptimer = 20; // jump timer = 20
}
}
float x = oldx + vx;
float y = oldy + vy;
float z = oldz + vz;
int collide = SC_ObjectCollision ( 1,2 ) ;
if ( collide > 0 )
{
float ny = SC_GetCollisionNormalY();
if ( dbAbs(ny) > slope )
{
oldy = SC_GetStaticCollisionY();
}
else
{
x = x - oldx; z = z - oldz;
oldx = SC_GetCollisionSlideX();
oldy = SC_GetCollisionSlideY();
oldz = SC_GetCollisionSlideZ();
x = x + oldx; z = z + oldz;
}
if ( ny > slope )
{
ground = 1;
vy = 0;
}
else
{
ground = 0;
if ( ny < -slope ) vy = gravity;
}
}
else
{
oldy = oldy + vy;
ground = 0;
}
if ( ground == 1 && jumptimer > 0 ) jumptimer--;
collide = SC_ObjectCollision ( 1,2 ) ;
if ( collide > 0 )
{
x = SC_GetCollisionSlideX();
oldy = SC_GetCollisionSlideY();
z = SC_GetCollisionSlideZ();
vx = 0;
vz = 0;
}
dbPositionObject( 2,x,oldy,z );
SC_UpdateObject( 2 );
}
void positionCameraToObject( int obj, int thirdPerson)
{
dbPositionCamera( dbObjectPositionX(2),dbObjectPositionY(2)+ 20,dbObjectPositionZ(2) );
dbRotateCamera( dbObjectAngleX(2),dbObjectAngleY(2),dbObjectAngleZ(2) );
if ( thirdPerson == 1 )
{
dbPitchCameraDown( 20 );
dbMoveCamera( -70 );
}
}
void DarkGDK( )
{
dbSyncOn( );
dbSyncRate( 60 );
dbAutoCamOff( );
dbRandomize( dbTimer() );
SC_Start( );
makeLevel();
makePlayer();
while( LoopGDK( ) )
{
movePlayer();
//change view
if ( strcmp(dbInKey(), "v") == 0 && vtimer < dbTimer() )
{
vtimer = dbTimer() + 300;
view = 1 - view;
}
//enable/disable sync limit
if ( strcmp(dbInKey(), "l") == 0 && stimer < dbTimer() )
{
stimer = dbTimer() + 300 ;
dbSyncRate(60);
}
positionCameraToObject( 2, view );
SC_DrawObjectBounds (2);
SC_DrawObjectBounds (1);
dbSync( );
}
}