aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar chirs241097@gmail.com <chirs241097@gmail.com@c17bf020-1265-9734-9302-a83f62007ddb> 2014-03-19 13:42:25 +0000
committerGravatar chirs241097@gmail.com <chirs241097@gmail.com@c17bf020-1265-9734-9302-a83f62007ddb> 2014-03-19 13:42:25 +0000
commitd8c84876b20f8fd784171e9bb525af38a25380f1 (patch)
tree132688b48bb9875d427d2b44719baa05e026ffa6
parentcd2d8a40f39ccf70b6fb294cff37c879bee98c6a (diff)
downloadbullet-lab-remix-d8c84876b20f8fd784171e9bb525af38a25380f1.tar.xz
Support command line options, change player settings, update wiki page.
-rwxr-xr-xCHANGELOG.TXT2
-rw-r--r--global.h9
-rw-r--r--main.cpp109
-rw-r--r--menus.h3
-rw-r--r--towernbullet.h2
5 files changed, 118 insertions, 7 deletions
diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT
index 2d2b426..75ab8cb 100755
--- a/CHANGELOG.TXT
+++ b/CHANGELOG.TXT
@@ -13,6 +13,8 @@ New level "Gravity vortex".
New level "Double reflective".
Make point bullet additive blending.
Allow bullets to pause before being accelerated.
+Add command line argument support. Use "--help" for usage.
+Modify player speed settings.
0.8.0-1_PR (b75)
New level Supernova.
diff --git a/global.h b/global.h
index 8515de7..9c8c1ba 100644
--- a/global.h
+++ b/global.h
@@ -6,6 +6,7 @@
#include <hgegui.h>
#define MaxRes 80
#define Resd 20.0f
+#define BLRVERSION "0.8.1-0_PR (b76)"
HGE *hge=0;
HEFFECT snd;
hgeQuad quad;
@@ -279,6 +280,14 @@ bool credstop,creddone;
bool tfs;
int fpslvl,clrmode;
const vector2d splitData[4]={vector2d(0,0),vector2d(400,0),vector2d(0,300),vector2d(400,300)};
+//options from command line arguments
+bool fNoSound,
+#ifdef WIN32
+noHideConsole,
+#endif
+fFristStartUp,fFast;
+int startLvl,startPrt,fFullScreen;
+char alterLog[64];
//static const char* GLOBAL_H_FN="global.h";
void Throw(char *Filename,char *Info)
diff --git a/main.cpp b/main.cpp
index e6fdfe6..c6db4fe 100644
--- a/main.cpp
+++ b/main.cpp
@@ -40,6 +40,7 @@
#include <cmath>
#include <ctime>
#include <cstdlib>
+#include <cstring>
#include <cstdio>
#ifdef WIN32
#include <io.h>
@@ -744,15 +745,87 @@ bool FrameFunc()
hge->Gfx_EndScene();
return false;
}
+void printHelp(char *exec,const char* str="")
+{
+ printf("Usage %s [options]...\n",exec);
+ printf("To run the game normally, just start without arguments.\n");
+ printf("Options:\n");
+ printf("--help Print this help and exit.\n");
+ printf("--version Print version and exit.\n");
+ printf("--start=x,y Start the game directly from level x part y. The part must be valid.\n");
+ printf("--nosound Forcibly use no sound.\n");
+ printf("--fullscreen=1/0 Forcibly use fullscreen/windowed. This will override your configuration.\n");
+ printf("--firststartup Forcibly run first start up. This will reset the score file.\n");
+ printf("--fast Fast mode. All levels are two times shorter.\n");
+ printf("--logfile=... Use an alternate log file name instead of the default \"BLRLOG.txt\".\n");
#ifdef WIN32
-int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
+ printf("--nohideconsole Do not hide console (Windows version only).\n");
#endif
-#ifndef WIN32
-int main()
+ if(strcmp(str,""))printf("%s\n",str);
+ exit(0);
+}
+void parseArgs(int argc,char *argv[])
+{
+ for(int i=1;i<argc;++i)
+ {
+ if(!strcmp(argv[i],"--help"))printHelp(argv[0]);
+ if(!strcmp(argv[i],"--version"))
+ {
+ printf("Bullet Lab Remix II %s\n",BLRVERSION);
+ exit(0);
+ }
+ bool valid=false;
+ if(!strcmp(argv[i],"--nosound"))fNoSound=true,valid=true;
+ if(!strcmp(argv[i],"--fast"))fFast=true,valid=true;
+ if(!strcmp(argv[i],"--firststartup"))fFristStartUp=true,valid=true;
+ if(!strncmp(argv[i],"--fullscreen",12))
+ {
+ char *ptr=argv[i];while(*ptr!='='&&*ptr)++ptr;
+ if(!*ptr)printHelp(argv[0],"--fullscreen need a parameter!\n");
+ ++ptr;
+ int para=strtol(ptr,&ptr,10);
+ if(*ptr||(para!=1&&para!=0))printHelp(argv[0],"Invalid parameter for --fullscreen!\n");
+ if(para)fFullScreen=2;else fFullScreen=1;
+ valid=true;
+ }
+ if(!strncmp(argv[i],"--start",7))
+ {
+ char *ptr=argv[i];while(*ptr!='='&&*ptr)++ptr;
+ if(!*ptr)printHelp(argv[0],"--start need two parameters!");
+ ++ptr;startLvl=strtol(ptr,&ptr,10);
+ if(*ptr!=',')printHelp(argv[0],"Invalid parameter for --start!\n");
+ ++ptr;startPrt=strtol(ptr,&ptr,10);
+ if(*ptr)printHelp(argv[0],"Invalid parameter for --start!\n");
+ valid=true;
+ }
+ if(!strncmp(argv[i],"--logfile",9))
+ {
+ char *ptr=argv[i];while(*ptr!='='&&*ptr)++ptr;
+ if(!*ptr)printHelp(argv[0],"--logfile need a parameter!");
+ ++ptr;strcpy(alterLog,ptr);
+ valid=true;
+ }
+#ifdef WIN32
+ if(!strncmp(argv[i],"--nohideconsole",15))noHideConsole=true,valid=true;
#endif
+ if(!valid)
+ {
+ char err[256];sprintf(err,"Unknown option: %s\n",argv[i]);
+ printHelp(argv[0],err);
+ }
+ }
+}
+int main(int argc,char *argv[])
{
+ parseArgs(argc,argv);
+#ifdef WIN32
+ if(!noHideConsole)FreeConsole();
+#endif
srand(time(NULL));
hge=hgeCreate(HGE_VERSION);
+ if(alterLog[0])
+ hge->System_SetState(HGE_LOGFILE, alterLog);
+ else
hge->System_SetState(HGE_LOGFILE, "BLRLOG.txt");
hge->System_Log("%s: Bullet Lab Remix Log File",MAIN_SRC_FN);
#ifdef WIN32
@@ -771,6 +844,7 @@ int main()
hge->System_SetState(HGE_SCREENWIDTH, 800);
hge->System_SetState(HGE_SCREENHEIGHT, 600);
hge->System_SetState(HGE_SCREENBPP, 32);
+ if(fNoSound)hge->System_SetState(HGE_USESOUND,false);
#ifdef WIN32
hge->System_SetState(HGE_ICON, MAKEINTRESOURCE(1));
#endif
@@ -780,6 +854,7 @@ int main()
hge->System_Log("%s: Config file not found. Calling first startup.",MAIN_SRC_FN);
firststartup();
}
+ if(fFristStartUp)firststartup();
hge->System_Log("%s: Loading config file",MAIN_SRC_FN);
freopen("blr.cfg","r",stdin);
char tch=getchar();
@@ -802,10 +877,13 @@ int main()
hge->System_SetState(HGE_FPS,61);
fpslvl=1;
}
+ if(fFast)TenSeconds/=2,TwentySeconds/=2,ThirtySeconds/=2,AMinute/=2;
tch=getchar();//FULLSCRREEN
tfs=false;
if (tch==1)
hge->System_SetState(HGE_WINDOWED, false),tfs=true;
+ if(fFullScreen==2)hge->System_SetState(HGE_WINDOWED, false),tfs=true;
+ if(fFullScreen==1)hge->System_SetState(HGE_WINDOWED, true),tfs=false;
tch=getchar();//LockFPS
if (tch==1&&!LOWFPS)
{
@@ -815,7 +893,7 @@ int main()
tch=getchar();//Key binding
if (tch==1)diffkey=true;
plrspd=tch=getchar();
- playerfulspd=(tch)*0.05f;
+ playerfulspd=(tch)*0.08f;
playerspeed=playerfulspd;
plrslospd=tch=getchar();
playerfulslospd=(tch)*0.0125f;
@@ -894,8 +972,27 @@ int main()
gui->SetCursor(spr);
gui->SetFocus(1);
gui->Enter();
- if (LOWFPS)
- hge->System_Log("%s: Low FPS Mode Enabled.\n",MAIN_SRC_FN);
+ if(LOWFPS)hge->System_Log("%s: Low FPS Mode Enabled.",MAIN_SRC_FN);
+ if(fNoSound)hge->System_Log("%s: Sound is disabled.",MAIN_SRC_FN);
+ if(startLvl)
+ {
+ hge->System_Log("%s: Starting from Level%dPart%d",MAIN_SRC_FN,startLvl,startPrt);
+ gui->Leave();
+ 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;
+ 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;
+ 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;
+ }
hge->System_Start();
delete gui;delete titlespr;
delete fnt;delete playerspr;
diff --git a/menus.h b/menus.h
index 8fca040..97d4a2d 100644
--- a/menus.h
+++ b/menus.h
@@ -777,6 +777,7 @@ void OptionsGUI_FrameFnk()
TwentySeconds=1200;
ThirtySeconds=1800;
AMinute=3600;
+ if(fFast)TenSeconds/=2,TwentySeconds/=2,ThirtySeconds/=2,AMinute/=2;
break;
case 1:
fpslvl=2;LOWFPS=false;
@@ -785,6 +786,7 @@ void OptionsGUI_FrameFnk()
TwentySeconds=20000;
ThirtySeconds=30000;
AMinute=60000;
+ if(fFast)TenSeconds/=2,TwentySeconds/=2,ThirtySeconds/=2,AMinute/=2;
break;
case 2:
fpslvl=0;LOWFPS=false;
@@ -793,6 +795,7 @@ void OptionsGUI_FrameFnk()
TwentySeconds=20000;
ThirtySeconds=30000;
AMinute=60000;
+ if(fFast)TenSeconds/=2,TwentySeconds/=2,ThirtySeconds/=2,AMinute/=2;
break;
}
switch (fpslvl)
diff --git a/towernbullet.h b/towernbullet.h
index ea51289..59613f2 100644
--- a/towernbullet.h
+++ b/towernbullet.h
@@ -977,7 +977,7 @@ void ProcessBullet255(int i)
}
else
{
- bulletspr[grey]->SetColor(0x10FFFFFF);
+ bulletspr[grey]->SetColor(0x20FFFFFF);
bulletspr[grey]->SetBlendMode(BLEND_ALPHAADD);
bulletspr[grey]->RenderEx(bullet[i].bulletpos.x+6,bullet[i].bulletpos.y+6,0,0.5,0);
bulletspr[grey]->SetBlendMode(BLEND_ALPHABLEND);