Add the following in global code:
- Code: Select all
float d2R(int degrees)
{
return degrees * (3.1415926535897932384626433832795 / 180);
}
double xdist(int deg, double dist)
{
return dist * cos(d2R(deg));
}
double ydist(int deg, double dist)
{
return -dist * sin(d2R(deg));
}
Now, in draw actor->motor:
- Code: Select all
x=hover.x;
y=hover.y;
x+=xdist(angle between hovercraft and motor(hovercraft.angle-180), distance from hovercraft center);
y+=ydist(angle between hovercraft and motor(hovercraft.angle-180), distance from hovercraft center);
This is useful for anything where an actor should be a certain distance from another. My brother helped me make it for creating a shot at the end of a cannon's barrel, and I modified it to make two functions.
Another way that solves some problems is to make the animation rotate around a central point.