I'm not sure if this little piece of code will help but it's a general camera control code I use for everything I do while I'm testing things out. I haven't implemented a jump in it yet but I have noticed you are using the parabola curve used in a lot of the old Speccy and Commodore 64 games years ago.
#define MAX_CAMMOVE 5
class CamControl {
private:
float xp,yp,zp; // position
float xo,yo,zo; // orientation
float xr,yr,zr; // rotation
float strafe; // strafe movement left/right
float move; // forward/backward movement
public:
CamControl() { // constructor sets all values to 0
xp=yp=zp=xo=yo=zo=xr=yr=zr=0; }
void position(float x, float y, float z) {
// set new position for camera
xp=x; yp=y; zp=z; }
void update() {
float mousex,mousey;
int mousec;
mousec=dbMouseClick();
mousex=dbMouseMoveX()/2;
mousey=dbMouseMoveY()/2;
yr=dbWrapValue(yr+mousex); // control y rotation
xr=dbWrapValue(xr+mousey); // control x rotation
dbPositionCamera(xp,yp,zp);
dbRotateCamera(xr,yr,zr);
// strafe controls
if (dbLeftKey()) {
strafe-=2;
if (strafe<-MAX_CAMMOVE) strafe=-MAX_CAMMOVE;
}
if (dbRightKey()) {
strafe+=2;
if (strafe> MAX_CAMMOVE) strafe=MAX_CAMMOVE;
}
dbTurnCameraRight(90);
dbMoveCamera(strafe);
dbTurnCameraLeft(90);
if (strafe<0) strafe += 0.5;
if (strafe>0) strafe -= 0.5;
// move forward/backward
if (dbUpKey()) {
move+=2;
if (move>MAX_CAMMOVE)
move=MAX_CAMMOVE;
}
if (dbDownKey()) {
move-=2;
if (move<-MAX_CAMMOVE)
move=-MAX_CAMMOVE;
}
if (move>0) move-=0.5;
if (move<0) move+=0.5;
dbMoveCamera(move);
xp=dbCameraPositionX();
yp=dbCameraPositionY();
zp=dbCameraPositionZ();
}
};
To use this in your program before your main loop use:
CamControl mycam; // will initialise a class for use
mycam.position(newxpos, newypos, newzpos); // set new position of camera
And then in your main loop just simply add the command:
mycam.update();
it will handle all movement, strafe and mouse controls.
I'm going to update this for you today to include a simple parabola jump function when either space or mouse key is pressed. I'll make it initialise the jump on the Y axis and return to where it jumped from while controlling movement in the fashion I've been trying to explain.
Warning! May contain Nuts!