summaryrefslogtreecommitdiffstats
path: root/src/ball.c
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-27 16:20:58 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-27 16:20:58 (EDT)
commit30bb703ff3185f9c9c05cfbd67f0d008ea4c29bb (patch)
tree9a1b704dcff9f5ffc7a95d3156fa441272744683 /src/ball.c
parent90e42581e1360da1d422d40545fc5fd24f531813 (diff)
downloaddodge-balls-30bb703ff3185f9c9c05cfbd67f0d008ea4c29bb.zip
dodge-balls-30bb703ff3185f9c9c05cfbd67f0d008ea4c29bb.tar.gz
dodge-balls-30bb703ff3185f9c9c05cfbd67f0d008ea4c29bb.tar.bz2
ball, map: Convert to left-hand rule
The SDL coordinate system has a negative orientation (the positive y-axis points down). It's easier to not fight it.
Diffstat (limited to 'src/ball.c')
-rw-r--r--src/ball.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ball.c b/src/ball.c
index 3230628..ccdccec 100644
--- a/src/ball.c
+++ b/src/ball.c
@@ -59,7 +59,7 @@ db_ball_new(int x, int y, int r, int a, int d, int sr, double s,
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->y = y + sin(a * (M_PI / 180)) * sr;
}
ball->r = r;
ball->a = a;
@@ -81,11 +81,11 @@ db_balls_move(struct db_ball *ball)
{
if (ball->sr == 0) {
ball->x += cos(ball->a * (M_PI / 180));
- ball->y -= sin(ball->a * (M_PI / 180));
+ ball->y += sin(ball->a * (M_PI / 180));
} else {
ball->a += ball->d * ball->s;
ball->x = ball->cx + cos(ball->a * (M_PI / 180)) * ball->sr;
- ball->y = ball->cy - sin(ball->a * (M_PI / 180)) * ball->sr;
+ ball->y = ball->cy + sin(ball->a * (M_PI / 180)) * ball->sr;
db_dbg("Spinning ball angle %f (speed %f, direction %d)",
ball->a, ball->s, ball->d);
}