diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ball.c | 19 | ||||
-rw-r--r-- | src/ball.h | 1 | ||||
-rw-r--r-- | src/level.c | 1 |
3 files changed, 21 insertions, 0 deletions
@@ -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); + } +} @@ -30,5 +30,6 @@ void db_balls_collisions(struct db_ball *ball_head); int db_balls_player_collisions(struct db_ball *ball_head, int player_x, int player_y, int player_r) __attribute__((__pure__)); +void db_balls_render(struct db_ball *ball, SDL_Renderer *renderer); #endif /* DB_BALL_H_ */ diff --git a/src/level.c b/src/level.c index efa566c..9de9182 100644 --- a/src/level.c +++ b/src/level.c @@ -101,6 +101,7 @@ db_level_play(SDL_Renderer *renderer, struct db_level *level) db_err("Failed to copy texture (%s)", SDL_GetError()); return -1; } + db_balls_render(level->balls, renderer); SDL_RenderPresent(renderer); SDL_Delay(1000); |