For some reason I can not get my program to run correctly I tried even converting the code to DarkBASIC and seem to work fine in DarkBASIC but won't work in C++. The program will basicly rotate using movement of mouse in x and when the mouse is clicked it will position the camera in the direction but in C++ it goes the wrong direction. Any ideas of whats wrong with the program?
#include "DarkGDK.h"
void DarkGDK(void)
{
dbSetDisplayMode(1024, 768, 32);
dbSetWindowPosition(0, 0);
dbSyncOn();
dbSyncRate(60);
dbSetCameraFOV(45);
dbAutoCamOff();
dbBackdropOn();
dbColorBackdrop(dbRGB(0, 0, 0));
dbMakeObjectCube(1, 5);
dbInk(dbRGB(255, 255, 255), dbRGB(255, 255, 255));
float distance = 0.0;
float xMove = 0.0, yMove = 0.0, zMove = 0.0;
dbPositionCamera(0, 0, -20);
dbRotateCamera(0, 0, 0);
while(LoopGDK())
{
distance = 0.0;
if(dbMouseClick() == 1){distance = 1;}
if(dbMouseClick() == 2){distance = -1;}
xMove = sin(dbCameraAngleY()) * distance;
yMove = 0;
zMove = cos(dbCameraAngleY()) * distance;
dbPositionCamera(xMove + dbCameraPositionX(), 0, zMove + dbCameraPositionZ());
dbYRotateCamera(dbMouseX());
dbSync();
}
return;
}
Here is the DarkBASIC code that works
set display mode 1024, 768, 32
sync on
sync rate 60
set camera FOV 45
autocam off
backdrop on
color backdrop rgb(0, 0, 0)
make object cube 1, 5
ink rgb(255, 255, 255), rgb(255, 255, 255)
distance# = 0.0
xMove# = 0.0
yMove# = 0.0
zMove# = 0.0
angleX# = 0.0
angleY# = 0.0
position camera 0, 0, -20
rotate camera 0, 0, 0
do
angleX# = mousex()
angleY# = mousey()
distance# = 0.0
if mouseclick() = 1 then distance# = 1
if mouseclick() = 2 then distance# = -1
xMove# = sin(camera angle y()) * distance#
yMove# = 0.0
zMove# = cos(camera angle y()) * distance#
position camera 0, xMove# + camera position x(), 0, zMove# + camera position z()
yrotate camera 0, mousex()
sync
loop