Prevent 90 deg ball throw
This commit is contained in:
parent
039149a745
commit
05addb3baa
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user