OK... I just started making a little game where you are a camera who can shoot instanced 3d spheres at untextured boxes which flying towards you at high velocity (1) to stop them from killing you...
I'm getting a really strange problem which I have no clue why is happening... When a sphere you can shoot does not exist the camera does not roll on its X-axis but when the sphere does exist it can... Really strange and I have racked my brain to try to come up for a solution but couldn't find one...
Here's the source code::
//include headers
#include "DarkGDK.h"
//dgdk function
void DarkGDK ( void )
{
//syncrate
dbSyncOn ( );
dbSyncRate ( 60 );
//setup
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
dbLoadObject ("sky20.x", 2);
dbPositionObject (2, 0, 0, 20);
dbScaleObject (2, 3000, 3000, 3000);
dbLoadImage ("black.png", 3);
dbAutoCamOff ();
dbPositionCamera (10, 6, -100);
//dbHideMouse ();
dbMakeObjectPlain (10, 900, 900);
dbPositionObject (10, 10, -220, -120);
dbXRotateObject (10, 90);
dbTextureObject (10, 3);
dbMakeObjectBox (4, 10, 10, 10);
dbPositionObject (4, dbRND (25), dbRND (25)+10, dbRND (25));
//float dbCameraPositionX()=dbCameraPositionX(0);
//float dbCameraPositionY()=dbCameraPositionY(0);
//float dbCameraPositionZ()=dbCameraPositionZ(0);
int Health=100;
dbMakeObjectBox (12, 1, 1, 1);
dbPositionObject (12, dbCameraPositionX(), dbCameraPositionY(), dbCameraPositionZ()-1);
dbLoadImage ("crosshair.png", 20);
//game loop
while ( LoopGDK ( ) )
{
//draw crosshair
dbPasteImage ( 20 , ( dbScreenWidth( ) / 2 ), ( dbScreenHeight( ) / 2 ));
//--
//camera rotation
{
fCameraAngleX = dbWrapValue (fCameraAngleX + dbMouseMoveY ( ) * 0.4f);
fCameraAngleY = dbWrapValue (fCameraAngleY + dbMouseMoveX ( ) * 0.4f);
dbXRotateCamera (fCameraAngleX);
dbYRotateCamera (fCameraAngleY);
}
//--
/* dbPointCamera (dbMouseX(), dbMouseY(), 1);
dbControlCameraUsingArrowKeys (0, 0.1f, 0.2f);*/
//delete and create new box
{
if (dbUpKey())
{dbDeleteObject(4);}
}
{
if (!dbObjectExist (4))
{dbMakeObjectBox (4, 10, 10, 10);
dbPositionObject (4, dbRND (50), dbRND (50)+25, dbRND (10));}
}
//--
//point box towards cam
{dbPointObject (4, dbCameraPositionX(), dbCameraPositionY(), dbCameraPositionZ());}
//--
//move box towards cam
{dbMoveObject(4, 0.5);}
//--
//detect collisions
{
if (dbObjectHit(4, 12))
{Health = Health - 5; dbDeleteObject(4);}
if (dbObjectCollision(30, 4))
{dbDeleteObject (30); dbDeleteObject(4);}
}
//--
//printhealth to screen
{dbSetCursor(0,0);
dbPrint ((LONGLONG) Health);
dbPrint ((LONGLONG) dbObjectExist(30));
dbPrint ((LONGLONG) dbObjectPositionX(30));
dbPrint ((LONGLONG) dbObjectPositionY(30));
dbPrint ((LONGLONG) dbObjectPositionZ(30));
}
//shoot boxes
{
if ((!dbObjectExist (30)) && (dbKeyState(17)))
{dbMakeObjectSphere(30, 2); dbPositionObject (30, 10, 6, -100);
dbSetObjectToCameraOrientation(30);}
else
if ((dbObjectExist (30)))
{dbMoveObject (30, 1);}
}
{if ((dbObjectPositionZ(30)) > 70) {dbDeleteObject(30);}}
// update screen
dbSync ( );
}
// return back to windows
return;
}
Any suggestions?
~~It's not who you are underneath, but what you do that defines you.~~