Implemented collisions.
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user