diff --git a/games/breakout/ball.h b/games/breakout/ball.h index 1ccbc28..91d73c5 100644 --- a/games/breakout/ball.h +++ b/games/breakout/ball.h @@ -27,9 +27,6 @@ void ball_spawn (ball_t *in_ball, uint16_t in_x, uint16_t in_y, int16_t in_dir_x */ void ball_think (ball_t *in_ball); -/* @description Change the ball's moving vector according to bounce and collision type - */ -void ball_bounce (ball_t *in_ball, enum collision_t in_coltype); -void ball_die (ball_t *in_b) +void ball_die (ball_t *in_b); #endif /* BALL_H */ diff --git a/games/breakout/breakout.c b/games/breakout/breakout.c index d63b40d..2dcc506 100644 --- a/games/breakout/breakout.c +++ b/games/breakout/breakout.c @@ -1,13 +1,13 @@ - -#include "../../menu/menu.h" +#include "common.h" +void borg_breakout(); #ifdef MENU_SUPPORT -static uint8_t icon[8] PROGMEM = - {0x03, 0x03, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00}; /* our Icon */ +const uint8_t breakout_icon[8] PROGMEM = {0x03, 0x03, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00}; /* our Icon */ -game_descriptor_t invaders_game_descriptor __attribute__((section(".game_descriptors"))) ={ +game_descriptor_t breakout_game_descriptor __attribute__((section(".game_descriptors"))) = +{ &borg_breakout, - icon, + breakout_icon, }; #endif @@ -17,6 +17,7 @@ void borg_breakout() ball_t balls[1]; ball_init (balls[0]); + rebound_init(); /* spawn a ball in the middle bottom of the field, let it move upwards with random speed & x-direction */ ball_spawn (balls[0], (NUM_COLS / 2) << 8, (NUM_ROWS-2) << 8, - random8(), random8(), START_LIFES); @@ -24,6 +25,7 @@ void borg_breakout() while (rungame) { + rebound_tick(); ball_think(balls[0]); playfield_draw(); ball_draw(balls[0]); diff --git a/games/breakout/common.h b/games/breakout/common.h index 7cd915b..3688407 100644 --- a/games/breakout/common.h +++ b/games/breakout/common.h @@ -2,11 +2,16 @@ #define COMMON_H #include #include "../../config.h" +#include "../../autoconf.h" +#include "../../compat/eeprom.h" #include "../../random/prng.h" +#include "../../menu/menu.h" +#include "../../compat/pgmspace.h" #include "../../pixel.h" #include "config.h" #include "playfield.h" #include "ball.h" #include "score.h" #include "level.h" +#include "rebound.h" #endif /* COMMON_H */ diff --git a/games/breakout/config.h b/games/breakout/config.h index d4f8b47..4d51640 100644 --- a/games/breakout/config.h +++ b/games/breakout/config.h @@ -6,3 +6,9 @@ /* initial amount of lifes */ #define START_LIFES 3 + +/* rebound size */ +#define REBOUND_SIZE 5 + +/* "color" of the rebound */ +#define REBOUND_COLOR 2 diff --git a/games/breakout/level.c b/games/breakout/level.c index 86e4f85..ff788b7 100644 --- a/games/breakout/level.c +++ b/games/breakout/level.c @@ -21,7 +21,7 @@ inline void level_field (uint8_t in_x, uint8_t in_y, uint8_t in_lvl) case 3: /* add a row of solid bricks right in the middle of the field */ if (in_y == (NUM_ROWS / 2) && - (in_x > (NUM_COLS / 4) && in_x < (NUM_COLS - (NUM_COLS / 4))) + (in_x > (NUM_COLS / 4)) && (in_x < (NUM_COLS - (NUM_COLS / 4)))) return bs; /* intentional fallthrough: the rest of level 3 is like level 2 */ diff --git a/games/breakout/playfield.c b/games/breakout/playfield.c index 031d381..00a3f3b 100644 --- a/games/breakout/playfield.c +++ b/games/breakout/playfield.c @@ -44,26 +44,26 @@ uint8_t check_bounce (uint8_t in_x, uint8_t in_y) /* this is the actual draw function for a single field */ -static inline void draw_single_field (game_field_t in_f) +static inline void draw_single_field (uint8_t in_x, uint8_t in_y, game_field_t in_f) { switch (in_f) { case b1: - setPixel (); + setPixel (in_x, in_y, 1); return; case rb: case b2: - + setPixel (in_x, in_y, 2); return; case b3: case bl: case bs: - + setPixel (in_x, in_y, 3); return; default: /* this includes freespace */ - + setPixel (in_x, in_y, 0); return; } @@ -77,7 +77,7 @@ void playfield_draw () { for (y=0;y -#include "ball.h" -#include "score.h" - #ifndef PLAYFIELD_H #define PLAYFIELD_H +#include "common.h" /* entries for the playing field */ enum game_field_t { sp = 0, /* space */ b1 = 1, b2 = 2, b3 = 3, /* bricks */ - bs = 4 /* solid (unbreakable) brick */ + bs = 4, /* solid (unbreakable) brick */ bl, /* ball */ - rb, /* rebound */ + rb /* rebound */ }; diff --git a/games/breakout/score.h b/games/breakout/score.h index 3d5ce79..90dcc6b 100644 --- a/games/breakout/score.h +++ b/games/breakout/score.h @@ -6,7 +6,7 @@ static uint16_t score = 0; void score_add(uint8_t); -score_add (uint8_t in_score) +void score_add (uint8_t in_score) { score += in_score; }