Smooth view :S
Posted: Tue Jan 29, 2008 8:58 pm
Hi, (duh! i have all these questions, which the answer is really simple.. :S) how can i make so the view follows its parent "smoothly" and not the exact movement by the parent?
int refx = x + 160;//change to half the width
int refy = y + 120;//change to half the height
if (unpaused)//use whatever conditionals to limit
{
double dir;
double spd;
dir = direction(refx, refy, player.x, player.y);
spd = distance(refx, refy, player.x, player.y) * .1;//adjust this value to suit
if (spd > .2)//adjust this too
{
x += xdist(dir, spd);
y += ydist(dir, spd);
}
}
double xdist(double angsize, double dist)
{
return cos(degtorad(angsize)) * dist;
}
double ydist(double angsize, double dist)
{
return sin(degtorad(angsize)) * -dist;
}