Implemented collisions.

This commit is contained in:
2016-12-17 15:40:40 +02:00
parent 42f0d4125b
commit a7af100122
14 changed files with 651 additions and 11 deletions

View File

@@ -26,9 +26,10 @@ void move(float *x, float *y, model::Direction direction, float distance)
void moveTowards(float *x, float *y, float towardsX, float towardsY, float speed)
{
float angle = atan2f(towardsX - *x, towardsY - *y);
// Y coordinate is opposite of trigonometric coordinates
float angle = atan2f(-(towardsY - *y), towardsX - *x);
*x += cosf(angle) * speed;
*y += sinf(angle) * speed;
*y -= sinf(angle) * speed;
}
float distanceSq(float x0, float y0, float x1, float y1)