Hey guys, I downloaded the Dark GDK again yesterday and I've set out to make a small Platformer.
What I want is to be able to Jump (Either with Physics or just "jump"ing)
I've tried Box2D and S3GE both to no prevail and so I tried to create the "jump" functionality for myself.
What I have so far is:
#include "Library.h"
float y = dbSpriteY(10);
int velocityY;
bool jumping = false;
void Controls()
{
//Controls -- Directional Control Buttons
if(dbUpKey() == 1)
{
if(jumping == false)
{
y = dbSpriteY(10);
jumping = true;
}
}
if (jumping == true && dbSpriteY(10) != y) // Move Player if we are jumping
{
do
{
dbMoveSprite(10,velocityY);
velocityY = velocityY - 1;
}while(y != dbSpriteY(10));
}
if (dbSpriteY(10) <= y && jumping == true) // Check to see if Player has hit floor
{
velocityY = 0;
jumping = false;
}
if(dbLeftKey() == 1)
{
dbSetSpriteFrame(10,3);
dbRotateSprite(10,90);
dbMoveSprite(10,-1);
dbRotateSprite(10,0);
if(Collision() == true)
{
dbRotateSprite(10,90);
dbMoveSprite(10,1);
dbRotateSprite(10,0);
}
}
if(dbRightKey() == 1)
{
dbSetSpriteFrame(10,4);
dbRotateSprite(10,90);
dbMoveSprite(10,1);
dbRotateSprite(10,0);
if(Collision() == true)
{
dbRotateSprite(10,90);
dbMoveSprite(10,-1);
dbRotateSprite(10,0);
}
}
if(dbDownKey() == 1)
{
dbSetSpriteFrame(10,1);
dbMoveSprite(10,-1);
if(Collision() == true)
{
dbMoveSprite(10,1);
}
}
}
This compiles fine but doesn't work.
If there's a fix for this or a different/easier way of doing things, please let me know.
Thanks
Lee
Founder of Fireball Games