Smooth view :S

Talk about making games.

Smooth view :S

Postby alkoh002 » 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?
Current games:
Kreon (rpg) 2%
Gitaaah! (interactive) 5% (paused)

Past games:
Gurkot the game (arcade) 100% (ready)
Aeroth (rpg) 5% (cancelled)
User avatar
alkoh002
 
Posts: 33
Joined: Fri Sep 28, 2007 4:46 pm
Score: 0 Give a positive score

Re: Smooth view :S

Postby Kalladdolf » Wed Jan 30, 2008 8:37 am

there is a turtorial just about this very thing:
you'll find it in Game Editor.
help -> game stuff -> make view follow player (2)
it's really handy.
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: Smooth view :S

Postby DilloDude » Wed Jan 30, 2008 11:39 am

This works well for me:
Code: Select all
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);
    }
}

You'll need the xdist and ydist functions in global code:
Code: Select all
double xdist(double angsize, double dist)
{
    return cos(degtorad(angsize)) * dist;
}


double ydist(double angsize, double dist)
{
    return sin(degtorad(angsize)) * -dist;
}
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: Smooth view :S

Postby alkoh002 » Wed Jan 30, 2008 6:10 pm

Thanks people! :D
Current games:
Kreon (rpg) 2%
Gitaaah! (interactive) 5% (paused)

Past games:
Gurkot the game (arcade) 100% (ready)
Aeroth (rpg) 5% (cancelled)
User avatar
alkoh002
 
Posts: 33
Joined: Fri Sep 28, 2007 4:46 pm
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron