|
|
@ -1,5 +1,6 @@ |
|
|
|
#include "common.h" |
|
|
|
|
|
|
|
|
|
|
|
void ball_think (ball_t *b) |
|
|
|
{ |
|
|
|
int8_t proj_x, proj_y, bounce; |
|
|
@ -9,6 +10,11 @@ void ball_think (ball_t *b) |
|
|
|
/* projection of the new coordinates */ |
|
|
|
proj_x = (b->x + (b->dir_x)) / 256; |
|
|
|
proj_y = (b->y + (b->dir_y)) / 256; |
|
|
|
|
|
|
|
/* ball fell out of the field */ |
|
|
|
if (proj_y >= NUM_ROWS) |
|
|
|
ball_die (b); |
|
|
|
|
|
|
|
|
|
|
|
bounce = check_bounce (proj_x, b->y / 256); |
|
|
|
if (bounce & BOUNCE_UNDEF) |
|
|
@ -23,10 +29,6 @@ void ball_think (ball_t *b) |
|
|
|
bounce = BOUNCE_X | BOUNCE_Y; |
|
|
|
|
|
|
|
|
|
|
|
/* ball fell out of the field */ |
|
|
|
// if (proj_y >= NUM_ROWS)
|
|
|
|
// ball_die (b);
|
|
|
|
|
|
|
|
|
|
|
|
/* bounce in x direction */ |
|
|
|
if (bounce & 0x01) |
|
|
@ -64,10 +66,6 @@ void ball_think (ball_t *b) |
|
|
|
|
|
|
|
b->y += b->dir_y; |
|
|
|
b->x += b->dir_x; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("B: %i %i, d: %i %i\n", b->x, b->y, b->dir_x, b->dir_y); |
|
|
|
} |
|
|
|
|
|
|
|
void ball_die (ball_t *in_b) |
|
|
@ -76,7 +74,10 @@ void ball_die (ball_t *in_b) |
|
|
|
|
|
|
|
/* respawn ball with random direction */ |
|
|
|
if (in_b->strength) |
|
|
|
ball_spawn (in_b, (NUM_COLS / 2) << 8, (NUM_ROWS-2) << 8, - random8(), random8(), START_LIFES); |
|
|
|
{ |
|
|
|
print_ballsleft(in_b); |
|
|
|
ball_spawn (in_b, (uint16_t) (rebound_getpos() * 256), (uint16_t) (NUM_ROWS-2) * 256, -120, 150, in_b->strength); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void ball_draw (ball_t *b) |
|
|
@ -85,17 +86,19 @@ void ball_draw (ball_t *b) |
|
|
|
p.x = (uint8_t) abs(b->x / 256); |
|
|
|
p.y = (uint8_t) abs(b->y / 256); |
|
|
|
|
|
|
|
printf("db: %i %i\n", p.x, p.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) |
|
|
|
{ |
|
|
|
printf ("spawn: %i %i, dir: %i, %i\n", in_x, in_y, in_dir_x, in_dir_y); |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
void ball_spawn_default (ball_t *in_b) |
|
|
|
{ |
|
|
|
ball_spawn (in_b, (uint16_t) (NUM_COLS / 2) * 256, (uint16_t) (NUM_ROWS-2) * 256, -120, 150, START_LIFES); |
|
|
|
} |
|
|
|