From a404f537e1f260040063b65461213800c896e15c Mon Sep 17 00:00:00 2001 From: "chirs241097@gmail.com" Date: Mon, 3 Mar 2014 08:52:12 +0000 Subject: New levels and laser rewrite. Bring back a level and remove all commented levels. --- CHANGELOG.TXT | 11 +++- VERSION.TXT | 2 +- global.h | 51 ++++++----------- levels.h | 133 +++++++++++++++++--------------------------- libcgh.h | 24 +++++++- main.cpp | 5 +- towernbullet.h | 172 ++++++++++++++++++++++++++++++++++++++++++--------------- 7 files changed, 233 insertions(+), 165 deletions(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 53ac014..dac52c6 100755 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,12 +1,21 @@ =================================================================== Next version: -0.7.2-1_PR +0.7.2-2_PR TODOs: Couple of tests, new levels, pre-release preparation, resource remaking. 0.7.x-x_PR will be another public pre-release version. Pre-Released versions: +0.7.2-1_PR (b71) +New level "Trypophobia", however it seems that this level won't +cause trypophobia at all! +Rewrote laser distance detection using vector2d calculations, +extending libcgh and bump its version at the same time. +Put the new level to the correct place. +Bring back "Minesweeper" level, adjust it to the new interfaces. +Remake the credits page, it grows from 350KiB to 6MiB. + 0.7.2-0_PR (b70) I wasn't willing to bump the build number because I want the svn revision to chease the build number. diff --git a/VERSION.TXT b/VERSION.TXT index 3867e66..1c85f05 100755 --- a/VERSION.TXT +++ b/VERSION.TXT @@ -1 +1 @@ -0.7.2-0_PR (b70) \ No newline at end of file +0.7.2-1_PR (b71) \ No newline at end of file diff --git a/global.h b/global.h index 109c81a..393b3bd 100644 --- a/global.h +++ b/global.h @@ -73,9 +73,9 @@ bool DisableAllTower=false; bool DisablePlayer=false; bool LOWFPS=false,diffkey=false; inline double GetDist(vector2d,vector2d); -struct Bullet +class Bullet { - //hgeSprite *bulletspr;//This shit will be deprecated. +public: vector2d bulletpos; vector2d bulletdir; double dist; @@ -404,38 +404,6 @@ void ClearAll(bool cbullet=true) memset(tower,0,sizeof(tower)); if (cbullet)All2pnt(); } - /*if (cbullet) - { - none=true; - for (int i=1;i<=bulcnt;++i) - { - if (LOWFPS) - { - if (bullet[i].bulletspr->GetColor()>>24>=0x08) - { - bullet[i].bulletspr->SetColor(bullet[i].bulletspr->GetColor()-0x8000000); - none=false; - } - } - else - { - if (bullet[i].bulletspr->GetColor()>>24>=0x01) - { - bullet[i].bulletspr->SetColor(bullet[i].bulletspr->GetColor()-0x1000000); - none=false; - } - } - } - if (none) - { - bulcnt=0; - memset(bullet,0,sizeof(bullet)); - } - none=true; - for (int i=1;i<=bulcnt;++i)if (bullet[i].bulletspr->GetColor()>>24>=0x3F){none=false;break;} - if (none) - bulcnt=0,memset(bullet,0,sizeof(bullet)); - }*/ } void SaySomethingAndBye(char *text) { @@ -510,3 +478,18 @@ TextureRect GetTextureRect(int type,TColors color) } return TextureRect(0,0,0,0); } +DWORD ColorToDWORD(TColors a) +{ + switch(a) + { + case green:return 0xCCFF00; + case blue:return 0x33CCFF; + case yellow:return 0xFFFF00; + case purple:return 0x9966FF; + case red:return 0xFFFF3333; + case white:return 0xFFFEFEFE; + case dblue:return 0xFF0000FF; + case orange:return 0xFFFF8800; + default:return 0xFF000000; + } +} diff --git a/levels.h b/levels.h index 41be41a..1bf8b25 100644 --- a/levels.h +++ b/levels.h @@ -2971,15 +2971,45 @@ void Level7Part18()//Great circles-child2 Circles[i].Update(); } } +BTail btails[50]; +void Level7Part19() +{ + frameleft=AMinute*2;clrtime=2;towcnt=0; + DisableAllTower=false; + if (IfShowTip) + { + IfShowTip=false; + FadeTip=false; + Current_Position=2; + ShowTip("Warning: Trypophobia caution ahead!"); + } + if (Current_Position==1) + { + ++part;All2pnt();avabrk=1.0f;avacurbrk=1.0f;memset(btails,0,sizeof(btails)); + } +} +void Level7Part20() +{ + avacurbrk+=hge->Timer_GetDelta(); + if(avacurbrk>avabrk) + { + avacurbrk=0;avabrk=(frameleft/(double)(AMinute*2))*0.7+0.3; + for(int i=0;i<50;++i) + if(!btails[i].isActive()) + {btails[i].Create();break;} + } + for(int i=0;i<50;++i) + if(btails[i].isActive())btails[i].Update(); +} //Rearrange needed since here, see LEVELS.txt WOP wop[100]; -void Level7Part19()//Wave of Photon +void Level7Part21()//Wave of Photon { memset(bnl,0,sizeof(bnl)); - frameleft=AMinute; + frameleft=AMinute;All2pnt(); ykbrk=0.5f;++part; } -void Level7Part20() +void Level7Part22() { ykbrk-=hge->Timer_GetDelta(); if (ykbrk<0&&frameleft>TenSeconds/10*3) @@ -3005,6 +3035,12 @@ void Level7Part20() { if (rand()%100>49)b=vector2d(-10,rand()%580+10);else b=vector2d(810,rand()%580+10); } + if (rand()%100>80) + { + vector2d d=playerpos-a; + b=playerpos; + while(b.x>-5&&b.x<805&&b.y>-5&&b.y<605)b=b+d; + } wop[i].Init(a,b,1+(AMinute-frameleft)/(double)AMinute,0.02); break; } @@ -3012,7 +3048,7 @@ void Level7Part20() for (int i=0;i<100;++i) if (wop[i].active)wop[i].Update(); } -void Level7Part21()//3 circles +void Level7Part23()//3 circles { frameleft=AMinute;clrtime=2;towcnt=0; DisableAllTower=false; @@ -3039,7 +3075,7 @@ void L7P13Creator(vector2d p,int cnt,TColors col) bullet[pnt].bulletaccel=-0.003;bullet[pnt].limv=((AMinute-frameleft)/(double)AMinute)+1.0f; } } -void Level7Part22() +void Level7Part24() { avacurbrk+=hge->Timer_GetDelta(); avabrk=(frameleft/(double)AMinute)*0.5f+0.5f; @@ -3053,7 +3089,7 @@ void Level7Part22() } BCircle scircles[200]; double rspd[200]; -void Level7Part23()//circles +void Level7Part25()//circles { frameleft=AMinute;clrtime=2;towcnt=0; DisableAllTower=false; @@ -3069,7 +3105,7 @@ void Level7Part23()//circles ++part;All2pnt();avabrk=1.0f;avacurbrk=1.0f;memset(scircles,0,sizeof(scircles)); } } -void Level7Part24() +void Level7Part26() { avacurbrk+=hge->Timer_GetDelta(); avabrk=0.1+(frameleft/(double)AMinute)*0.4f; @@ -3096,83 +3132,16 @@ void Level7Part24() } } } -//vvvvvvvvvvvvvvvvvvvvvv Old Levels vvvvvvvvvvvvvvvvvvvvvv// -/* -void Level1Part17()//33*b+1*r-discard? -{ - frameleft=AMinute;clrtime=0; - if (bulcnt!=0&&towcnt!=34) - { - ClearAll(); - return; - } - DisableAllTower=false; - if (IfShowTip) - { - IfShowTip=false; - FadeTip=false; - Current_Position=2; - ShowTip("The last level for Dev-version...\n\ -It seems really easy right?"); - return; - } - ++frameskips; - if (frameskips<10&&!LOWFPS)return; - frameskips=0; - CreateTower6(400,30,500,4,750,1,36); - for (int i=1;i<=33;++i) - { - int tmp=CreateTower1(i*24-20,10,1000,3,i<16?-pi/90:pi/90); - } - for (int i=1;i<=towcnt;++i) - if (tower[i].towerspr->GetColor()==0x80FFFFFF) - tower[i].towerspr->SetColor(0x00FFFFFF); - for (int i=1;i<=towcnt;++i) - if ((tower[i].towerspr->GetColor()>>24)<=0x80) - tower[i].towerspr->SetColor(tower[i].towerspr->GetColor()+0x01FFFFFF); - else - { - ++part; - BTarg.TargHide(); - return; - } -} -void Level1Part18()//Child of last level -{ - //This is the child of Part17 - //Keep them together, thanks a lot - // --Commented by Chirsno, 03/08/2013 - if (frameleft<2*TwentySeconds) - { - tower[1].exp2=48; - tower[1].towertimer=400; - } - if (frameleft98) + if (rand()%100>95) { int i; for (i=1;i<=nonamecnt+1;++i) @@ -3180,13 +3149,13 @@ void Level1Part22()//Minesweeper?-child if (!noname[i].Exist()) { if (frameleftnonamecnt)nonamecnt=i;break; } } } + for (int i=1;i<=nonamecnt;++i)if (noname[i].Exist())noname[i].Process(); } -*/ diff --git a/libcgh.h b/libcgh.h index 54c1209..15a6979 100644 --- a/libcgh.h +++ b/libcgh.h @@ -1,7 +1,7 @@ //Chrisoft Bullet Lab Remix HGE //Chrisoft Game Helper header //Copyright Chrisoft 2014 -//libcgh version 0003 +//libcgh version 0004 //^Modify that when big change is made^ #include #include @@ -33,6 +33,18 @@ struct vector2d { return vector2d(a.x+b.x,a.y+b.y); } + friend double operator |(vector2d a,vector2d b)//dot product + { + return a.x*b.x+a.y*b.y; + } + friend double operator *(vector2d a,vector2d b)//length of cross product + { + return a.x*b.y-b.x*a.y; + } + friend vector2d operator *(double a,vector2d b) + { + return vector2d(b.x*a,b.y*a); + } }; inline vector2d ToUnitCircle(vector2d input) { @@ -45,6 +57,16 @@ inline double GetDist(const vector2d a,const vector2d b) { return sqrtf((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } +inline double GetDistSeg(const vector2d a,const vector2d b,const vector2d c) +{ + double l2=GetDist(a,b)*GetDist(a,b); + if (l2==0.0)return GetDist(c,a); + double t=((c-a)|(b-a))/l2; + if (t<0)return GetDist(c,a); + else if (t>1)return GetDist(c,b); + vector2d projection=a+t*(b-a); + return GetDist(c,projection); +} inline double normalizerad(double a) { while (a<0)a+=2*pi; diff --git a/main.cpp b/main.cpp index 94b90e6..4541606 100644 --- a/main.cpp +++ b/main.cpp @@ -442,6 +442,10 @@ void CallLevels() 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==7&&part==27)Level7Part27(); + if (level==7&&part==28)Level7Part28(); if (level==1&&part==5)level=2,part=0; if (level==2&&part==10)level=3,part=0; if (level==3&&part==7)level=4,part=0; @@ -596,7 +600,6 @@ bool FrameFunc() case 255:ProcessBullet255(i);break; } } - for (int i=1;i<=nonamecnt;++i)if (noname[i].Exist())noname[i].Process(); ProcessPlayer(); RefreshScore(); { diff --git a/towernbullet.h b/towernbullet.h index 854d161..1440bc1 100644 --- a/towernbullet.h +++ b/towernbullet.h @@ -1404,40 +1404,12 @@ public: //Initalize: 999'99.9'999 for (int i=0;i0&&xbul.bulletspeedTimer_GetFPS()); + if (xbul.bulletaccel<0&&xbul.bulletspeed>xbul.limv)xbul.bulletspeed+=xbul.bulletaccel*(1000.0f/hge->Timer_GetFPS()); xbul.bulletpos.x-=xbul.bulletspeed*(xbul.bulletdir.x/xbul.dist)/20*(1000.0f/hge->Timer_GetFPS()); xbul.bulletpos.y-=xbul.bulletspeed*(xbul.bulletdir.y/xbul.dist)/20*(1000.0f/hge->Timer_GetFPS()); double dis=GetDist(xbul.bulletpos,playerpos); - if (dis<=6&&clrrange<1e-5&&clrrad-pi/2<1e-7&&colchk) + if (dis<=6&&clrrange<1e-5&&clrrad-pi/2<1e-7&&colchk&&xbul.collable) { - ++coll,scminus+=10000,Mult_BatClear(); + ++coll,scminus+=10000,Mult_BatClear();xbul.collable=false; return; } if (dis<=16&&xbul.scollable)++semicoll,++dsmc,xbul.scollable=false,SCEffect_Attatch(); @@ -1521,8 +1494,8 @@ public: untitledlas.Init(); this->x=x,this->y=2;color=_color; CreateBullet2(untitledbul,x,2,0,3*pi/2); - untitledbul.bulletaccel=0.0001; - untitledbul.limv=1; + untitledbul.bulletaccel=0.0005; + untitledbul.limv=2;untitledbul.collable=true; las=false; reverse=false; done=false; @@ -1540,7 +1513,7 @@ public: ProcessBullet2(untitledbul),x=untitledbul.bulletpos.x,y=untitledbul.bulletpos.y; else untitledlas.EnableColl=true, - untitledlas.Process(); + untitledlas.Process();//printf("%lf\n",untitledlas.GetDist()); if (!untitledbul.exist)y=-1; if (y>pos&&!done&&!las) { @@ -1571,17 +1544,18 @@ public: } if (las) { - untitledlas.RenCtr=vector2d(x,y); - untitledlas.Render(); + untitledlas.RenCtr=vector2d(x+7.2,y+7.2); + untitledlas.Render();untitledlas.EnableColl=true; + untitledlas.Process();printf("%lf\n",untitledlas.GetDist()); if (!reverse) { - if (range1=r1lim&&range2Timer_GetFPS()),range2=range1; + if (range1>=r1lim&&range2Timer_GetFPS()); if (range2>=r2lim)reverse=true; } else { - if (range2>=r1lim)range2-=0.1;else range1-=0.2,range2=range1; + if (range2>=r1lim)range2-=0.1*(1000.0/hge->Timer_GetFPS());else range1-=0.2*(1000.0/hge->Timer_GetFPS()),range2=range1; if (range1<=2)las=false,done=true; } for (int i=0;i<60;++i) @@ -1846,6 +1820,114 @@ public: if (OutOfBound())active=false; } }; +class BTail +{ +//devide the screen into a 16*12 matrix, put random colored bullets, arranged +//in the shape of the snake, on to it. +//^Maybe this description is too bad to understand. See the code. +//Partly based on class WOP +private: + class Pile + { + private: + Bullet* pb[200]; + int matrixx,matrixy,progress,cnt; + double brk;TColors color; + public: + int getProgress(){return progress;} + void create(int _x,int _y,TColors _col) + { + matrixx=_x;matrixy=_y;color=_col; + progress=1;cnt=0; + } + void update() + { + if(!progress)return; + if(progress<10) + { + brk+=hge->Timer_GetDelta(); + if(brk>0.03) + { + brk=0;if(progress++>5)return (void)(progress=10); + for(int i=0;i<10;++i) + { + vector2d ran=vector2d(rand()%50+matrixx*50,rand()%50+matrixy*50); + pb[cnt++]=&bullet[CreateBullet2(ran.x,ran.y,0,0,true)]; + pb[cnt-1]->alterColor=color; + } + } + } + else + { + brk+=hge->Timer_GetDelta(); + if(brk>0.03) + { + bool alldone=true; + for(int i=0;ilifetime>1) + { + BulletEffect_Death(*pb[i],ColorToDWORD(color)); + pb[i]->exist=false;pb[i]=0; + } + else alldone=false; + } + } + if(alldone)progress=0; + } + } + } + }; + Pile piles[30]; + bool tactive; + int listx[30],listy[30],cnt; + TColors pcolor; + bool check(int x,int y) + { + if(x<0||x>15)return false; + if(y<0||y>12)return false; + for(int i=0;i