I got the collision thing working but allow me to explain for clarity. My old collision code checked for a collision with my player and stored the id of the other object in a variable it was setup as (hit=dbSpriteCollision(player_id,0)
then I used the hit variable to check if the other object was in a range of objects held for ground, walls, and ceilings exclusivley. Now the issue was that If i was at a corner where he was hitting a wall & a Floor tile then he became confused because only one collision was being read. So if i jumped i could A.) Phase through the wall(if it was reading the floor collision) or B.)fall through the floor(if it was reading the wall) I fixed this by adding a new sprite that moves to key positions around the played and checks for collisions. that way i can check specific positions and know if its a wall celing or floor and only check one at a time then act accordingly.
But now a new issue has arisen. First let me give u some source:
Ground collision Check Code
id+1 means satalite)
dbSprite(id+1,dbSpriteX(id),dbSpriteY(id)+129,15002);
hit=dbSpriteCollision(id+1,0);
if(hit<=15000 && hit!=15001 && hit!=15002 && hit!=0)
{
jumping=0;
jump_power=jump;
gravity=grav;
plr.y=dbSpriteY(hit)-128;
}
else
{
dbSprite(id+1,dbSpriteX(id)+32,dbSpriteY(id)+129,15002);
hit=dbSpriteCollision(id+1,0);
if(hit<=15000 && hit!=15001 && hit!=15002 && hit!=0)
{
jumping=0;
jump_power=jump;
gravity=grav;
plr.y=dbSpriteY(hit)-128;
}
else
{
dbSprite(id+1,dbSpriteX(id)+48,dbSpriteY(id)+129,15002);
hit=dbSpriteCollision(id+1,0);
if(hit<=15000 && hit!=15001 && hit!=15002 && hit!=0)
{
jumping=0;
jump_power=jump;
gravity=grav;
plr.y=dbSpriteY(hit)-128;
}
else
{
jumping=1;
jump_power=0;
gravity=grav;
}
}
}
Jumping Code:
if(dbUpKey() && jumping==0)
{
jumping=1;
jump_power=jump;
gravity=grav;
plr.y-=6;
}
if(jumping==1)
{
plr.y-=jump_power;
jump_power-=gravity;
gravity*=1.1;
}
Falling Code:As seen at bottom of jumping code
else
{
jumping=1;
jump_power=0;
gravity=grav;
}
Constant Variables Used in the above:
#define mvspd 7;
#define jump 12;
#define grav 1
int jumping=0;
int gravity=1;
int jump_power=0;
now the issue is that when i press up to jump he moves just eneough pixels that the satalite on the bottom is on pixel away from the floor. then he just hangs there, he wont fall or anything. Left and right movement still works fine, so I assume its something in my jump code(left and right movement is handled in the same was as floor collision checking in that it cycles 4 positions and returns the hit value and if it hits then he moves to a specified x position) Included is a pic of whats happening. I have no idea whats wrong here any ideas?