Jason, the stop command just freezes a frame
And PoK, I added this:
//if the left key AND the right key are NOT being pressed
if (dbLeftKey() == 0; && dbRightKey == 0)
{
//stop the animation.
dbLoopObject ( 2 , 190 , 209 );
}
After the controls and got a lot of errors.
Here is the whole code:
// Dark GDK - The Game Creators - www.thegamecreators.com
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
//THIS IS A FUNCTION
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
//Screen
dbSetWindowSize ( 800, 600 )
//Backdrop
;dbColorBackdrop ( dbRGB ( 1, 1, 1 ) )
// switch to the media directory, load our world
// and turn lighting off
;SetCurrentDirectory ( "media" );
;dbLoadObject ( "level1.x", 1 );
dbSetObjectLight ( 1, 0 );
dbRotateObject ( 1 , 0 , 180 , 0 )
//Load Character
;SetCurrentDirectory ( "media" );
;dbLoadObject ( "civ_assault.x", 2 );
;dbSetObjectSpeed ( 2 , 60 )
;void Idleanimation ()
;dbLoopObject ( 2 , 210 , 234 )
//Ligth in level
;dbMakeLight ( 1 )
;dbSetSpotLight ( 1 , 20 , 30 )
;dbPositionLight ( 1 , 0 , 50 , 0 )
//Collision
;dbSetGlobalCollisionOn ()
;dbSetObjectCollisionToPolygons ( 1 )
;dbSetObjectCollisionToBoxes ( 2 )
;dbSetGlobalCollisionOn ()
// position the camera
;dbPositionCamera ( 0 , 80 , -200 );
// camera variables
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
// THIS IS A LOOP
while ( LoopGDK ( ) )
{
//THIS UPDATES THE CAMERA POSITION, so every frame, the camera will move with the character object, and also, stay a certain distance away from them
dbPositionCamera (dbObjectPositionX(2), dbObjectPositionY(2) +80 , -200 );
//if you press the left arrow key, the walk animation will play, and the character will move to the left
if (dbLeftKey() == 1)
{
dbLoopObject ( 2 , 280 , 299 );
dbSetObjectSpeed ( 2 , 60 );
dbMoveObjectLeft ( 2 , 6 );
}
//if you press the lright arrow key, the walk animation will play, and the character will move to the right
if (dbRightKey() == 1)
{
dbLoopObject(2, 280, 299);
dbSetObjectSpeed ( 2 , 60 );
dbMoveObjectRight (2, 6);
}
//if the left key AND the right key are NOT being pressed
if (dbLeftKey() == 0; && dbRightKey == 0)
{
//stop the animation.
dbLoopObject ( 2 , 190 , 209 );
}
// update the screen
;dbSync ( );
}
// return back to windows
return;
}
And I think I know what you are talking about with functions, and it seems quite easy actually