From fed0f2cf2d47f55e1d6e16966e4983fe3c828745 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Thu, 25 Mar 2021 18:38:46 -0400 Subject: ball: Render --- (limited to 'src/ball.c') diff --git a/src/ball.c b/src/ball.c index b8dd78b..ce39c0a 100644 --- a/src/ball.c +++ b/src/ball.c @@ -48,6 +48,7 @@ db_ball_new(int x, int y, int r, int a, int d, int sr, double s, return NULL; } + db_dbg("Ball at (%d,%d)", x, y); ball->x = x; ball->y = y; ball->r = r; @@ -101,3 +102,21 @@ db_balls_player_collisions(struct db_ball *ball, return 0; } } + +void +db_balls_render(struct db_ball *ball, SDL_Renderer *renderer) +{ + SDL_Rect dstrect; + + dstrect.x = ball->x - ball->r; + dstrect.y = ball->y - ball->r; + dstrect.w = ball->r * 2; + dstrect.h = ball->r * 2; + db_dbg("Rendering ball (%dx%d) at (%d,%d)", + dstrect.w, dstrect.h, dstrect.x, dstrect.y); + db_tile_render(ball->tilesets, renderer, ball->gid, &dstrect); + + if (ball->next != NULL) { + db_balls_render(ball->next, renderer); + } +} -- cgit v0.9.1