summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xCHANGELOG.TXT11
-rwxr-xr-xVERSION.TXT2
-rw-r--r--global.h51
-rw-r--r--levels.h133
-rw-r--r--libcgh.h24
-rw-r--r--main.cpp5
-rw-r--r--towernbullet.h172
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 (frameleft<ThirtySeconds)
- {
- tower[1].exp2=60;
- tower[1].towertimer=300;
- tower[1].bulletspeed=3;
- }
- if (frameleft<TwentySeconds)
- {
- tower[1].exp2=72;
- }
- if (frameleft<TenSeconds)
- {
- tower[1].exp2=108;
- tower[1].towertimer=200;
- }
-}
-void Level1Part21()//Minesweeper?-
+void Level7Part27()//Minesweeper?-
{
- frameleft=ThirtySeconds;
+ frameleft=AMinute;
if (bulcnt!=0)return (void)ClearAll();
Lasercnt=0;
++part;
}
-void Level1Part22()//Minesweeper?-child
+void Level7Part28()//Minesweeper?-child
{
- if (rand()%100>98)
+ 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 (frameleft<TenSeconds)
- noname[i].Init(rand()%800,4,100,150,70);
+ noname[i].Init(rand()%800,4,100,150,70,0x8033CCFF);
else if (frameleft<TwentySeconds)
- noname[i].Init(rand()%800,4,100,150,75);
- else noname[i].Init(rand()%800,4,100,150,80);
+ noname[i].Init(rand()%800,4,100,150,75,0x8033CCFF);
+ else noname[i].Init(rand()%800,4,100,150,80,0x8033CCFF);
if (i>nonamecnt)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 <hge.h>
#include <hgefont.h>
@@ -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;i<Res-1;++i)
{
- hgeRect box;memset(&box,0,sizeof(box));
- box.x1=box.x2=data1[i].x+RenCtr.x,box.y1=box.y2=data1[i].y+RenCtr.y;
- //box.Encapsulate(data1[i].x+RenCtr.x,data1[i].y+RenCtr.y);
- box.Encapsulate(data1[i+1].x+RenCtr.x,data1[i+1].y+RenCtr.y);
- box.Encapsulate(data2[i].x+RenCtr.x,data2[i].y+RenCtr.y);
- box.Encapsulate(data2[i+1].x+RenCtr.x,data2[i+1].y+RenCtr.y);
- {
- //Debugging collision box
- hgeSprite colbox=*(new hgeSprite(0,0,0,0,0));
- colbox.SetColor(0x20FFFFFF);
- colbox.RenderStretch(box.x1,box.y1,box.x2,box.y2);
- }
- if (box.TestPoint(playerpos.x,playerpos.y))
- {
- double dx=data1[i].x-data1[i+1].x,dy=data1[i].y-data1[i+1].y;
- double a,b,c;
- if (abs(dx)<1e-4)
- {
- a=1;b=0;c=data1[i].x+RenCtr.x;
- }
- else
- {
- b=1;a=-dy/dx;c=(data1[i].x+RenCtr.x)*a-data1[i].y-RenCtr.y;
- }
- tres=abs(a*playerpos.x+b*playerpos.y+c)/sqrt(sqr(a)+sqr(b));
- }
- else
- {
- vector2d t0=data1[i];data1[i].x+=RenCtr.x,data1[i].y+=RenCtr.y;
- tres=::GetDist(playerpos,t0);
- vector2d t1=data1[i+1];data1[i+1].x+=RenCtr.x,data1[i+1].y+=RenCtr.y;
- tres=tres<(::GetDist(playerpos,t1))?tres:(::GetDist(playerpos,t1));
- data1[i]=t0;data1[i+1]=t1;
- }
+ vector2d sa,sb;
+ sa=data1[i]+RenCtr;sb=data1[i+1]+RenCtr;
+ tres=GetDistSeg(sa,sb,playerpos);
+ sa=data2[i]+RenCtr;sb=data2[i+1]+RenCtr;
+ if(GetDistSeg(sa,sb,playerpos)<tres)
+ tres=GetDistSeg(sa,sb,playerpos);
if (tres<res)res=tres;
}
return res;
@@ -1486,15 +1458,16 @@ void CreateBullet2(Bullet &Tar,double x,double y,double bs,double rad,bool eff=f
}
void ProcessBullet2(Bullet &xbul,bool colchk=true)
{
- if (xbul.bulletspeed<xbul.limv)xbul.bulletspeed+=xbul.bulletaccel;
if (!xbul.exist||xbul.bullettype!=2)return;
if (!xbul.dist)xbul.dist=1;
+ if (xbul.bulletaccel>0&&xbul.bulletspeed<xbul.limv)xbul.bulletspeed+=xbul.bulletaccel*(1000.0f/hge->Timer_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)range1+=0.2,range2=range1;
- if (range1>=r1lim&&range2<r2lim)range2+=0.1;
+ if (range1<r1lim)range1+=0.2*(1000.0/hge->Timer_GetFPS()),range2=range1;
+ if (range1>=r1lim&&range2<r2lim)range2+=0.1*(1000.0/hge->Timer_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;i<cnt;++i)
+ {
+ if(pb[i])
+ {
+ if(pb[i]->lifetime>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<cnt;++i)
+ if(x==listx[i]&&y==listy[i])return false;
+ return true;
+ }
+public:
+ bool isActive(){return tactive;}
+ void Create()
+ {
+ pcolor=(TColors)(rand()%8);tactive=true;
+ cnt=0;memset(listx,0,sizeof(listx));
+ memset(listy,0,sizeof(listy));
+ listx[cnt++]=rand()%16;listy[cnt-1]=rand()%12;
+ piles[cnt-1].create(listx[cnt-1],listy[cnt-1],pcolor);
+ }
+ void Update()
+ {
+ if(piles[cnt-1].getProgress()==10)
+ {
+ int dlx[4],dly[4],dcnt=0;
+ if(check(listx[cnt-1]+1,listy[cnt-1]))
+ dlx[dcnt]=listx[cnt-1]+1,dly[dcnt++]=listy[cnt-1];
+ if(check(listx[cnt-1]-1,listy[cnt-1]))
+ dlx[dcnt]=listx[cnt-1]-1,dly[dcnt++]=listy[cnt-1];
+ if(check(listx[cnt-1],listy[cnt-1]+1))
+ dlx[dcnt]=listx[cnt-1],dly[dcnt++]=listy[cnt-1]+1;
+ if(check(listx[cnt-1],listy[cnt-1]-1))
+ dlx[dcnt]=listx[cnt-1],dly[dcnt++]=listy[cnt-1]-1;
+ if(dcnt&&cnt<30)
+ {
+ int rd=rand()%dcnt;
+ listx[cnt++]=dlx[rd];listy[cnt-1]=dly[rd];
+ piles[cnt-1].create(listx[cnt-1],listy[cnt-1],pcolor);
+ }
+ }
+ bool none=true;
+ for(int i=0;i<30;++i)
+ if(piles[i].getProgress())none=false,piles[i].update();
+ if(none)tactive=false;
+ }
+};
class SimpleThing
{
private: