#include #include #include #include "ball.h" struct ball * new_ball(float x, float y, float speed, float dir) { struct ball *b; b = malloc(sizeof(*b)); if (b == NULL) { return NULL; } b->x = x; b->y = y; b->speed = speed; b->dir = dir; return b; } void free_ball(struct ball *b) { free(b); } void clear_ball(struct ball *b) { mvprintw((int) (b->y + 0.5), (int) (b->x + 0.5), " "); } void update_ball(struct ball *b) { b->x += cosf(b->dir) * b->speed; b->y += sinf(b->dir) * b->speed; } void draw_ball(struct ball *b) { mvprintw((int) (b->y + 0.5), (int) (b->x + 0.5), "o"); }