diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ball.c | 17 | ||||
-rw-r--r-- | src/ball.h | 1 | ||||
-rw-r--r-- | src/level.c | 1 |
3 files changed, 19 insertions, 0 deletions
@@ -77,6 +77,23 @@ db_ball_new(int x, int y, int r, int a, int d, int sr, double s, } void +db_balls_move(struct db_ball *ball) +{ + if (ball->sr == 0) { + } 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; + db_dbg("Spinning ball angle %f (speed %f, direction %d)", + ball->a, ball->s, ball->d); + } + + if (ball->next != NULL) { + db_balls_move(ball->next); + } +} + +void db_balls_collisions(struct db_ball *ball) { struct db_ball *other; @@ -26,6 +26,7 @@ struct db_ball; struct db_ball *db_ball_new(int x, int y, int r, int a, int d, int sr, double s, struct db_tileset *tilesets, int gid, struct db_ball *prev); +void db_balls_move(struct db_ball *ball); 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) diff --git a/src/level.c b/src/level.c index 8c6a1bd..b8dc618 100644 --- a/src/level.c +++ b/src/level.c @@ -137,6 +137,7 @@ db_level_play(SDL_Renderer *renderer, struct db_level *level) break; } } + db_balls_move(level->balls); _db_level_render(renderer, level); cur_ticks = SDL_GetTicks(); if ((Uint32) (1000 / fr) > (cur_ticks - prv_ticks)) { |