Index: menuselect_curses.c =================================================================== --- menuselect_curses.c (revision 953) +++ menuselect_curses.c (working copy) @@ -565,7 +565,8 @@ BLIP_TANK = 0, BLIP_SHOT, BLIP_BOMB, - BLIP_ALIEN + BLIP_ALIEN, + BLIP_UFO }; struct blip { @@ -580,9 +581,11 @@ static AST_LIST_HEAD_NOLOCK(, blip) blips; +static int respawn = 0; static int score = 0; static int num_aliens = 0; static int alien_sleeptime = 0; +struct blip *ufo = NULL; struct blip *tank = NULL; /*! Probability of a bomb, out of 100 */ @@ -614,7 +617,7 @@ return -1; cur->type = BLIP_ALIEN; cur->x = (j * 2) + 1; - cur->y = (i * 2) + 1; + cur->y = (i * 2) + 2; AST_LIST_INSERT_HEAD(&blips, cur, entry); num_aliens++; } @@ -634,6 +637,8 @@ return '|'; case BLIP_BOMB: return 'o'; + case BLIP_UFO: + return '@'; default: break; } @@ -795,6 +800,41 @@ return 0; } +static int ufo_action() +{ + struct blip *cur; + + + AST_LIST_TRAVERSE(&blips, cur, entry) { + if (cur->type != BLIP_UFO) { + continue; + } + + cur->x--; + + if (cur->x < 0) { + remove_blip(cur); + respawn += 1; + } + + } + + if (respawn == 7) { + respawn = 0; + /* make new mothership*/ + cur = calloc(1, sizeof(struct blip)); + if(!cur) + return -1; + cur->type = BLIP_UFO; + cur->x = max_x - 1; + cur->y = 1; + AST_LIST_INSERT_HEAD(&blips, cur, entry); + } + + return 0; +} + + static void game_over(int win) { clear(); @@ -818,12 +858,16 @@ struct blip *cur; AST_LIST_TRAVERSE(&blips, cur, entry) { - if (cur->type != BLIP_ALIEN) + if (cur->type != BLIP_ALIEN && cur->type != BLIP_UFO) continue; if (cur->x == shot->x && cur->y == shot->y) { + if (cur->type == BLIP_UFO) { + score += 80; + } score += 20; remove_blip(shot); remove_blip(cur); + respawn += 1; if (!num_aliens) { if(alien_sleeptime < 101) { game_over(1); @@ -898,7 +942,7 @@ break; } if (!(jiffies % 25)) { - if (move_aliens() || move_bombs()) { + if (move_aliens() || move_bombs() || ufo_action()) { alien_sleeptime = 1; game_over(0); break;