thanx mon'. everytime i learn something new the firsts time i post on a forum i expect a ripping, but that was pretty helpful .
i wrote this at midnight and was dead tired, so i expected a bunha syntax errors, good to see it was only my stupidity :0
so should i set another blit, like this?
Code:
// starts off where the keys are called,
blit(zombie, screen, 0, 0, zombieS.x, zombieS.y, 50, 50); // NEED TO LOCK X Y
refreshText(); // starts out the refreshables
//------------------------------------------------
if(key[KEY_UP]) //dont know how to define if any key is pressed :/
movement(zombieS.x, zombieS.y);
rectfill(screen, zombieS.x, zombieS.y, 50, 50, 0); //erase the sprite
blit(zombie, screen, 0, 0, zombieS.x, zombieS.y, 50, 50); //recall the new location
refreshText();
//-------------------------------------------------
if(key[KEY_DOWN])
movement(zombieS.x, zombieS.y);
rectfill(screen, zombieS.x, zombieS.y, 50, 50, 0); //erase the sprite
blit(zombie, screen, 0, 0, zombieS.x, zombieS.y, 50, 50); //recall the new location
refreshText();
//-----------------------------------------------------
if(key[KEY_RIGHT])
movement(zombieS.x, zombieS.y);
rectfill(screen, zombieS.x, zombieS.y, 50, 50, 0); //erase the sprite
blit(zombie, screen, 0, 0, zombieS.x, zombieS.y, 50, 50); //recall the new location
refreshText();
//-------------------------------------------------------
if(key[KEY_LEFT])
movement(zombieS.x, zombieS.y);
rectfill(screen, zombieS.x, zombieS.y, 50, 50, 0); //erase the sprite
blit(zombie, screen, 0, 0, zombieS.x, zombieS.y, 50, 50); //recall the new location
refreshText();
i know its impracticle, but is it plausable?
or i could write a function for the x and y variabels sepratly and do something like,
Code:
int y_dec(int y);
int x_dec(int x)
{
if(key[KEY_LEFT])
{
if(x<=0)
return x;
else
{
x++;
return x;
}
}
if(key[KEY_RIGHT])
{
if(x>=480)
return x;
else
{
x++;
return x;
}
}
}
// do the same for all other directions, then
if(key[KEY_RIGHT])
x_dec(zombieS.x)
rectfill(screen, zombieS.x, zombieS.y, 50, 50, 0);
blit(zombie, screen, 0, 0, zombieS.x, zombieS.y, 50, 50);
refreshtext();
if(key[KEY_LEFT])
x_dec(zombieS.x)
rectfill(screen, zombieS.x, zombieS.y, 50, 50, 0);
blit(zombie, screen, 0, 0, zombieS.x, zombieS.y, 50, 50);
refreshtext();
//ect. ect. ect.
which way is more likely to succeed, or be more successful?