From 30bb703ff3185f9c9c05cfbd67f0d008ea4c29bb Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 27 Mar 2021 16:20:58 -0400 Subject: 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. --- 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); } diff --git a/src/map.c b/src/map.c index 7eb4ddb..add4c3e 100644 --- a/src/map.c +++ b/src/map.c @@ -440,7 +440,6 @@ _db_tmx_object_property_start(void *pv, const char *name, const char **attr) free(p_type); db_dbg(" Object speed: %f px/s", map->obj_s); - map->obj_s /= map->fr; /* Convert px/s to px/f */ } else if (strcmp(p_name, "direction") == 0) { db_xml_get_string_attr(p, attr, "value", &dir, 1); if (strcmp(dir, "lr") == 0) { @@ -458,12 +457,12 @@ _db_tmx_object_property_start(void *pv, const char *name, const char **attr) "random"); } else if (strcmp(dir, "cw") == 0) { map->obj_a = rand() / (RAND_MAX / 360); - map->obj_d = -1; + map->obj_d = 1; db_dbg(" Object direction: " "clockwise"); } else if (strcmp(dir, "ccw") == 0) { map->obj_a = rand() / (RAND_MAX / 360); - map->obj_d = 1; + map->obj_d = -1; db_dbg(" Object direction: " "counter-clockwise"); } -- cgit v0.9.1