ok, i used this, and it works just fine. however I noticed it didnt seem to work until I put in the matrix as reference. but i dont know why that would be...
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple 3D project that uses Dark GDK
// it can be used as a starting point in making your own 3D games
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
void clampCameraAngle(int cameraID, float x1, float x2, float y1, float y2, float z1, float z2);
void mouseWASD();
// Camera variables
float fCameraAngleX = 0.0f; // For controlling camera movement in the X-axis
float fCameraAngleY = 0.0f; // For controlling camera movement in the Y-axis
float mouseY1; // Used to apply camera rotation
float mouseX1; // Used to apply camera rotation
float mouseY2; // Used to return mouse to position before right click
float mouseX2; // Used to return mouse to position before right click
float moveSpeed = 1.0f; // Initiated the variable
bool rClicked = false; // For controlling original mouse position
// Character control
float walkSpeed = 1.0f; // Default walk speed
float runSpeed = 1.8f; // Default run speed
float hasteSpeed = 0.0f; // Increases movement speed
float snareSpeed = 0.0f; // Decreases movement speed
// the main entry point for the application is this function
void DarkGDK ( void )
{
// in this application we are going to create some 3D objects
// and position them on screen
// when starting a Dark GDK program it is useful to set global
// application properties, we begin by turning the sync rate on,
// this means we control when the screen is updated, we also set
// the maximum rate to 60 which means the maximum frame rate will
// be set at 60 frames per second
dbSyncOn ( );
dbSyncRate ( 60 );
// set our random seed to a value from the timer, this will help
// to ensure each time we run our program the random values appear
// more random
dbRandomize ( dbTimer ( ) );
// make some 3D objects
for ( int i = 1; i < 50; i++ )
{
// make a sphere
dbMakeObjectSphere ( i, 1 );
// position the object in a random location
dbPositionObject ( i, dbRnd ( 20 ), dbRnd ( 20 ), dbRnd ( 20 ) );
// adjust scaling
dbScaleObject ( i, 100 + dbRnd ( 400 ), 100 + dbRnd ( 400 ), 100 + dbRnd ( 400 ) );
// give the object a color
dbColorObject ( i, dbRgb ( dbRnd ( 255 ), dbRnd ( 255 ), dbRnd ( 255 ) ) );
// increase specular power
dbSetObjectSpecularPower ( i, 255 );
// turn off ambient lighting for this object
dbSetObjectAmbient ( i, 0 );
}
// move our camera back so we can view the objects
dbPositionCamera ( 10, 10, -20 );
dbMakeMatrix(101, 500, 500, 32, 32);
dbPositionMatrix(101, 0, 0, 0);
// now we come to our main loop, we call LoopGDK so some internal
// work can be carried out by the GDK
while ( LoopGDK ( ) )
{
mouseWASD();
// rotate all of our objects
for ( int i = 1; i < 50; i++ )
dbRotateObject ( i, dbObjectAngleX ( i ) + 0.1, dbObjectAngleY ( i ) + 0.2, dbObjectAngleZ ( i ) + 0.3 );
// here we make a call to update the contents of the screen
dbSync ( );
}
dbDeleteImage(1);
// before quitting delete our objects
for ( int i = 1; i < 50; i++ )
dbDeleteObject ( i );
// and now everything is ready to return back to Windows
return;
}
void clampCameraAngle(int cameraID, float x1, float x2, float y1, float y2, float z1, float z2)
{
float x = dbCameraAngleX(cameraID);
float y = dbCameraAngleY(cameraID);
float z = dbCameraAngleZ(cameraID);
if(x < x1) x = x1;
if(y < y1) y = y1;
if(z < z1) z = z1;
if(x > x2) x = x2;
if(y > y2) y = y2;
if(z > z2) z = z2;
dbRotateCamera(cameraID, x, y, z);
}
void mouseWASD() {
//mouseY1 = dbMouseMoveY();
//mouseX1 = dbMouseMoveX();
// Calculates move speed
if (dbShiftKey() == 1) { moveSpeed = runSpeed + hasteSpeed - snareSpeed; } else { moveSpeed = walkSpeed + hasteSpeed - snareSpeed; }
// Enter mouse look when right mouse button or control key is pressed
if (dbMouseClick() == 2 || dbControlKey() == 1) {
if (rClicked == false) { mouseX2 = dbMouseX(); mouseY2 = dbMouseY(); rClicked = true; }
fCameraAngleX = dbCameraAngleX() + dbMouseMoveY() * 0.4f;
fCameraAngleY = dbCameraAngleY() + dbMouseMoveX() * 0.4f;
dbXRotateCamera(fCameraAngleX);
dbYRotateCamera(fCameraAngleY);
clampCameraAngle(0, -70, 70, -360, 360, 0, 0);
dbPositionMouse(mouseX2, mouseY2);
dbHideMouse();
} else { dbShowMouse(); rClicked = false; }
// W to move forward
if (dbKeyState(17)) { dbMoveCamera(moveSpeed); }
// S to move back
if (dbKeyState(31)) { dbMoveCamera(-moveSpeed); }
// A to turn left
if (dbKeyState(30)){ dbTurnCameraLeft(1.5f * moveSpeed); }
// D to turn right
if (dbKeyState(32)){ dbTurnCameraRight(1.5f * moveSpeed); }
// Q to straffe left
if (dbKeyState(16)) { dbTurnCameraLeft(90); dbMoveCamera(moveSpeed); dbTurnCameraRight(90); }
// E to straffe right
if (dbKeyState(18)) { dbTurnCameraRight(90); dbMoveCamera(moveSpeed); dbTurnCameraLeft(90); }
// Final update on camera position
//float fHeight = dbGetTerrainGroundHeight(1, dbCameraPositionX(), dbCameraPositionZ());
//dbPositionCamera(dbCameraPositionX(), fHeight + 10.0f, dbCameraPositionZ());
//dbSync();
}
-Warspawn