[svn-commits] jrose: trunk r956 - /trunk/menuselect_curses.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Nov 7 10:45:04 CST 2011
Author: jrose
Date: Mon Nov 7 10:44:58 2011
New Revision: 956
URL: http://svnview.digium.com/svn/menuselect?view=rev&rev=956
Log:
Adds a mothership enemy to Asterisk menuselect easteregg.
Mothership flies across the top of the screen after a certain number of alien kills.
It's a bonus target.
(closes issue ASTERISK-18801)
Reported by: John Gould
Patches:
space2.patch uploaded by John Gould (license 6319)
Review: https://reviewboard.asterisk.org/r/1555/
Modified:
trunk/menuselect_curses.c
Modified: trunk/menuselect_curses.c
URL: http://svnview.digium.com/svn/menuselect/trunk/menuselect_curses.c?view=diff&rev=956&r1=955&r2=956
==============================================================================
--- trunk/menuselect_curses.c (original)
+++ trunk/menuselect_curses.c Mon Nov 7 10:44:58 2011
@@ -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;
}
@@ -792,7 +797,40 @@
free(blip);
- return 0;
+ 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)
@@ -816,14 +854,18 @@
static int check_shot(struct blip *shot)
{
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 +940,7 @@
break;
}
if (!(jiffies % 25)) {
- if (move_aliens() || move_bombs()) {
+ if (move_aliens() || move_bombs() || ufo_action()) {
alien_sleeptime = 1;
game_over(0);
break;
More information about the svn-commits
mailing list