|
@ -8,15 +8,18 @@ void ball_think (ball_t *b) |
|
|
|
|
|
|
|
|
new_x = (b->x + b->dir_x) >> 8; |
|
|
new_x = (b->x + b->dir_x) >> 8; |
|
|
new_y = (b->y + b->dir_y) >> 8; |
|
|
new_y = (b->y + b->dir_y) >> 8; |
|
|
|
|
|
|
|
|
|
|
|
printf("B: %i %i, d: %i %i\n", new_x, new_y); |
|
|
|
|
|
|
|
|
/* ball fell out of the field */ |
|
|
/* ball fell out of the field */ |
|
|
if (new_y >= NUM_ROWS) |
|
|
// if (new_y >= NUM_ROWS)
|
|
|
ball_die (b); |
|
|
// ball_die (b);
|
|
|
|
|
|
|
|
|
/* bounce in x direction */ |
|
|
/* bounce in x direction */ |
|
|
if (check_bounce (new_x, b->y >> 8)) |
|
|
if (check_bounce (new_x, b->y >> 8)) |
|
|
{ |
|
|
{ |
|
|
b->dir_x *= -1; /* invert x vector */ |
|
|
b->dir_x *= -1; /* invert x vector */ |
|
|
|
|
|
new_x += b->dir_x; |
|
|
|
|
|
|
|
|
#if BOUNCE_SLOWDOWN |
|
|
#if BOUNCE_SLOWDOWN |
|
|
if (b->dir_x < 0) |
|
|
if (b->dir_x < 0) |
|
@ -30,9 +33,10 @@ void ball_think (ball_t *b) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* bounce in y direction */ |
|
|
/* bounce in y direction */ |
|
|
if (check_bounce (b->x >> 8), new_y) |
|
|
if (check_bounce ((b->x >> 8), new_y)) |
|
|
{ |
|
|
{ |
|
|
b->dir_y *= -1; /* invert y vector */ |
|
|
b->dir_y *= -1; /* invert y vector */ |
|
|
|
|
|
new_y += b->dir_y; |
|
|
|
|
|
|
|
|
#if BOUNCE_SLOWDOWN |
|
|
#if BOUNCE_SLOWDOWN |
|
|
if (b->dir_y < 0) |
|
|
if (b->dir_y < 0) |
|
@ -44,6 +48,9 @@ void ball_think (ball_t *b) |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
b->x = new_x; |
|
|
|
|
|
b->y = new_y; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void ball_die (ball_t *in_b) |
|
|
void ball_die (ball_t *in_b) |
|
@ -54,3 +61,21 @@ void ball_die (ball_t *in_b) |
|
|
if (in_b->strength) |
|
|
if (in_b->strength) |
|
|
ball_spawn (in_b, (NUM_COLS / 2) << 8, (NUM_ROWS-2) << 8, - random8(), random8(), START_LIFES); |
|
|
ball_spawn (in_b, (NUM_COLS / 2) << 8, (NUM_ROWS-2) << 8, - random8(), random8(), START_LIFES); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ball_draw (ball_t *b) |
|
|
|
|
|
{ |
|
|
|
|
|
pixel p; |
|
|
|
|
|
p.x = b->x; |
|
|
|
|
|
p.y = b->y; |
|
|
|
|
|
|
|
|
|
|
|
setpixel (p, 3); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ball_spawn (ball_t *in_ball, uint16_t in_x, uint16_t in_y, int16_t in_dir_x, int16_t in_dir_y, uint8_t in_strength) |
|
|
|
|
|
{ |
|
|
|
|
|
in_ball->x = in_x; |
|
|
|
|
|
in_ball->y = in_y; |
|
|
|
|
|
in_ball->dir_x = in_dir_x; |
|
|
|
|
|
in_ball->dir_y = in_dir_y; |
|
|
|
|
|
in_ball->strength = in_strength; |
|
|
|
|
|
} |
|
|