From 3eee64398bdfde684199873793febadbd6fa4a19 Mon Sep 17 00:00:00 2001 From: "chirs241097@gmail.com" Date: Fri, 9 May 2014 12:15:44 +0000 Subject: Fix a bug in the credit scene. Now the pause menu shouldn't be broken now...(It's so hard to reproduce that I have to assume it *has* been fixed.(IT STILL HAPPENS!!!) Close the "infinity CLR" "bug". (Huge) Code cleanup, mainly removing duplicate code. Allocate bullets dynamically. The array is freed every time a new game is started. Add a signal handler, print back trace on error(currently only available for linux...). --- ChangeLog | 35 +++- Readme | 69 ++----- VERSION | 2 +- build | 6 + effects.h | 20 +- global.h | 54 +++++- hgeft.cpp | 2 +- include/hge.h | 4 +- main.cpp | 564 +++++++++++++++++++++++++-------------------------------- menus.h | 51 +----- towernbullet.h | 90 +-------- 11 files changed, 374 insertions(+), 523 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8bba62..0365d96 100755 --- a/ChangeLog +++ b/ChangeLog @@ -2,12 +2,39 @@ Next version: ? Todo's: -Complete the game system. -Menu rewrite... -Random segmentation fault in "Hyper-threading".(seen only once, -can not reproduce now...) +Add multpo's. +Bug fixes. +Tests. +Wishlist? + +Known bugs: +Return to game in pause menu are sometimes broken. (It seldom happens, and is +very hard to catch!) +One part of Level 3 fails randomly (really randomly?). +~~infinity CLR~~(debug purpose. I can't pass those levels with out +this) + +Wishlist: +Make more data stored in score.cfg. +Replace some boring levels. +Built-in help pages. +In-game music bring back. +~~Now Playing(Music Room)~~ +~~BLR script virtual machine~~(long long-term! probably the core +of next BLR.) Pre-Released versions: +0.9.1-1 (r90) +Fix a bug in the credit scene. +Now the pause menu shouldn't be broken now...(It's so hard to reproduce +that I have to assume it *has* been fixed.(IT STILL HAPPENS!!!) +Close the "infinity CLR" "bug". +(Huge) Code cleanup, mainly removing duplicate code. +Allocate bullets dynamically. The array is freed every time a new game +is started. +Add a signal handler, print back trace on error(currently only available +for linux...). + 0.9.1-1 (r89) Fix a critical bug in Score_Initailize. Modify level pinball. diff --git a/Readme b/Readme index 93c0fb4..2e4c8cc 100644 --- a/Readme +++ b/Readme @@ -70,7 +70,7 @@ Generic Information My own comment on this game... A "game" filled with the smell of mysterious science and imagination(3:2 approximately). (I worked on it for almost 9 months, after all.) -Others comments... +Others' comments... -PIECE OF SHIT!!! -The author must be suffering from serious mental problems.(I agree...) -(literally translated from Chinese) Revenge on society... @@ -92,6 +92,10 @@ MORE Recommends... -(Additionally for the last one)Ability to read non human-readable code. -Achromatopsia(<-strikethrough) +How to install&run it... +Just extract all files in the archive somewhere, then start the only executable +file in it. + If, suddenly, you can't run it one day... Remove blr.cfg (remember to backup your score.cfg first!) then restart the game. It will ask you for initial settings. @@ -191,58 +195,23 @@ Now it has reached a position that I've never expected... Brief History ------------------------------------------------------------------------------------ The file ChangeLog contains the full history of this project. -Here's a list of milestones. - -0.9.1-0_PR (r85) -Menu rewrite(still in progress). - -0.9.0-1_PR (b79/r79) -Finish assessment mode. -Extend laser class. -Several modify and fix to HGE. +Here's a list of released-to-public versions. -0.8.1-1_PR (b77) -Completing all levels for Classic Mode and Free Play Mode. -Switch to mingw-w64 for building Windows version. -Prepare for assessment mode. +0.9.1-1_PR (r86) +Current public release. Comes with all levels that will appear in the final release. +Done menu rewrite. +Make multiplier system functional. 0.7.3-0_PR (b73) -Completing level 7. -Lots and lots of fixes. -Laser revesion is now r5 and work perfectly. - -0.6.2-2_PR (b52) -Level 6 is complete. -Supporting new music interfaces and added in-game music. - -0.5.3-2_PR (b43) -Finishing level 5. -New clear range trigger method and fixes to clear range. +Comes with all seven "normal" levels. +Many bug fixes, making the Windows port (almost) stable. +Huge code changes happened here. 0.4.4-0_PRG (b37a) -Regression version from 0.5.2-0_PR (b37). -Released to public. Including the complete level 4, and some levels of Level 5. -Fixed two minor problems. - -0.3.2-0_PR (b27) -Completing level 3. -Avoid hidden bullets. - -0.2.9-2_PR (b22) -Completing level 2. -0.2.9-1_PR (b21) is released to public. - -0.1.7-2_PR (b16) -Level 1 is finished. - -TB130907 (b10) -Laser implementation rev 2. - -TB130827 (b8) -Initial laser implementation. - -TB130620~TB130818 (b1~b7) -New towers and new levels. +Comes with four levels and some parts of the fifth level. +Contains several bug fixes. -TB130610 (b0) -Creation of the Testbed version. +0.2.9-1_PR (b21) +First public prerelease version. +Comes with two levels. +Introduced multiplier system, not functional yet. \ No newline at end of file diff --git a/VERSION b/VERSION index 4235450..8cc5770 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.1-1 (r89) \ No newline at end of file +0.9.1-1 (r90) \ No newline at end of file diff --git a/build b/build index 12c7578..dab46d9 100755 --- a/build +++ b/build @@ -1,5 +1,6 @@ #!/bin/bash cd hge +############################################################################# cd CxImage echo Compiling CxImage... g++ -c *.cpp -D_LINUX @@ -7,6 +8,7 @@ ar rcs libCxImage.a *.o rm *.o cd .. mv ./CxImage/libCxImage.a libCxImage.a +############################################################################# cd ZLIB echo Compiling zlib... gcc -c *.c @@ -14,12 +16,14 @@ ar rcs libz.a *.o rm *.o cd .. mv ./ZLIB/libz.a libz.a +############################################################################# echo Compiling libhge... g++ -c *.cpp -I/usr/include/SDL/ -I../include ar rcs libhge.a *.o rm *.o cd .. mv ./hge/*.a ./ +############################################################################# cd hgehelp echo Compiling libhgehelp... g++ -c *.cpp -I../include @@ -27,10 +31,12 @@ ar rcs libhgehelp.a *.o rm *.o cd .. mv ./hgehelp/libhgehelp.a libhgehelp.a +############################################################################# echo Compiling the main executable... g++ *.cpp -I/usr/include/freetype2 -I./include \ -lSDL -lvorbis -lvorbisfile -lopenal -ljpeg -lpng -lfreetype \ -Wl,libhgehelp.a,libhge.a,libCxImage.a,libz.a -o BulletLabRemixII +############################################################################# rm *.a strip BulletLabRemixII cd .. \ No newline at end of file diff --git a/effects.h b/effects.h index 0e40824..d71a445 100644 --- a/effects.h +++ b/effects.h @@ -9,15 +9,7 @@ void SCEffect_Attatch(vector2d Target=vector2d(-100,-100)) if(Target.x<-50&&Target.y<-50)Target=playerpos; for (int ii=1;ii<=cnt;++ii) { - int i; - if (bulcnt==0) - bulcnt=i=1; - else - { - for (i=1;i<=bulcnt;++i) - if (!bullet[i].exist)break; - if (i>bulcnt)bulcnt=i; - } + int i=AllocBullet(); bullet[i].exist=true; bullet[i].bullettype=254; bullet[i].bulletpos.x=Target.x+3; @@ -83,15 +75,7 @@ void BulletEffect_Process(int n) } int BulletEffect_Death(Bullet a,DWORD color) { - int i; - if (bulcnt==0) - bulcnt=i=1; - else - { - for (i=1;i<=bulcnt;++i) - if (!bullet[i].exist)break; - if (i>bulcnt)bulcnt=i; - } + int i=AllocBullet(); bullet[i].exist=true; bullet[i].bullettype=253; bullet[i].bulletpos.x=a.bulletpos.x; diff --git a/global.h b/global.h index 68dc285..5776e5c 100644 --- a/global.h +++ b/global.h @@ -5,6 +5,7 @@ #include #define MaxRes 80 #define Resd 20.0f +#define MaxBulCnt 20000 HGE *hge=0; HEFFECT snd,menuin,menuout; hgeQuad quad; @@ -81,9 +82,9 @@ hgeSprite *bulletspr[COLOR_COUNT],*towerspr[COLOR_COUNT]; const double zero=1e-5; vector2d playerpos; bool playerLockX,playerLockY; -bool DisableAllTower=false; -bool DisablePlayer=false; -bool LOWFPS=false,diffkey=false; +bool DisableAllTower; +bool DisablePlayer; +bool LOWFPS,diffkey,showalloc; int VidMode=-1; inline double GetDist(vector2d,vector2d); class Bullet @@ -120,7 +121,7 @@ public: bulletdir.y=sin(rad); dist=1; } -}bullet[20000]; +}*bullet=NULL; /*Something about bullets: //bullettype: //1: player dir-based green bullet @@ -274,7 +275,7 @@ double clrrange,clrrad,clrmaxrange,clrind,assetime; hgeSprite *clrcircle; bool Dis8ref,t8special; int frameskips=0,stepskips=0; -bool IfCallLevel,IfShowTip,FadeTip,PlayerSplit; +bool IfCallLevel,IfShowTip,FadeTip,PlayerSplit,charge; RandomEngine re; hgeFont *TipFont,*MenuFont; char lasttip[200]; @@ -335,7 +336,7 @@ static const char* archive[]={ }; #endif //static const char* GLOBAL_H_FN="global.h"; -static const char* BLRVERSION="0.9.1-1 (r89)"; +static const char* BLRVERSION="0.9.1-1 (r90)"; static const char *months="JanFebMarAprMayJunJulAugSepOctNovDec"; char *parseDate(const char *date) { @@ -355,9 +356,8 @@ void Throw(char *Filename,char *Info) } void Error(const char *EC,bool hgecreated=false) { -#ifndef WIN32 - fprintf(stderr,"%s\n",EC); -#else + hge->System_Log("%s\n",EC); +#ifdef WIN32 MessageBox(NULL,EC,"Error!",MB_ICONERROR); #endif if (hgecreated) @@ -423,6 +423,42 @@ void ShowTip(const char *tip) } } void All2pnt();//forward that... + +int AllocBullet() +{ + int i; + if (bulcnt==0) + { + bulcnt=i=1; + bullet=(Bullet*)malloc(sizeof(Bullet)*(bulcnt+1)); + } + else + { + for (i=1;i<=bulcnt;++i) + if (!bullet[i].exist)break; + if (i>bulcnt) + { + bulcnt=i; + Bullet *nblt=(Bullet*)realloc(bullet,sizeof(Bullet)*(bulcnt+1)); + if(!nblt)Error("Error allocating bullets!",1); + bullet=nblt; + } + } + return i; +} +void SigHandler(int pm) +{ + hge->System_Log("Oops, the application ate a piece of DE AD BE EF!"); +#if defined(__GNUC__) && !defined(MINGW_BUILD) + void *strs[64];unsigned cnt; + char **str;cnt=backtrace(strs,64); + str=backtrace_symbols(strs,cnt); + for(unsigned i=0;iSystem_Log("%s",str[i]); +#endif + hge->System_Shutdown(); + exit(1); +} void ClearAll(bool cbullet=true) { DisableAllTower=true; diff --git a/hgeft.cpp b/hgeft.cpp index a5b233a..ec4e7bc 100644 --- a/hgeft.cpp +++ b/hgeft.cpp @@ -1,7 +1,7 @@ // Freetype2 ext4hge implementations -*- C++ -*- #include "hgeft.h" static const char* HGEFT_SRC_FN="hgeft.cpp"; -void hgeTTChar::Free(){if(quad.tex)hge->Texture_Free(quad.tex),quad.tex=0;} +void hgeTTChar::Free(){if(quad.tex)hge->Texture_Free(quad.tex),quad.tex=NULL;} bool hgeTTChar::SetChar(wchar_t ch,FT_Face ttfface) { FT_GlyphSlot slot=ttfface->glyph; diff --git a/include/hge.h b/include/hge.h index ef4597e..ce5badd 100644 --- a/include/hge.h +++ b/include/hge.h @@ -10,11 +10,11 @@ #ifndef HGE_H #define HGE_H -#include "unix_compat.h" - #ifdef WIN32 #include #include +#else +#include "unix_compat.h" #endif #define HGE_VERSION 0x181 diff --git a/main.cpp b/main.cpp index c598192..d8cdd4b 100644 --- a/main.cpp +++ b/main.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #ifdef WIN32 #include #include @@ -50,6 +51,9 @@ #include #include #endif +#if defined(__GNUC__) && !defined(MINGW_BUILD) +#include +#endif #include "libcgh.h" #include "hgeft.h" #include "global.h" @@ -72,7 +76,7 @@ void Expand(const char *source,const char *dist) void firststartup() { if (MessageBoxA(NULL,"It seems that you are running BLR for the First time!\nLet's do some \ -basic settings first!\n\nUse vsync??","First Start Up",0x00000024)==6) +basic settings first!\n\nUse vsync?","First Start Up",0x00000024)==6) fpslvl=2; else fpslvl=0; @@ -86,13 +90,12 @@ basic settings first!\n\nUse vsync??","First Start Up",0x00000024)==6) Options_Writeback(); Score_Initailize(); } -#endif -#ifndef WIN32 +#else void firststartup() { fpslvl=2;tfs=0;VidMode=0;diffkey=false; plrspd=3;plrslospd=3;clrbns=clrmode=0; - hge->System_Log("%s: Finishing first start up configuraion...",MAIN_SRC_FN); + hge->System_Log("%s: Finishing (stubbed) first start up configuraion...",MAIN_SRC_FN); Options_Writeback(); Score_Initailize(); } @@ -135,7 +138,7 @@ void Player_Clear_Rotate() double dis=GetDist(bullet[i].bulletpos,playerpos); double rad=atan2l(bullet[i].bulletpos.y-playerpos.y,bullet[i].bulletpos.x-playerpos.x); hge->Gfx_RenderLine(playerpos.x+8,playerpos.y+8,playerpos.x+cos(clrrad)*clrmaxrange,playerpos.y+sin(clrrad)*clrmaxrange); - while (rad<0)rad+=2*pi; + rad=normalizerad(rad); if (bullet[i].bullettype!=255&&dis<=clrmaxrange&&bullet[i].exist&&!bullet[i].inv&&rad>normalizerad(clrrad)-pi/12&&radSetHotSpot(96.5f,96.5f); clrcircle->SetBlendMode(BLEND_ALPHAADD); } - if(clrmode)clrcircle->SetColor(0x30008080);else clrcircle->SetColor(0x30800000);; + if(clrmode)clrcircle->SetColor(0x30008080);else clrcircle->SetColor(0x30800000); if (playerLockX) { Lock.Setdata(0,vector2d(playerpos.x-1,0),vector2d(playerpos.x-1,600),0xC0FFFFFF); @@ -196,90 +199,42 @@ void ProcessPlayer() playerspr->RenderEx(playerpos.x+splitData[i].x+8.4,playerpos.y+splitData[i].y+8.4,playerrot,0.7,0); } if (DisablePlayer)return; - if (!LOWFPS) - playerrot+=0.00174533; - else - playerrot+=0.00174533*17; + playerrot+=0.00174533*17; double realspd; if (hge->Input_GetKeyState(HGEK_SHIFT)) realspd=playerslospeed*(1000.0f/hge->Timer_GetFPS()); else realspd=playerspeed*(1000.0f/hge->Timer_GetFPS()); if (hge->Input_GetKeyState(HGEK_LEFT)&&!playerLockX) - { - if (playerpos.x>10) - playerpos.x-=realspd; - } + if (playerpos.x>10)playerpos.x-=realspd; if (hge->Input_GetKeyState(HGEK_RIGHT)&&!playerLockX) - { - if ((playerpos.x<770&&!PlayerSplit)||(playerpos.x<370&&PlayerSplit)) - playerpos.x+=realspd; - } + if ((playerpos.x<770&&!PlayerSplit)||(playerpos.x<370&&PlayerSplit))playerpos.x+=realspd; if (hge->Input_GetKeyState(HGEK_UP)&&!playerLockY) - { - if (playerpos.y>10) - playerpos.y-=realspd; - } + if (playerpos.y>10)playerpos.y-=realspd; if (hge->Input_GetKeyState(HGEK_DOWN)&&!playerLockY) - { - if ((playerpos.y<570&&!PlayerSplit)||(playerpos.y<270&&PlayerSplit)) - playerpos.y+=realspd; - } + if ((playerpos.y<570&&!PlayerSplit)||(playerpos.y<270&&PlayerSplit))playerpos.y+=realspd; if(mode!=2) { if (!clrmode) { - if (hge->Input_GetKeyStateEx(HGEK_Z)==HGEKST_HIT&&clrrange==0&&!diffkey) - { - clrmaxrange=0;clrind=0; - } - if (hge->Input_GetKeyStateEx(HGEK_X)==HGEKST_HIT&&clrrange==0&&diffkey) - { - clrmaxrange=0;clrind=0; - } - if (hge->Input_GetKeyStateEx(HGEK_Z)==HGEKST_KEEP&&clrrange==0&&!diffkey) + if (hge->Input_GetKeyStateEx(diffkey?HGEK_X:HGEK_Z)==HGEKST_HIT&&clrmaxrange==0) + {clrind=0;charge=1;} + if (hge->Input_GetKeyStateEx(diffkey?HGEK_X:HGEK_Z)==HGEKST_KEEP&&charge) { if (clrmaxrange<=400) - { - if (LOWFPS)clrmaxrange+=1.6;else clrmaxrange+=0.1; - } + {if (LOWFPS)clrmaxrange+=1.6;else clrmaxrange+=0.1;} if (!LOWFPS)clrind+=0.001*pi;else clrind+=0.016*pi; clrcircle->RenderEx(playerpos.x+7.2,playerpos.y+7.2,clrind,2*clrmaxrange/193.0f); if(PlayerSplit)for(int i=1;i<4;++i) clrcircle->RenderEx(playerpos.x+splitData[i].x+7.2,playerpos.y+splitData[i].y+7.2,clrind,2*clrmaxrange/193.0f); } - if (hge->Input_GetKeyStateEx(HGEK_X)==HGEKST_KEEP&&clrrange==0&&diffkey) - { - if (clrmaxrange<=400) - { - if (LOWFPS)clrmaxrange+=1.6;else clrmaxrange+=0.1; - } - if (!LOWFPS)clrind+=0.001*pi;else clrind+=0.016*pi; - clrcircle->RenderEx(playerpos.x+7.2,playerpos.y+7.2,clrind,2*clrmaxrange/193.0f); - if(PlayerSplit)for(int i=1;i<4;++i) - clrcircle->RenderEx(playerpos.x+splitData[i].x+7.2,playerpos.y+splitData[i].y+7.2,clrind,2*clrmaxrange/193.0f); - } - if (hge->Input_GetKeyStateEx(HGEK_Z)==HGEKST_RELEASE&&clrrange==0&&!diffkey) + if (hge->Input_GetKeyStateEx(diffkey?HGEK_X:HGEK_Z)==HGEKST_RELEASE&&charge) { + charge=0; if (clrmaxrange<=50) - { - if (clrtime+clrbns){--clrtime;clrmaxrange=350;Player_Clear_Expand();++clrusg;} - } + {if (clrtime+clrbns>0){--clrtime;clrmaxrange=350;Player_Clear_Expand();++clrusg;}} else - { - Player_Clear_Expand();++clrusg; - } - } - if (hge->Input_GetKeyStateEx(HGEK_X)==HGEKST_RELEASE&&clrrange==0&&diffkey) - { - if (clrmaxrange<=50) - { - if (clrtime+clrbns){--clrtime;clrmaxrange=350;Player_Clear_Expand();++clrusg;} - } - else - { - Player_Clear_Expand();++clrusg; - } + {Player_Clear_Expand();++clrusg;} } if (clrrange!=0) { @@ -289,47 +244,31 @@ void ProcessPlayer() clrcircle->RenderEx(playerpos.x+splitData[i].x+7.2,playerpos.y+splitData[i].y+7.2,clrind,2*(clrmaxrange-clrrange)/193.0f); clrind+=(LOWFPS?0.016*pi:0.001*pi); } - if (clrrange>=clrmaxrange)clrrange=0; + if (clrrange>=clrmaxrange)clrrange=clrmaxrange=0; } else { - if (hge->Input_GetKeyStateEx(HGEK_Z)==HGEKST_HIT&&clrrad-pi/2<1e-7&&!diffkey) - { - clrmaxrange=0;clrind=0; - } - if (hge->Input_GetKeyStateEx(HGEK_X)==HGEKST_HIT&&clrrad-pi/2<1e-7&&diffkey) - { - clrmaxrange=0;clrind=0; - } - if (hge->Input_GetKeyStateEx(HGEK_Z)==HGEKST_KEEP&&clrrange==0&&!diffkey) + if (hge->Input_GetKeyStateEx(diffkey?HGEK_X:HGEK_Z)==HGEKST_HIT&&clrmaxrange==0) + {clrind=0;charge=1;} + if (hge->Input_GetKeyStateEx(diffkey?HGEK_X:HGEK_Z)==HGEKST_KEEP&&charge) { if (clrmaxrange<=400) - { - if (LOWFPS)clrmaxrange+=1.6;else clrmaxrange+=0.1; - } + {if (LOWFPS)clrmaxrange+=1.6;else clrmaxrange+=0.1;} if (!LOWFPS)clrind+=0.001*pi;else clrind+=0.016*pi; clrcircle->RenderEx(playerpos.x+7.2,playerpos.y+7.2,clrind,2*clrmaxrange/193.0f); if(PlayerSplit)for(int i=1;i<4;++i) clrcircle->RenderEx(playerpos.x+splitData[i].x+7.2,playerpos.y+splitData[i].y+7.2,clrind,2*clrmaxrange/193.0f); } - if (hge->Input_GetKeyStateEx(HGEK_X)==HGEKST_KEEP&&clrrange==0&&diffkey) + if (hge->Input_GetKeyStateEx(diffkey?HGEK_X:HGEK_Z)==HGEKST_RELEASE&&charge) { - if (clrmaxrange<=400) + charge=0; + if (clrmaxrange<=50) { - if (LOWFPS)clrmaxrange+=1.6;else clrmaxrange+=0.1; - } - if (!LOWFPS)clrind+=0.001*pi;else clrind+=0.016*pi; - clrcircle->RenderEx(playerpos.x+7.2,playerpos.y+7.2,clrind,2*clrmaxrange/193.0f); - if(PlayerSplit)for(int i=1;i<4;++i) - clrcircle->RenderEx(playerpos.x+splitData[i].x+7.2,playerpos.y+splitData[i].y+7.2,clrind,2*clrmaxrange/193.0f); - } - if (hge->Input_GetKeyStateEx(HGEK_Z)==HGEKST_RELEASE&&clrrad-pi/2<1e-7&&clrtime+clrbns&&!diffkey) - { - Player_Clear_Rotate();if(clrmaxrange<50)--clrtime,clrmaxrange=350;++clrusg; - } - if (hge->Input_GetKeyStateEx(HGEK_X)==HGEKST_RELEASE&&clrrad-pi/2<1e-7&&clrtime+clrbns&&diffkey) - { - Player_Clear_Rotate();if(clrmaxrange<50)--clrtime,clrmaxrange=350;++clrusg; + if(clrtime+clrbns>0) + { + Player_Clear_Rotate();if(clrmaxrange<50)--clrtime,clrmaxrange=350;++clrusg; + } + }else{Player_Clear_Rotate();++clrusg;} } if (clrrad-pi/2>1e-7) { @@ -339,19 +278,16 @@ void ProcessPlayer() clrcircle->RenderEx(playerpos.x+splitData[i].x+7.2,playerpos.y+splitData[i].y+7.2,clrind,2*clrmaxrange/193.0f*(5*pi/2.0f-clrrad)/(2*pi)); clrind+=(LOWFPS?0.016*pi:0.001*pi); } - if (5*pi/2-clrrad<1e-7)clrrad=pi/2; + if (5*pi/2-clrrad<1e-7)clrrad=pi/2,clrmaxrange=0; } } } void RefreshScore() { Mult_FrameFunc(); - if (DisablePlayer)return; + if(DisablePlayer)return; mult+=0.01f*dsmc; - if (LOWFPS) - score+=16*mult; - else - score+=mult; + score+=16*mult; if(scminus){if(mult/2>0.1)mult/=2;else mult=0.1;} score+=100*shots*mult; score-=scminus*mult; @@ -362,230 +298,230 @@ void RefreshScore() void CallLevels() { //Use this to call level procedures. - if ((mode==1)&&coll!=0){deathMenu.Init(-200);return;} - if ((mode==2)&&coll!=0){assetime=0;++part;coll=0;IfCallLevel=IfShowTip=true;return;} - if (!IfCallLevel) return; - if (mode==2)assetime+=hge->Timer_GetDelta(); + if((mode==1)&&coll!=0){deathMenu.Init(-200);return;} + if((mode==2)&&coll!=0){assetime=0;++part;coll=0;IfCallLevel=IfShowTip=true;return;} + if(!IfCallLevel) return; + if(mode==2)assetime+=hge->Timer_GetDelta(); //Check Complete here - if (level==1&&part==0)Level1Part0(); - if (level==1&&part==1)Level1Part1(); - if (level==1&&part==2)Level1Part2(); - if (level==1&&part==3)Level1Part3(); - if (level==1&&part==4)Level1Part4(); - if (level==2&&part==0)Level2Part0(); - if (level==2&&part==1)Level2Part1(); - if (level==2&&part==2)Level2Part2(); - if (level==2&&part==3)Level2Part3(); - if (level==2&&part==4)Level2Part4(); - if (level==2&&part==5)Level2Part5(); - if (level==2&&part==6)Level2Part6(); - if (level==2&&part==7)Level2Part7(); - if (level==2&&part==8)Level2Part8(); - if (level==2&&part==9)Level2Part9(); - if (level==3&&part==0)Level3Part0(); - if (level==3&&part==1)Level3Part1(); - if (level==3&&part==2)Level3Part2(); - if (level==3&&part==3)Level3Part3(); - if (level==3&&part==4)Level3Part4(); - if (level==3&&part==5)Level3Part5(); - if (level==3&&part==6)Level3Part6(); - if (level==4&&part==0)Level4Part0(); - if (level==4&&part==1)Level4Part1(); - if (level==4&&part==2)Level4Part2(); - if (level==4&&part==3)Level4Part3(); - if (level==4&&part==4)Level4Part4(); - if (level==4&&part==5)Level4Part5(); - if (level==4&&part==6)Level4Part6(); - if (level==4&&part==7)Level4Part7(); - if (level==4&&part==8)Level4Part8(); - if (level==4&&part==9)Level4Part9(); - if (level==4&&part==10)Level4Part10(); - if (level==4&&part==11)Level4Part11(); - if (level==4&&part==12)Level4Part12(); - if (level==4&&part==13)Level4Part13(); - if (level==4&&part==14)Level4Part14(); - if (level==4&&part==15)Level4Part15(); - if (level==4&&part==16)Level4Part16(); - if (level==4&&part==17)Level4Part17(); - if (level==4&&part==18)Level4Part18(); - if (level==4&&part==19)Level4Part19(); - if (level==4&&part==20)Level4Part20(); - if (level==4&&part==21)Level4Part21(); - if (level==4&&part==22)Level4Part22(); - if (level==4&&part==23)Level4Part23(); - if (level==4&&part==24)Level4Part24(); - if (level==4&&part==25)Level4Part25(); - if (level==5&&part==0)Level5Part0(); - if (level==5&&part==1)Level5Part1(); - if (level==5&&part==2)Level5Part2(); - if (level==5&&part==3)Level5Part3(); - if (level==5&&part==4)Level5Part4(); - if (level==5&&part==5)Level5Part5(); - if (level==5&&part==6)Level5Part6(); - if (level==5&&part==7)Level5Part7(); - if (level==5&&part==8)Level5Part8(); - if (level==5&&part==9)Level5Part9(); - if (level==5&&part==10)Level5Part10(); - if (level==5&&part==11)Level5Part11(); - if (level==5&&part==12)Level5Part12(); - if (level==5&&part==13)Level5Part13(); - if (level==5&&part==14)Level5Part14(); - if (level==5&&part==15)Level5Part15(); - if (level==5&&part==16)Level5Part16(); - if (level==5&&part==17)Level5Part17(); - if (level==5&&part==18)Level5Part18(); - if (level==5&&part==19)Level5Part19(); - if (level==5&&part==20)Level5Part20(); - if (level==5&&part==21)Level5Part21(); - if (level==5&&part==22)Level5Part22(); - if (level==6&&part==0)Level6Part0(); - if (level==6&&part==1)Level6Part1(); - if (level==6&&part==2)Level6Part2(); - if (level==6&&part==3)Level6Part3(); - if (level==6&&part==4)Level6Part4(); - if (level==6&&part==5)Level6Part5(); - if (level==6&&part==6)Level6Part6(); - if (level==6&&part==7)Level6Part7(); - if (level==6&&part==8)Level6Part8(); - if (level==6&&part==9)Level6Part9(); - if (level==6&&part==10)Level6Part10(); - if (level==6&&part==11)Level6Part11(); - if (level==6&&part==12)Level6Part12(); - if (level==6&&part==13)Level6Part13(); - if (level==6&&part==14)Level6Part14(); - if (level==6&&part==15)Level6Part15(); - if (level==6&&part==16)Level6Part16(); - if (level==6&&part==17)Level6Part17(); - if (level==6&&part==18)Level6Part18(); - if (level==6&&part==19)Level6Part19(); - if (level==6&&part==20)Level6Part20(); - if (level==6&&part==21)Level6Part21(); - if (level==6&&part==22)Level6Part22(); - if (level==6&&part==23)Level6Part23(); - if (level==6&&part==24)Level6Part24(); - if (level==6&&part==25)Level6Part25(); - if (level==6&&part==26)Level6Part26(); - if (level==6&&part==27)Level6Part27(); - if (level==6&&part==28)Level6Part28(); - if (level==6&&part==29)Level6Part29(); - if (level==6&&part==30)Level6Part30(); - if (level==6&&part==31)Level6Part999999999(); - if (level==7&&part==0)Level7Part0(); - if (level==7&&part==1)Level7Part1(); - if (level==7&&part==2)Level7Part2(); - if (level==7&&part==3)Level7Part3(); - if (level==7&&part==4)Level7Part4(); - if (level==7&&part==5)Level7Part5(); - if (level==7&&part==6)Level7Part6(); - if (level==7&&part==7)Level7Part7(); - if (level==7&&part==8)Level7Part8(); - if (level==7&&part==9)Level7Part9(); - if (level==7&&part==10)Level7Part10(); - if (level==7&&part==11)Level7Part11(); - if (level==7&&part==12)Level7Part12(); - if (level==7&&part==13)Level7Part13(); - if (level==7&&part==14)Level7Part14(); - if (level==7&&part==15)Level7Part15(); - if (level==7&&part==16)Level7Part16(); - if (level==7&&part==17)Level7Part17(); - if (level==7&&part==18)Level7Part18(); - if (level==7&&part==19)Level7Part19(); - if (level==7&&part==20)Level7Part20(); - if (level==7&&part==21)Level7Part21(); - if (level==7&&part==22)Level7Part22(); - if (level==7&&part==23)Level7Part23(); - if (level==7&&part==24)Level7Part24(); - if (level==7&&part==25)Level7Part25(); - if (level==7&&part==26)Level7Part26(); - if (level==-1&&part==0)Levelm1Part0(); - if (level==-1&&part==1)Levelm1Part1(); - if (level==-1&&part==2)Levelm1Part2(); - if (level==-1&&part==3)Levelm1Part3(); - if (level==-1&&part==4)Levelm1Part4(); - if (level==-1&&part==5)Levelm1Part5(); - if (level==-1&&part==6)Levelm1Part6(); - if (level==-1&&part==7)Levelm1Part7(); - if (level==-1&&part==8)Levelm1Part8(); - if (level==-1&&part==9)Levelm1Part9(); - if (level==-1&&part==10)Levelm1Part10(); - if (level==-1&&part==11)Levelm1Part11(); - if (level==-1&&part==12)Levelm1Part12(); - if (level==-1&&part==13)Levelm1Part13(); - if (level==-1&&part==14)Levelm1Part14(); - if (level==-1&&part==15)Levelm1Part15(); - if (level==-1&&part==16)Levelm1Part16(); - if (level==-1&&part==17)Levelm1Part17(); - if (level==-1&&part==18)Levelm1Part18(); - if (level==-1&&part==19)Levelm1Part19(); - if (level==-1&&part==20)Levelm1Part20(); - if (level==-1&&part==21)Levelm1Part21(); - if (level==-2&&part==0)Levelm2Part0(); - if (level==-2&&part==1)Levelm2Part1(); - if (level==-2&&part==2)Levelm2Part2(); - if (level==-2&&part==3)Levelm2Part3(); - if (level==-2&&part==4)Levelm2Part4(); - if (level==-2&&part==5)Levelm2Part5(); - if (level==-2&&part==6)Levelm2Part6(); - if (level==-2&&part==7)Levelm2Part7(); - if (level==-2&&part==8)Levelm2Part8(); - if (level==-2&&part==9)Levelm2Part9(); - if (level==-2&&part==10)Levelm2Part10(); - if (level==-2&&part==11)Levelm2Part11(); - if (level==-2&&part==12)Levelm2Part12(); - if (level==-2&&part==13)Levelm2Part13(); - if (level==-2&&part==14)Levelm2Part14(); - if (level==-2&&part==15)Levelm2Part15(); - if (level==-2&&part==16)Levelm2Part16(); - if (level==-2&&part==17)Levelm2Part17(); - if (level==-2&&part==18)Levelm2Part18(); - if (level==-2&&part==19)Levelm2Part19(); - if (level==-2&&part==20)Levelm2Part20(); - if (level==-2&&part==21)Levelm2Part21(); - if (level==-2&&part==22)Levelm2Part22(); - if (level==-2&&part==23)Levelm2Part23(); - if (level==-2&&part==24)Levelm2Part24(); - if (level==-2&&part==25)Levelm2Part25(); - if (level==-2&&part==26)Levelm2Part26(); + if(level==1&&part==0)Level1Part0(); + if(level==1&&part==1)Level1Part1(); + if(level==1&&part==2)Level1Part2(); + if(level==1&&part==3)Level1Part3(); + if(level==1&&part==4)Level1Part4(); + if(level==2&&part==0)Level2Part0(); + if(level==2&&part==1)Level2Part1(); + if(level==2&&part==2)Level2Part2(); + if(level==2&&part==3)Level2Part3(); + if(level==2&&part==4)Level2Part4(); + if(level==2&&part==5)Level2Part5(); + if(level==2&&part==6)Level2Part6(); + if(level==2&&part==7)Level2Part7(); + if(level==2&&part==8)Level2Part8(); + if(level==2&&part==9)Level2Part9(); + if(level==3&&part==0)Level3Part0(); + if(level==3&&part==1)Level3Part1(); + if(level==3&&part==2)Level3Part2(); + if(level==3&&part==3)Level3Part3(); + if(level==3&&part==4)Level3Part4(); + if(level==3&&part==5)Level3Part5(); + if(level==3&&part==6)Level3Part6(); + if(level==4&&part==0)Level4Part0(); + if(level==4&&part==1)Level4Part1(); + if(level==4&&part==2)Level4Part2(); + if(level==4&&part==3)Level4Part3(); + if(level==4&&part==4)Level4Part4(); + if(level==4&&part==5)Level4Part5(); + if(level==4&&part==6)Level4Part6(); + if(level==4&&part==7)Level4Part7(); + if(level==4&&part==8)Level4Part8(); + if(level==4&&part==9)Level4Part9(); + if(level==4&&part==10)Level4Part10(); + if(level==4&&part==11)Level4Part11(); + if(level==4&&part==12)Level4Part12(); + if(level==4&&part==13)Level4Part13(); + if(level==4&&part==14)Level4Part14(); + if(level==4&&part==15)Level4Part15(); + if(level==4&&part==16)Level4Part16(); + if(level==4&&part==17)Level4Part17(); + if(level==4&&part==18)Level4Part18(); + if(level==4&&part==19)Level4Part19(); + if(level==4&&part==20)Level4Part20(); + if(level==4&&part==21)Level4Part21(); + if(level==4&&part==22)Level4Part22(); + if(level==4&&part==23)Level4Part23(); + if(level==4&&part==24)Level4Part24(); + if(level==4&&part==25)Level4Part25(); + if(level==5&&part==0)Level5Part0(); + if(level==5&&part==1)Level5Part1(); + if(level==5&&part==2)Level5Part2(); + if(level==5&&part==3)Level5Part3(); + if(level==5&&part==4)Level5Part4(); + if(level==5&&part==5)Level5Part5(); + if(level==5&&part==6)Level5Part6(); + if(level==5&&part==7)Level5Part7(); + if(level==5&&part==8)Level5Part8(); + if(level==5&&part==9)Level5Part9(); + if(level==5&&part==10)Level5Part10(); + if(level==5&&part==11)Level5Part11(); + if(level==5&&part==12)Level5Part12(); + if(level==5&&part==13)Level5Part13(); + if(level==5&&part==14)Level5Part14(); + if(level==5&&part==15)Level5Part15(); + if(level==5&&part==16)Level5Part16(); + if(level==5&&part==17)Level5Part17(); + if(level==5&&part==18)Level5Part18(); + if(level==5&&part==19)Level5Part19(); + if(level==5&&part==20)Level5Part20(); + if(level==5&&part==21)Level5Part21(); + if(level==5&&part==22)Level5Part22(); + if(level==6&&part==0)Level6Part0(); + if(level==6&&part==1)Level6Part1(); + if(level==6&&part==2)Level6Part2(); + if(level==6&&part==3)Level6Part3(); + if(level==6&&part==4)Level6Part4(); + if(level==6&&part==5)Level6Part5(); + if(level==6&&part==6)Level6Part6(); + if(level==6&&part==7)Level6Part7(); + if(level==6&&part==8)Level6Part8(); + if(level==6&&part==9)Level6Part9(); + if(level==6&&part==10)Level6Part10(); + if(level==6&&part==11)Level6Part11(); + if(level==6&&part==12)Level6Part12(); + if(level==6&&part==13)Level6Part13(); + if(level==6&&part==14)Level6Part14(); + if(level==6&&part==15)Level6Part15(); + if(level==6&&part==16)Level6Part16(); + if(level==6&&part==17)Level6Part17(); + if(level==6&&part==18)Level6Part18(); + if(level==6&&part==19)Level6Part19(); + if(level==6&&part==20)Level6Part20(); + if(level==6&&part==21)Level6Part21(); + if(level==6&&part==22)Level6Part22(); + if(level==6&&part==23)Level6Part23(); + if(level==6&&part==24)Level6Part24(); + if(level==6&&part==25)Level6Part25(); + if(level==6&&part==26)Level6Part26(); + if(level==6&&part==27)Level6Part27(); + if(level==6&&part==28)Level6Part28(); + if(level==6&&part==29)Level6Part29(); + if(level==6&&part==30)Level6Part30(); + if(level==6&&part==31)Level6Part999999999(); + if(level==7&&part==0)Level7Part0(); + if(level==7&&part==1)Level7Part1(); + if(level==7&&part==2)Level7Part2(); + if(level==7&&part==3)Level7Part3(); + if(level==7&&part==4)Level7Part4(); + if(level==7&&part==5)Level7Part5(); + if(level==7&&part==6)Level7Part6(); + if(level==7&&part==7)Level7Part7(); + if(level==7&&part==8)Level7Part8(); + if(level==7&&part==9)Level7Part9(); + if(level==7&&part==10)Level7Part10(); + if(level==7&&part==11)Level7Part11(); + if(level==7&&part==12)Level7Part12(); + if(level==7&&part==13)Level7Part13(); + if(level==7&&part==14)Level7Part14(); + if(level==7&&part==15)Level7Part15(); + if(level==7&&part==16)Level7Part16(); + if(level==7&&part==17)Level7Part17(); + if(level==7&&part==18)Level7Part18(); + if(level==7&&part==19)Level7Part19(); + if(level==7&&part==20)Level7Part20(); + if(level==7&&part==21)Level7Part21(); + if(level==7&&part==22)Level7Part22(); + if(level==7&&part==23)Level7Part23(); + if(level==7&&part==24)Level7Part24(); + if(level==7&&part==25)Level7Part25(); + if(level==7&&part==26)Level7Part26(); + if(level==-1&&part==0)Levelm1Part0(); + if(level==-1&&part==1)Levelm1Part1(); + if(level==-1&&part==2)Levelm1Part2(); + if(level==-1&&part==3)Levelm1Part3(); + if(level==-1&&part==4)Levelm1Part4(); + if(level==-1&&part==5)Levelm1Part5(); + if(level==-1&&part==6)Levelm1Part6(); + if(level==-1&&part==7)Levelm1Part7(); + if(level==-1&&part==8)Levelm1Part8(); + if(level==-1&&part==9)Levelm1Part9(); + if(level==-1&&part==10)Levelm1Part10(); + if(level==-1&&part==11)Levelm1Part11(); + if(level==-1&&part==12)Levelm1Part12(); + if(level==-1&&part==13)Levelm1Part13(); + if(level==-1&&part==14)Levelm1Part14(); + if(level==-1&&part==15)Levelm1Part15(); + if(level==-1&&part==16)Levelm1Part16(); + if(level==-1&&part==17)Levelm1Part17(); + if(level==-1&&part==18)Levelm1Part18(); + if(level==-1&&part==19)Levelm1Part19(); + if(level==-1&&part==20)Levelm1Part20(); + if(level==-1&&part==21)Levelm1Part21(); + if(level==-2&&part==0)Levelm2Part0(); + if(level==-2&&part==1)Levelm2Part1(); + if(level==-2&&part==2)Levelm2Part2(); + if(level==-2&&part==3)Levelm2Part3(); + if(level==-2&&part==4)Levelm2Part4(); + if(level==-2&&part==5)Levelm2Part5(); + if(level==-2&&part==6)Levelm2Part6(); + if(level==-2&&part==7)Levelm2Part7(); + if(level==-2&&part==8)Levelm2Part8(); + if(level==-2&&part==9)Levelm2Part9(); + if(level==-2&&part==10)Levelm2Part10(); + if(level==-2&&part==11)Levelm2Part11(); + if(level==-2&&part==12)Levelm2Part12(); + if(level==-2&&part==13)Levelm2Part13(); + if(level==-2&&part==14)Levelm2Part14(); + if(level==-2&&part==15)Levelm2Part15(); + if(level==-2&&part==16)Levelm2Part16(); + if(level==-2&&part==17)Levelm2Part17(); + if(level==-2&&part==18)Levelm2Part18(); + if(level==-2&&part==19)Levelm2Part19(); + if(level==-2&&part==20)Levelm2Part20(); + if(level==-2&&part==21)Levelm2Part21(); + if(level==-2&&part==22)Levelm2Part22(); + if(level==-2&&part==23)Levelm2Part23(); + if(level==-2&&part==24)Levelm2Part24(); + if(level==-2&&part==25)Levelm2Part25(); + if(level==-2&&part==26)Levelm2Part26(); - if (level==1&&part==5)level=2,part=0; - if (level==2&&part==10) + if(level==1&&part==5)level=2,part=0; + if(level==2&&part==10) { if(mode==3&&coll>10){completeMenu.Init(-200);return;} if(mode==1&&restarts>1){completeMenu.Init(-200);return;} level=3,part=0; } - if (level==3&&part==7) + if(level==3&&part==7) { if(mode==3&&coll>40){completeMenu.Init(-200);return;} if(mode==1&&restarts>2){completeMenu.Init(-200);return;} level=4,part=0; } - if (level==4&&part==26) + if(level==4&&part==26) { if(mode==3&&coll>75){completeMenu.Init(-200);return;} if(mode==1&&restarts>3){completeMenu.Init(-200);return;} level=5,part=0; } - if (level==5&&part==23) + if(level==5&&part==23) { if(mode==3&&coll>125){completeMenu.Init(-200);return;} if(mode==1&&restarts>5){completeMenu.Init(-200);return;} level=6,part=0; } - if (level==6&&part==32) + if(level==6&&part==32) { if(mode==3&&coll>200){completeMenu.Init(-200);return;} if(mode==1&&restarts>8){completeMenu.Init(-200);return;} level=7,part=0; } - if (level==7&&part==27) + if(level==7&&part==27) { if(mode==3&&coll>50){completeMenu.Init(-200);return;} if(mode==1&&restarts>2){completeMenu.Init(-200);return;} level=-1,part=0; } - if (level==-1&&part==22){completeMenu.Init(-200);return;} - if (level==-2&&part>26){completeMenu.Init(-200);return;} + if(level==-1&&part==22){completeMenu.Init(-200);return;} + if(level==-2&&part>26){completeMenu.Init(-200);return;} } bool ProcessCurCred() { @@ -601,12 +537,11 @@ bool ProcessCurCred() vdig->printf(creditfly,240,HGETEXT_LEFT,"%s",BLRVERSION); bdig->printf(creditfly,310,HGETEXT_LEFT,"%s",BuiltDate); } - int times=1;if (LOWFPS)times=17; if (credstop)credbrk+=hge->Timer_GetDelta(); if (credbrk>=4.5&&!creddone)creddone=true,credstop=false,creditacc=0,credbrk=0; - if (!credstop)for (int i=1;i<=times;++i)creditfly-=creditacc; + if (!credstop)for (int i=1;i<=17;++i)creditfly-=creditacc; if (creditfly<-300)return true; - for (int i=1;i<=times;++i)if (creditacc<2)creditacc+=0.015; + for (int i=1;i<=17;++i)if (creditacc<2)creditacc+=0.015; if (abs(creditfly-400)<5&&!creddone&&!credstop)credstop=true; return false; } @@ -625,7 +560,7 @@ void AboutScene() } bool Foclost() { - if (Current_Position==1)pauseMenu.Init(-200); + if(Current_Position==1)pauseMenu.Init(-200); return false; } bool FrameFunc() @@ -665,9 +600,9 @@ bool FrameFunc() CreditsRail->SetHotSpot(300,100); creditsp=0; Music_Init("./Resources/Music/BLR2_TR09.ogg"); - lpst=lped=0; - Music_Play(); + lpst=lped=0;Music_Play(); creditfly=1200;creditacc=0;credstop=creddone=false; + Credits->SetTextureRect(0,0,600,200); Current_Position=4; mainMenu.Leave(); break; @@ -692,15 +627,14 @@ bool FrameFunc() playerpos.x=400,playerpos.y=400,playerrot=0; frameleft=ThirtySeconds;infofade=0xFF;Dis8ref=t8special=false; level=1,part=1;frms=0,averfps=0.0;bsscale=1; + if(bullet){free(bullet);bullet=NULL;} towcnt=bulcnt=0;whrcnt=12;skyactive=false;PlayerSplit=false; score=0;Mult_Init();//Music_Init("./Resources/Music/CanonTechno.ogg"); lpst=4625568;lped=9234584;//Music_Play(); coll=semicoll=clrusg=0;playerLockX=playerLockY=false; Lock.Init(2);IfShowTip=true;lsc=0; - //Lock.SetTexture(SprSheet,151,264,2,8); clrrad=pi/2;clrrange=0;re.SetSeed(time(NULL)); memset(tower,0,sizeof(tower)); - memset(bullet,0,sizeof(bullet)); Complete=false; Current_Position=1; Level1Part1(); @@ -711,15 +645,14 @@ bool FrameFunc() playerpos.x=400,playerpos.y=400,playerrot=0; frameleft=ThirtySeconds;infofade=0xFF;Dis8ref=t8special=false; level=-2,part=0;frms=0,averfps=0.0;bsscale=1;assetime=0; + if(bullet){free(bullet);bullet=NULL;} towcnt=bulcnt=0;whrcnt=12;skyactive=false;PlayerSplit=false; score=0;Mult_Init();//Music_Init("./Resources/Music/CanonTechno.ogg"); lpst=4625568;lped=9234584;//Music_Play(); coll=semicoll=clrusg=0;playerLockX=playerLockY=false; Lock.Init(2);IfShowTip=true;lsc=0; - //Lock.SetTexture(SprSheet,151,264,2,8); clrrad=pi/2;clrrange=0;re.SetSeed(time(NULL)); memset(tower,0,sizeof(tower)); - memset(bullet,0,sizeof(bullet)); Complete=false; Current_Position=1; IfCallLevel=true; @@ -729,15 +662,14 @@ bool FrameFunc() playerpos.x=400,playerpos.y=400,playerrot=0; frameleft=ThirtySeconds;infofade=0xFF;Dis8ref=t8special=false; level=1,part=1;frms=0,averfps=0.0;bsscale=1; + if(bullet){free(bullet);bullet=NULL;} towcnt=bulcnt=0;whrcnt=12;skyactive=false;PlayerSplit=false; score=0;Mult_Init();//Music_Init("./Resources/Music/CanonTechno.ogg"); lpst=4625568;lped=9234584;//Music_Play(); coll=semicoll=clrusg=0;playerLockX=playerLockY=false; Lock.Init(2);IfShowTip=true;lsc=0; - //Lock.SetTexture(SprSheet,151,264,2,8); clrrad=pi/2;clrrange=0;re.SetSeed(time(NULL)); memset(tower,0,sizeof(tower)); - memset(bullet,0,sizeof(bullet)); Complete=false; Current_Position=1; Level1Part1(); @@ -888,6 +820,7 @@ bool FrameFunc() hge->Gfx_Clear(SETA(DBGColor,0xFF)); if (skyactive)sky.Update(),sky.Render(); hge->Gfx_RenderQuad(&quad); + int bulinuse=0; if (Current_Position==1||Current_Position==2||Current_Position==5||Current_Position==11||Current_Position==12) { //If we are at the main scene or tip scene(which towers and bullets should still appear..) @@ -911,6 +844,7 @@ bool FrameFunc() ProcessLaser(); for (int i=1;i<=bulcnt;++i) { + if(bullet[i].exist)++bulinuse; switch (bullet[i].bullettype) { case 1:ProcessBullet1(i);break; @@ -990,13 +924,16 @@ bool FrameFunc() if (!LOWFPS&&infofade<0xFF)++infofade; if (LOWFPS&&infofade<=0xEF)infofade+=16; } + if(hge->Input_GetKeyStateEx(HGEK_A)==HGEKST_HIT)showalloc^=1; + if(showalloc) + { + fnt->SetColor(0xFFFFFFFF); + fnt->printf(795, 0, HGETEXT_RIGHT, "Allocated bullets %d",bulcnt); + fnt->printf(795, 25, HGETEXT_RIGHT, "%d in use",bulinuse); + } fnt->SetColor(SETA(0xFFFFFF,infofade)); fnt->printf(5, 0, HGETEXT_LEFT, "Frames to go: %d",frameleft); -#if 0 - fnt->printf(5, 25, HGETEXT_LEFT, "Score: %I64d",score); -#else fnt->printf(5, 25, HGETEXT_LEFT, "Score: %lld",score); -#endif fnt->printf(5, 50, HGETEXT_LEFT, "Level %d",level); if (mode==3) fnt->printf(5, 75, HGETEXT_LEFT, "Collisions: %d",coll); @@ -1006,9 +943,7 @@ bool FrameFunc() fnt->printf(5, 75, HGETEXT_LEFT, "Restarts: %d",restarts); fnt->printf(5, 100, HGETEXT_LEFT, "Semi-Collisions: %d",semicoll); if(mode==2) - { fnt->printf(5, 125, HGETEXT_LEFT, "Multiplier: %.2lf",mult); - } else { fnt->printf(5, 125, HGETEXT_LEFT, "Clear Range Left: %d",clrtime+clrbns); @@ -1039,7 +974,7 @@ void printHelp(char *exec,const char* str="") puts("--fast Fast mode. All levels are two times shorter."); puts("--logfile=... Use an alternate log file name instead of the default \"BLRLOG.txt\"."); #ifdef WIN32 - printf("--nohideconsole Do not hide console (Windows version only).\n"); + printf("--nohideconsole Do not hide console.\n"); #endif if(strcmp(str,""))printf("%s\n",str); exit(0); @@ -1108,6 +1043,7 @@ void parseArgs(int argc,char *argv[]) } int main(int argc,char *argv[]) { + signal(SIGSEGV,SigHandler); parseArgs(argc,argv); #ifdef WIN32 if(!noHideConsole)FreeConsole(); @@ -1308,6 +1244,7 @@ int main(int argc,char *argv[]) playerpos.x=400,playerpos.y=400,playerrot=0; frameleft=ThirtySeconds;infofade=0xFF;Dis8ref=t8special=false; level=startLvl,part=startPrt;frms=0,averfps=0.0;bsscale=1; + if(bullet){free(bullet);bullet=NULL;} towcnt=bulcnt=0;whrcnt=12;skyactive=false;PlayerSplit=false; score=0;Mult_Init();//Music_Init("./Resources/Music/CanonTechno.ogg"); lpst=4625568;lped=9234584;//Music_Play(); @@ -1315,7 +1252,6 @@ int main(int argc,char *argv[]) Lock.Init(2);IfShowTip=true;lsc=0; clrrad=pi/2;clrrange=0;re.SetSeed(time(NULL)); memset(tower,0,sizeof(tower)); - memset(bullet,0,sizeof(bullet)); Complete=false;Current_Position=1; IfCallLevel=true; mode=3; diff --git a/menus.h b/menus.h index 7164701..f014123 100644 --- a/menus.h +++ b/menus.h @@ -814,7 +814,7 @@ public: LowerGradient.v[0].col=LowerGradient.v[1].col=SETA(DBGColor,0x00); LowerGradient.v[2].col=LowerGradient.v[3].col=SETA(DBGColor,0xFF); } - void Leave(){onOut=true;} + void Leave(){if(!onIn)onOut=true;} int Update() { if(onIn) @@ -832,6 +832,7 @@ public: { active=onOut=false; if(selected==1)Current_Position=1,DisableAllTower=DisablePlayer=false; + return -1; } } ConfigureQuad(&UpperGradient,xoffset-140,190,320,100); @@ -1012,13 +1013,7 @@ public: Ribb->RenderEx(xoffset-50,422,0,3.75,1); hge->Gfx_RenderQuad(&UpperGradient); hge->Gfx_RenderQuad(&LowerGradient); - MenuFont->printf(xoffset-100,250,HGETEXT_LEFT, -#if 0 - "You scored %I64d at level %d" -#else - "You scored %lld at level %d" -#endif - ,score,level); + MenuFont->printf(xoffset-100,250,HGETEXT_LEFT,"You scored %lld at level %d",score,level); MenuFont->printf(xoffset-100,280,HGETEXT_LEFT,"Average FPS: %lf\n",averfps); DeathTitle->Render(xoffset-200,200); } @@ -1100,21 +1095,9 @@ public: hge->Gfx_RenderQuad(&UpperGradient); hge->Gfx_RenderQuad(&LowerGradient); if(~CheckHighScore()) - MenuFont->printf(xoffset-100,250,HGETEXT_LEFT, -#if 0 - "New Highscore %I64d!" -#else - "New Highscore %lld!" -#endif - ,score); + MenuFont->printf(xoffset-100,250,HGETEXT_LEFT,"New Highscore %lld!",score); else - MenuFont->printf(xoffset-100,250,HGETEXT_LEFT, -#if 0 - "Score %I64d" -#else - "Score %lld" -#endif - ,score); + MenuFont->printf(xoffset-100,250,HGETEXT_LEFT,"Score %lld",score); MenuFont->printf(xoffset-100,280,HGETEXT_LEFT,"Your Ranking: %s",getRank()); if(mode==2) { @@ -1349,13 +1332,7 @@ public: if(calcy>289.9&&calcy<540.1) { if(i<=WrapCnt) - MenuFont->printf(xoffset,calcy,HGETEXT_LEFT,"%u. %s - " -#if 0 - "%I64d" -#else - "%lld" -#endif - ,i,WrapRec[i].name,WrapRec[i].score); + MenuFont->printf(xoffset,calcy,HGETEXT_LEFT,"%u. %s - %lld",i,WrapRec[i].name,WrapRec[i].score); else MenuFont->printf(xoffset,calcy,HGETEXT_LEFT,"%u. ----------",i); } } @@ -1437,13 +1414,7 @@ public: if(view==1) { if(dyoffset+430>289.9&&dyoffset+430<540.1) - MenuFont->printf(xoffset,dyoffset+430,HGETEXT_LEFT,"Scored " -#if 0 - "%I64d" -#else - "%lld" -#endif - " by %s",WrapRec[no].score,WrapRec[no].name); + MenuFont->printf(xoffset,dyoffset+430,HGETEXT_LEFT,"Scored %lld by %s",WrapRec[no].score,WrapRec[no].name); if(dyoffset+460>289.9&&dyoffset+460<540.1) MenuFont->printf(xoffset,dyoffset+460,HGETEXT_LEFT,"Semi-Collisions %d",WrapRec[no].scoll); if(dyoffset+490>289.9&&dyoffset+490<540.1) @@ -1452,13 +1423,7 @@ public: else { if(dyoffset+430>289.9&&dyoffset+430<540.1) - MenuFont->printf(xoffset,dyoffset+430,HGETEXT_LEFT,"Scored " -#if 0 - "%I64d" -#else - "%lld" -#endif - " by %s",WrapRec[no].score,WrapRec[no].name); + MenuFont->printf(xoffset,dyoffset+430,HGETEXT_LEFT,"Scored %lld by %s",WrapRec[no].score,WrapRec[no].name); if(dyoffset+460>289.9&&dyoffset+460<540.1) { if(view==0) diff --git a/towernbullet.h b/towernbullet.h index 2ec514c..b0ca7e7 100644 --- a/towernbullet.h +++ b/towernbullet.h @@ -24,15 +24,7 @@ void RenderAlter(vector2d p,TColors ca,TColors cb,double rot=0,double scl=1) int CreateBullet1(double x,double y,double bs,bool eff=false) { ++shots; - int i; - if (bulcnt==0) - bulcnt=i=1; - else - { - for (i=1;i<=bulcnt;++i) - if (!bullet[i].exist)break; - if (i>bulcnt)bulcnt=i; - } + int i=AllocBullet(); bullet[i].exist=true; bullet[i].inv=false; bullet[i].bullettype=1; @@ -52,15 +44,7 @@ int CreateBullet1(double x,double y,double bs,bool eff=false) int CreateBullet2(double x,double y,double bs,double rad,bool eff=false,bool invi=false) { ++shots; - int i; - if (bulcnt==0) - bulcnt=i=1; - else - { - for (i=1;i<=bulcnt;++i) - if (!bullet[i].exist)break; - if (i>bulcnt)bulcnt=i; - } + int i=AllocBullet(); bullet[i].exist=true; bullet[i].addblend=false; bullet[i].extborder=false; @@ -89,15 +73,7 @@ void CreateBullet3(double x,double y,double bs,int dir,bool eff=false) void CreateBullet4(double x,double y,double bs,int yelbrk=0,bool eff=false) { ++shots; - int i; - if (bulcnt==0) - bulcnt=i=1; - else - { - for (i=1;i<=bulcnt;++i) - if (!bullet[i].exist)break; - if (i>bulcnt)bulcnt=i; - } + int i=AllocBullet(); bullet[i].exist=true; bullet[i].inv=false; bullet[i].bullettype=4; @@ -117,15 +93,7 @@ void CreateBullet4(double x,double y,double bs,int yelbrk=0,bool eff=false) void CreateBullet5(double x,double y,double bs,bool eff=false) { ++shots; - int i; - if (bulcnt==0) - bulcnt=i=1; - else - { - for (i=1;i<=bulcnt;++i) - if (!bullet[i].exist)break; - if (i>bulcnt)bulcnt=i; - } + int i=AllocBullet(); bullet[i].exist=true; bullet[i].inv=false; bullet[i].bullettype=5; @@ -144,15 +112,7 @@ void CreateBullet5(double x,double y,double bs,bool eff=false) int CreateBullet6(double x,double y,double bs,int explo,int exp1=8,int exp2=12,bool eff=false) { ++shots; - int i; - if (bulcnt==0) - bulcnt=i=1; - else - { - for (i=1;i<=bulcnt;++i) - if (!bullet[i].exist)break; - if (i>bulcnt)bulcnt=i; - } + int i=AllocBullet(); bullet[i].exist=true; bullet[i].inv=false; bullet[i].bullettype=6; @@ -176,15 +136,7 @@ int CreateBullet6(double x,double y,double bs,int explo,int exp1=8,int exp2=12,b int CreateBullet7(double x,double y,double bs,int explo,bool eff=false) { ++shots; - int i; - if (bulcnt==0) - bulcnt=i=1; - else - { - for (i=1;i<=bulcnt;++i) - if (!bullet[i].exist)break; - if (i>bulcnt)bulcnt=i; - } + int i=AllocBullet(); bullet[i].exist=true; bullet[i].inv=false; bullet[i].bullettype=7; @@ -208,15 +160,7 @@ int CreateBullet7(double x,double y,double bs,int explo,bool eff=false) int CreateBullet8(double x,double y,double bs,bool eff=false) { ++shots; - int i; - if (bulcnt==0) - bulcnt=i=1; - else - { - for (i=1;i<=bulcnt;++i) - if (!bullet[i].exist)break; - if (i>bulcnt)bulcnt=i; - } + int i=AllocBullet(); bullet[i].exist=true; bullet[i].inv=false; bullet[i].bullettype=8; @@ -238,15 +182,7 @@ int CreateBullet9(double x,double y,double bs,int explo,int cnt,int brk,bool eff //This creates bullet9 in random direction and as attrib 0 //change them if necessary. ++shots; - int i; - if (bulcnt==0) - bulcnt=i=1; - else - { - for (i=1;i<=bulcnt;++i) - if (!bullet[i].exist)break; - if (i>bulcnt)bulcnt=i; - } + int i=AllocBullet(); bullet[i].exist=true; bullet[i].inv=false; bullet[i].bullettype=9; @@ -269,15 +205,7 @@ int CreateBullet9(double x,double y,double bs,int explo,int cnt,int brk,bool eff } void CreateBullet255(double x,double y,double bs,int spno=0) { - int i; - if (bulcnt==0) - bulcnt=i=1; - else - { - for (i=1;i<=bulcnt;++i) - if (!bullet[i].exist)break; - if (i>bulcnt)bulcnt=i; - } + int i=AllocBullet(); bullet[i].exist=true; bullet[i].bullettype=255; bullet[i].bulletpos.x=x; -- cgit v1.2.3