Browse Source

removed middle line from kart / added alternating border colors

feature/2015
Stefan Kinzel 11 years ago
parent
commit
3843d9f9de
  1. 25
      src/games/kart/kart.c

25
src/games/kart/kart.c

@ -60,8 +60,8 @@ game_descriptor_t kart_game_descriptor __attribute__((section(".game_descriptors
#define KEY_IGNORE 7 #define KEY_IGNORE 7
#define CARCOLOR 3 #define CARCOLOR 3
#define BORDERCOLOR 2 #define BORDER_LIGHT 1
#define LINECOLOR 1 #define BORDER_DARK 2
#define OBSTACLE_COLOR 3 #define OBSTACLE_COLOR 3
// borders = (middle, width, obstacle_pos) // borders = (middle, width, obstacle_pos)
@ -76,7 +76,7 @@ void kart_game(){
uint8_t drive_div = DRIVE_DIV; uint8_t drive_div = DRIVE_DIV;
uint8_t carpos = NUM_COLS / 2; uint8_t carpos = NUM_COLS / 2;
uint32_t cycle = 0; uint32_t cycle = 0;
uint8_t draw_middle_line = 1; uint8_t light_border = 1;
uint8_t width = NUM_COLS - 2; uint8_t width = NUM_COLS - 2;
uint8_t middle = NUM_COLS / 2; uint8_t middle = NUM_COLS / 2;
// obstacle_pos == 0 --> no obstacle // obstacle_pos == 0 --> no obstacle
@ -98,8 +98,8 @@ void kart_game(){
} }
// init street border // init street border
line((pixel){0,0}, (pixel){0,NUM_ROWS}, BORDERCOLOR); line((pixel){0,0}, (pixel){0,NUM_ROWS}, BORDER_DARK);
line((pixel){NUM_COLS-1,0}, (pixel){NUM_COLS-1,NUM_ROWS}, BORDERCOLOR); line((pixel){NUM_COLS-1,0}, (pixel){NUM_COLS-1,NUM_ROWS}, BORDER_DARK);
setpixel((pixel){carpos, NUM_ROWS-1}, CARCOLOR); setpixel((pixel){carpos, NUM_ROWS-1}, CARCOLOR);
@ -186,18 +186,17 @@ void kart_game(){
unsigned int px; unsigned int px;
for(px=0; px < NUM_COLS; px++){ for(px=0; px < NUM_COLS; px++){
if(px<middle-(width/2) || px >= middle+(width/2)){ if(px<middle-(width/2) || px >= middle+(width/2)){
setpixel((pixel){px, 0}, BORDERCOLOR); if(light_border){
setpixel((pixel){px, 0}, BORDER_LIGHT);
}else{
setpixel((pixel){px, 0}, BORDER_DARK);
}
} }
} }
// toggle drawing the middle line // toggle border color
if(cycle % ((drive_div / boost_multiplier)*4) == 0){ if(cycle % ((drive_div / boost_multiplier)*4) == 0){
draw_middle_line = 1-draw_middle_line; light_border = 1-light_border;
}
// paint middle line
if(width > 6 && draw_middle_line){
setpixel((pixel){middle, 0}, LINECOLOR);
} }
// set obstacle // set obstacle

Loading…
Cancel
Save