diff options
-rw-r--r-- | src/ball.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -17,6 +17,7 @@ * along with Dodge Balls. If not, see <http://www.gnu.org/licenses/>. */ +#include <math.h> #include <stdlib.h> #include "ball.h" #include "collision.h" @@ -24,6 +25,8 @@ #include "output.h" struct db_ball { + int cx; + int cy; double x; double y; int r; @@ -49,8 +52,15 @@ db_ball_new(int x, int y, int r, int a, int d, int sr, double s, } db_dbg("Ball at (%d,%d)", x, y); - ball->x = x; - ball->y = y; + if (sr == 0) { + ball->x = x; + ball->y = y; + } else { + ball->cx = x; + ball->cy = y; + ball->x = x + cos(a * (M_PI / 180)) * sr; + ball->y = y - sin(a * (M_PI / 180)) * sr; + } ball->r = r; ball->a = a; ball->d = d; |