Mathematical logic (basic trigger) in the game, what does this code do?
I am trying to understand what exactly this code does. It's written in Objective-C, but should be familiar to anyone with a C background. What exactly is sinful / cos math doing here? Also, does anyone have any good guidelines for learning triggers for game concepts like these?
for (int i = 0; i < GAME_CIRCLES; i++)
{
point.x = center.x - sin (degree) * RADIUS;
point.y = center.y + cos (degree) * RADIUS;
mPieRect[i] = CGRectMakeWithCenter (point, RADIUS - 4);
degree += PI / 3.0;
}
+2
randombits
source
to share
1 answer
This is a parametric equation for a circle (see wikipedia )
I am assuming that the variable "degree" is actually in radians and not degrees. There are 360 โโdegrees in a circle or 2 * Pi radians.
By advancing the variable of degree Pi / 3, it moves around 1/6 of the circle
+7
Paul dixon
source
to share