From 3c71b27c5e1a74e75600efb730ab3252f9d468f6 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Thu, 25 Mar 2021 19:09:02 -0400 Subject: ball: Position spinning ball --- (limited to 'src') diff --git a/src/ball.c b/src/ball.c index ce39c0a..862efc4 100644 --- a/src/ball.c +++ b/src/ball.c @@ -17,6 +17,7 @@ * along with Dodge Balls. If not, see . */ +#include #include #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; -- cgit v0.9.1