Hey guys again... I've added a bit to the program:
#include "DarkGDK.h"
void DarkGDK()
{
bool jumping = false;
int jc = 0;
float gravity = -1;
int oldX = 0;
int oldY = 0;
int newX = 0;
int newY = 0;
int dc=0;
int dd=1;
dbSyncOn();
dbSyncRate(60);
dbLoadImage("MartialL.bmp", 1);
dbLoadImage("MartialR.bmp", 2);
dbLoadImage("MartialJ.bmp", 3);
dbLoadImage("ground.bmp", 4);
dbLoadImage("rock.bmp", 5);
dbLoadImage("sky.bmp", 6);
dbLoadImage("Druk.bmp", 7);
dbLoadImage("Druk2.bmp", 8);
dbMakeObjectPlane(10, 800, 160);
dbMakeObjectBox(1, 10, 20, 0);
dbMakeObjectBox(2, 10, 10, 0);
dbMakeObjectBox(3, 15, 10, 0);
dbMakeObjectBox(11, 200, 60, 0);
dbMakeObjectBox(12, 100, 44, 0);
dbMakeObjectBox(13, 100, 44, 0);
dbPositionObject(1, 0, 2, 0);
dbPositionObject(2, 30, -5, 0);
dbPositionObject(10, 0, 10, 1);
dbPositionObject(11, 0, -40, 0);
dbPositionObject(12, 150, -48, 0);
dbPositionObject(13, -150, -48, 0);
dbPositionObject(3, 120, -21, 0);
dbTextureObject(1, 1);
dbTextureObject(2, 5);
dbTextureObject(11, 4);
dbTextureObject(12, 4);
dbTextureObject(13, 4);
dbTextureObject(10, 6);
dbTextureObject(3, 7);
dbSetAmbientLight(100);
dbRotateCamera(0, 0, 0);
dbRotateObject(1, 0, 0, 0);
while(LoopGDK())
{
// We deal with collision along the x-axis and y-axis seperately
// This means checking for collision twice each loop, once after moving
// left and right, then once after moving up and down.
// We also check for a collision below feet eack time the user tries to jump
//******************** X-component ***********************//
//check for movement and re-position
if(dbRightKey())
{
newX = newX + 1;
dbTextureObject(1, 2);
}
if(dbRightKey()&&dbShiftKey())
{
newX = newX + 1;
dbTextureObject(1, 2);
}
if(dbLeftKey())
{
newX = newX - 1;
dbTextureObject(1, 1);
}
if(dbLeftKey()&&dbShiftKey())
{
newX = newX - 1;
dbTextureObject(1, 1);
}
dbPositionObject(1, newX, dbObjectPositionY(1), dbObjectPositionZ(1));
//check for collision, put object back to where it was if there is a collision
if(dbObjectCollision(1, 0)<10 && dbSpaceKey())
{
dbDeleteObject(dbObjectCollision(1, 0));
}
else if(dbObjectCollision(1, 0)<10 && dbObjectCollision(1, 0)>0 && !dbSpaceKey())
{
newX = oldX;
}
else if(dbObjectCollision(1, 0)>=10)
{
dbPositionObject(1, oldX, dbObjectPositionY(1), dbObjectPositionZ(1));
newX = oldX;
}
else
{
oldX = newX;
}
//*********************** Y-component **************************//
//check for movement and re-position
if((dbUpKey()) && (jumping == false))
{
//Check for floor below feet by repositioning object, checking collision
//then move it back up.
dbPositionObject(1, dbObjectPositionX(1), dbObjectPositionY(1) - 1, dbObjectPositionZ(1));
bool floorBelow = dbObjectCollision(1, 0);
if(floorBelow)
{
jumping = true;
jc = 20;
dbTextureObject(1, 3);
}
dbPositionObject(1, dbObjectPositionX(1), dbObjectPositionY(1) + 1, dbObjectPositionZ(1));
}
if(jumping)
{
newY = newY + 2;
jc = jc - 1;
dbTextureObject(1, 3);
}
if(jc == 0)
{
jumping = false;
}
newY = newY + gravity;
dbPositionObject(1, dbObjectPositionX(1), newY, dbObjectPositionZ(1));
//check for collision, put object back to where it was if there is a collision
if(dbObjectCollision(1, 0))
{
dbPositionObject(1, dbObjectPositionX(1), oldY, dbObjectPositionZ(1));
newY = oldY;
}
else
{
oldY = newY;
}
if(newY <= -60)
{
dbPositionObject(1, 0, 2, 0);
newX=0;
newY=0;
oldX=0;
oldY=0;
}
if(dc==0&&dd==1)
{
dd=2; dbTextureObject(3, 8);
}
if(dc==40&&dd==2)
{
dd=1; dbTextureObject(3, 7);
}
if(dd==1){dbMoveObjectLeft(3, 1); dc--;}
if(dd==2){dbMoveObjectRight(3, 1); dc++;}
dbPositionCamera(dbObjectPositionX(1), dbObjectPositionY(1), -95);
dbSync();
}
}
and it works pretty well, but I was wondering if there was any way for me to make it so that the rock and druk(monster thingy... moving sprite) don't make me stop going up while jumping. And it's okay if nobody has ideas but that is a bit crucial to the game concept... also, any way to make semi buoyant water... so that gravity will not move him down when he's about half way in. As well... is there any way to make the background of sprite truly transparent or make it so that the druk will stop when it runs into martial. Anyways thanks guys and I'll keep working on it so this is not strictly speaking urgent!
I do only what is not required of me.