From 8b068f304d0d2f16a1323a139b5f72c2009c443e Mon Sep 17 00:00:00 2001 From: limb Date: Fri, 5 Jun 2009 17:33:26 +0000 Subject: [PATCH] Added lander-seeking missle powerup. git-svn-id: svn+ssh://svn/var/repos/curfender@825 bc5cbbab-a4ec-0310-bb52-ff3d296db539 --- CHANGELOG | 1 + draw.cpp | 13 +++++++++--- init.cpp | 14 +++++++++++++ init.h | 1 + layout.txt | 2 +- main.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- motion.cpp | 15 ++++++++++++++ motion.h | 1 + powerup.cpp | 7 +++++-- 9 files changed, 116 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2e835de..9ba70be 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +Added missle powerup, searcheds out landers attacking pods. Limited number of lives and smartbombs. Boss difficulty scales upward. Merged saucer boss into unified boss system. diff --git a/draw.cpp b/draw.cpp index c51f6c9..e8a4080 100644 --- a/draw.cpp +++ b/draw.cpp @@ -56,7 +56,7 @@ int draw_object(game_object object, int drawlocation){ void draw_board(){ - extern int score, lives, level, shieldsleft; + extern int score, lives, level, shieldsleft, missile; // mvprintw(row,col,string,vars) //top @@ -83,10 +83,17 @@ void draw_board(){ //Lives mvprintw(20,1,"Lv:"); int count = lives; - for(int x=4;count>0;x=x+3){ - mvprintw(20,x,"<=>"); + for(int x=4;count>0;x=x+2){ + mvprintw(20,x,"<>"); count--; }; + //Missles + count = missile; + for(int x=13;count>0;x=x+1){ + mvprintw(20,x,"M"); + count--; + }; + //Level mvprintw(22,1,"Lvl:%3d", level); mvprintw(22,9,"S:%3d", shieldsleft); diff --git a/init.cpp b/init.cpp index dd2e781..927bfac 100644 --- a/init.cpp +++ b/init.cpp @@ -74,3 +74,17 @@ game_object player_init(game_object player){ return player; } + +game_object missile_init(game_object missile, game_object player, game_object lander){ + missile.active=1; + missile.x = player.x; + missile.y = player.y; + if((620-missile.y+lander.y)<(missile.y-lander.y)){ + missile.direction = 4; + } else { + missile.direction = 6; + }; + missile.speed = 4; + + return missile; +} diff --git a/init.h b/init.h index 4873021..c11ef63 100644 --- a/init.h +++ b/init.h @@ -3,3 +3,4 @@ game_object lander_init(game_object); game_object crawler_init(game_object); game_object boss_init(game_object, int); game_object player_init(game_object); +game_object missile_init(game_object, game_object, game_object); diff --git a/layout.txt b/layout.txt index 8ee2f87..fafdb54 100644 --- a/layout.txt +++ b/layout.txt @@ -18,7 +18,7 @@ 8 ^ <_==> - - - 9 /|\ x + x + /=\ 0-------|-------------------|--------------------|--------------------|--------- -1Lv:<=><=><=><=>| / \ | +1Lv:<><><><> MMM| / \ | 2 O:X I:X BBBB | | 3 Lvl:XXX S:XXX | | 4 Score:XXXXXX | \ / | diff --git a/main.cpp b/main.cpp index 83cd598..b6d8c86 100644 --- a/main.cpp +++ b/main.cpp @@ -48,6 +48,7 @@ const int bulletmax = 10; const int landershotmax = 10; const int landermax = 4; const int crawlermax = 6; +const int missilemax = 3; const float version = 1.0; int score; @@ -60,6 +61,7 @@ int pause_game = 0; int shieldsleft = 400; int tripshot = 0; int laser = 0; +int missile = 0; int sound = 1; int main(int argc, char *argv[]){ @@ -417,6 +419,21 @@ int main(int argc, char *argv[]){ strcpy (boomstuff.line0, "\\"); strcpy (boomstuff.line1, "/"); + //missiles + struct game_object missiles[missilemax] = { + { 50, 0, 0, 0, 5, 0, 0, 0, 0 }, + { 51, 0, 0, 0, 5, 0, 0, 0, 0 }, + { 52, 0, 0, 0, 5, 0, 0, 0, 0 } + }; + + for(int missileloop = 0; missileloop=landers[landerloop].y){ landers[landerloop].direction = 4; alertleft = 20;}; landers[landerloop].phase = 1; + //launch missile if we have one + if(missile>=1){ + for(int missileloop = 0; missileloopobject.x){ object.x++; }; + }; + if(lander.y>=object.y){ + if(lander.xobject.x){ object.x++; }; + }; + + return object; +} + game_object process_motion(game_object object, game_object player){ extern int pod_in, drawlocation; diff --git a/motion.h b/motion.h index e58935a..3e573dc 100644 --- a/motion.h +++ b/motion.h @@ -1,5 +1,6 @@ game_object boss_motion(game_object, game_object); game_object crazy_motion(game_object, game_object); +game_object missile_motion(game_object, game_object); game_object process_motion(game_object, game_object); game_object process_direction(game_object, int); game_object pod_chase(game_object, game_object); diff --git a/powerup.cpp b/powerup.cpp index d65e9ce..1ee6f92 100644 --- a/powerup.cpp +++ b/powerup.cpp @@ -18,9 +18,12 @@ game_object powerup_init(game_object powerup, game_object object){ }; powerup.speed = 1; - int fodder = rand()%1000; + int fodder = rand()%1200; - if(fodder>=800){ + if(fodder>=1000){ + strcpy (powerup.line0, "M"); + }; + if(fodder>=800&&fodder<1000){ strcpy (powerup.line0, "T"); }; if(fodder>=600&&fodder<800){ -- 2.9.0