why do you have your up key corresponding with x and your right key corresponding with y?

Your limited movement is probably due to the fact of confusing code

Heres what you need to do...add this for your movements instead and use this also for incrementing/decrementing the players position:

if(dbUpKey() && y > 0)
{
y-=3;
dbSprite(31,x,y,31);
}
if(dbDownKey() && y < 550)
{
y+=3;
dbSprite(31,x,y,31);
}
if(dbRightKey() && x < 380)
{
x+=3;
dbSprite(31,x,y,31);
}
if(dbLeftKey() && x > 0)
{
x-=3;
dbSprite(31,x,y,31);
}

I don't have the time to look through the rest of your code, but i just commented out the rest and figured out your movements. Also, if you were aiming to have boundaries on the outskirts of the level....they were off for the max y value and max x values.