Hi, i'm just messing around with controlling the camera of a character. Right now, if no mouse buttons are pressed, the camera is behind and above the character and can be used to change the direction the character faces. If the right mouse button is pressed, the camera stops changing the direction of the character and can do a 360 around the character.
My first problem is that when you right click, the camera immediately jumps to a certain place rather than staying where it is.
My second problem is that in either camera views, if you rotate too far there comes a point where you cannot rotate any further.
Any help with these problems would be much appreciated, as well as any other suggestions.
Heres my code:
#include "DarkGDK.h"
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbSetWindowOff();
dbLoadObject ("Colonel-X.X",1);
dbRotateObject (1,0,180,0);
dbFixObjectPivot (1);
dbPositionObject (1,500,0,500);
dbLoadImage ("grass_T.BMP",2);
dbMakeMatrix (1,1000,1000,10,10);
dbPrepareMatrixTexture (1,2,1,1);
dbFillMatrix (1,0,1);
dbSetObjectSpeed ( 1, 40 );
dbMakeCamera(1);
dbSetCurrentCamera(1);
while( LoopGDK ( ) )
{
if (dbKeyState(17)==1)
{
dbMoveObject(1,2);
}
if (dbKeyState(31)==1)
{
dbMoveObject(1,-2);
}
if (dbKeyState(30)==1)
{
dbYRotateObject (1,dbWrapValue(dbObjectAngleY(1) - 1.0));
}
if (dbKeyState(32)==1)
{
dbYRotateObject (1,dbWrapValue(dbObjectAngleY(1) + 1.0));
}
float CameraX=dbCameraPositionX(1);
float CameraY=dbCameraPositionY(1);
float CameraZ=dbCameraPositionZ(1);
float ObjectX=dbObjectPositionX(1);
float ObjectY=dbObjectPositionY(1);
float ObjectZ=dbObjectPositionZ(1);
if (dbMouseClick()==0) //Normally (No mouse buttons)
{
dbHideMouse();
dbPositionCamera (1,ObjectX,ObjectY+100,ObjectZ);
dbSetCameraToObjectOrientation (1,1);
dbMoveCamera (1,-80);
dbRotateObject (1,0,dbWrapValue(dbMouseX()),0);
}
if (dbMouseClick()==2) //Right mouse button
{
dbHideMouse();
dbPositionCamera (1,ObjectX,ObjectY,ObjectZ);
dbRotateCamera(1,0,dbWrapValue(dbMouseX()),0);
dbMoveCamera (1,-80);
float CameraX=dbCameraPositionX(1);
float CameraY=dbCameraPositionY(1);
float CameraZ=dbCameraPositionZ(1);
dbPositionCamera (1,CameraX,CameraY+80,CameraZ);
}
dbSync ( );
}
return;
}