Hello I made a little maze you can control a object with your arrow keys through the maze. The camera is located a little behind the object. The first picture shows how I want my camera rotate. The second picture shows how it is now. How can I get it like in picture one?
#include "DarkGDK.h"
void (DarkGDK ())
{
dbSyncOn( );
dbSyncRate ( 60 );
dbColorBackdrop(dbRgb(0,0,125));//color background
dbDisableEscapeKey();
dbAutoCamOff();
dbMakeObjectCube(1,5);//character
dbLoadImage("crate1.jpg",1);//character texture
dbLoadImage("crate.png",2);//wall Texture
dbTextureObject(1,2);//texturing caharacter
for ( int i = 2; i < 26; i++ )//creating wall and texturing
{
dbMakeObjectCube( i, 25 );
dbTextureObject(i,1);
}
dbPositionObject(2,-25,0,0);//positioning wall
dbPositionObject(3,-25,0,25);
dbPositionObject(4,0,0,50);
dbPositionObject(5,25,0,50);
dbPositionObject(6,25,0,0);
dbPositionObject(7,50,0,50);
dbPositionObject(8,75,0,25);
dbPositionObject(9,75,0,0);
dbPositionObject(10,0,0,-25);
dbPositionObject(11,75,0,-25);
dbPositionObject(12,50,0,-50);
dbPositionObject(13,25,0,-75);
dbPositionObject(14,0,0,-75);
dbPositionObject(15,-25,0,-100);
dbPositionObject(16,-50,0,-100);
dbPositionObject(17,-75,0,-100);
dbPositionObject(18,-100,0,-75);
dbPositionObject(19,-100,0,-50);
dbPositionObject(20,-50,0,-50);
dbPositionObject(21,-75,0,-25);
dbPositionObject(22,-75,0,0);
dbPositionObject(23,-100,0,25);
dbPositionObject(24,-75,0,50);
dbPositionObject(25,-100,0,75);
bool exit = false;
while ( LoopGDK ( ) )
{
//movement with arrow keys
if (dbRightKey())
dbMoveObjectRight(1,1);
else if (dbLeftKey())
dbMoveObjectLeft(1,1);
else if (dbUpKey())
dbMoveObject(1,1.0);
else if (dbDownKey())
dbMoveObject(1,-1.0);
//camera positioning
int x = dbObjectPositionX(1);
int z = dbObjectPositionZ(1);
int y = dbObjectPositionY(1);
dbPositionCamera(x,y,z-15);
//pressing esc ->show messagebox
if(dbEscapeKey())
{
int msgboxID = MessageBox(NULL,"Are you sure you want to quit the game?",
"Quit Game", 4);
switch (msgboxID)
{
case IDYES:
exit = true;
case IDNO:
break;
}
}
if(dbObjectCollision(1,0))//character hit wall ->exit game
exit = true;
if(exit == true)
break;
dbSync ( );
}
return;
}