0

guys i think there is a mistake in my code but i dont know where. Can anybody tell me ??
here's my code.

#include "DarkGDK.h"
    #include "Inventor.h"
     
    void DarkGDK ( void )
    {
    dbSyncOn ( );
    dbSyncRate ( 60 );
    dbMaximizeWindow ();
    float fCameraAngleX = 0.0;
    float fCameraAngleY = 0.0;
    int ground;
    SetCurrentDirectory ( "media" );
    dbLoadObject ( "universe.dbo", 2 );
    dbSetObjectLight ( 2, 0 );
    dbLoadObject ( "skybox2.x", 3 );
    dbSetObjectLight ( 3, 0 );
    dbSetObjectTexture ( 3, 3, 2 );
    dbScaleObject ( 3, 5000, 5000, 5000 );
    dbLoadObject ( "Colonel-X.X", 1 );
    dbSetObjectSpeed ( 1, 100 );
    dbMoveObject ( 1, -130 );
    dbMoveObjectRight ( 1, 200 );
    dbSetObjectCollisionOn ( 1 );
    dbSetObjectCollisionOn ( 2 );
    dbSetGlobalCollisionOn ();
    while ( LoopGDK ( ) )
    {
    if ( dbUpKey() && dbShiftKey () ){
    dbLoopObject ( 1, 300, 318 );
    dbMoveObject ( 1, -5.0 );
    }else if ( dbUpKey () ){
    dbLoopObject ( 1, 235, 259 );
    dbMoveObject ( 1, -3.5 );
    }else if ( dbDownKey () ){
    dbLoopObject ( 1, 259, 235 );
    dbMoveObject ( 1, 3.5 );
    }else if ( dbRightKey () ){
    dbLoopObject ( 1, 280, 299 );
    dbMoveObjectLeft ( 1, 3.5 );
    }else if ( dbLeftKey () ){
    dbLoopObject ( 1, 260, 279 );
    dbMoveObjectRight ( 1, 3.5 );
    }else if ( dbSpaceKey () ){
    dbLoopObject ( 1, 190, 209 );
    dbMoveObjectUp ( 1, 3.5 );
    dbMoveObject ( 1, -3.5 );
    }else{
    dbLoopObject ( 1, 210, 234 );
    }
    while ( (ground = dbObjectCollision ( 1, 2 )) != 1 )
    {
    dbMoveObjectDown ( 1, 3.5 );
    }
    fCameraAngleX = dbWrapValue ( fCameraAngleX + dbMouseMoveY ( ) * 0.4f );
    fCameraAngleY = dbWrapValue ( fCameraAngleY + dbMouseMoveX ( ) * 0.4f );
    dbXRotateCamera ( fCameraAngleX );
    dbYRotateCamera ( fCameraAngleY );
    //dbRotateObject ( 1, 0, fCameraAngleY, 0 );
    dbPositionMouse ( dbScreenWidth () / 2, dbScreenHeight () / 2 );
    dbHideMouse ();
    dbPositionCamera ( dbObjectPositionX ( 1 ), dbObjectPositionY ( 1 ) + 50, dbObjectPositionZ ( 1 ) + 50 );
    dbSync ( );
    }
    return;
    }

i'm not an expert programmer so if you see any mistakes please tell me.8-)
This is in dark gdk code and you will have to copy colonel - x, universe, and skybox2 to your folder.
i made a media folder to make this task easier. :-)

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Tigerwatch
0

well this code is supposed to be creating a player and a game level. the player walks through the game level.that's about all there is. but the problem is that gravity isn't working. when the player climbs up the stairs, it can't come back down. the player simply starts walking on air.

i think there is a problem in this part of the code but i don't know what. :-(

while ( (ground = dbObjectCollision ( 1, 2 )) != 1 )
{
dbMoveObjectDown ( 1, 3.5 );
}

any help is appreciated

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.