diff options
| author | raysan5 <[email protected]> | 2016-10-31 20:39:03 +0100 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2016-10-31 20:39:03 +0100 |
| commit | 673dcf94364d37f3d52285ac27c88707ae567872 (patch) | |
| tree | 23e63c55662410be2c3147aac1ddc3e950cc47df /src/shapes.c | |
| parent | cc917fbac6e7007fdb744afaf8f0879c984d95af (diff) | |
| download | raylib-673dcf94364d37f3d52285ac27c88707ae567872.tar.gz raylib-673dcf94364d37f3d52285ac27c88707ae567872.zip | |
Comments tweaks
Diffstat (limited to 'src/shapes.c')
| -rw-r--r-- | src/shapes.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/shapes.c b/src/shapes.c index 62076b2c..79cf567a 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -4,7 +4,7 @@ * * Basic functions to draw 2d Shapes and check collisions * -* Copyright (c) 2014 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. @@ -25,9 +25,8 @@ #include "raylib.h" -#include <stdlib.h> // Required for abs() function -#include <math.h> // Math related functions, sin() and cos() used on DrawCircle* - // sqrt() and pow() and abs() used on CheckCollision* +#include <stdlib.h> // Required for: abs() +#include <math.h> // Required for: sinf(), cosf(), sqrtf() #include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2 @@ -331,8 +330,8 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col rlColor4ub(color.r, color.g, color.b, color.a); rlVertex2f(0, 0); - rlVertex2f(sin(DEG2RAD*i)*radius, cos(DEG2RAD*i)*radius); - rlVertex2f(sin(DEG2RAD*(i + 360/sides))*radius, cos(DEG2RAD*(i + 360/sides))*radius); + rlVertex2f(sinf(DEG2RAD*i)*radius, cosf(DEG2RAD*i)*radius); + rlVertex2f(sinf(DEG2RAD*(i + 360/sides))*radius, cosf(DEG2RAD*(i + 360/sides))*radius); } rlEnd(); rlPopMatrix(); @@ -434,7 +433,7 @@ bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, floa float dx = center2.x - center1.x; // X distance between centers float dy = center2.y - center1.y; // Y distance between centers - float distance = sqrt(dx*dx + dy*dy); // Distance between centers + float distance = sqrtf(dx*dx + dy*dy); // Distance between centers if (distance <= (radius1 + radius2)) collision = true; @@ -457,7 +456,7 @@ bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec) if (dx <= (rec.width/2)) { return true; } if (dy <= (rec.height/2)) { return true; } - float cornerDistanceSq = pow(dx - rec.width/2, 2) + pow(dy - rec.height/2, 2); + float cornerDistanceSq = (dx - rec.width/2)*(dx - rec.width/2) + (dy - rec.height/2)*(dy - rec.height/2); return (cornerDistanceSq <= (radius*radius)); } |
