Prevent 90 deg ball throw

This commit is contained in:
Pradana AUMARS 2021-06-28 14:12:18 +02:00
parent 039149a745
commit 05addb3baa

View File

@ -21,7 +21,10 @@ Ball_init(int screen_width, int screen_height)
void
Ball_reset(Ball *b, int direction) {
// 120 deg angle with norm horizontal vector
const int angle = rand() % 60 + 60;
int angle;
do {
angle = rand() % 60 + 60;
} while (angle == 90);
b->posX = b->SCREEN_WIDTH/2;
b->posY = b->SCREEN_HEIGHT/2;
b->velX = direction * b->BALL_VELOCITY * cos(angle * 2 * M_PI / 180);