aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2015-10-11 22:04:05 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2015-10-11 22:04:05 +0800
commit627d814f487ac38d4f9b9b71da9bef46f33b3dad (patch)
tree8fe9ffba654b40ede31575874793b735df0fdf2e /src
parentf54345e4fc889471513cba99151a5e6a2dcef2d8 (diff)
downloadbullet-lab-remix-627d814f487ac38d4f9b9b71da9bef46f33b3dad.tar.xz
Implement the collision system and a simple effect.
Fixed a problem that keeps the screen black on start up. Replace the build script in dtputil with makefile. Sync with the newest SMELT revision.
Diffstat (limited to 'src')
-rw-r--r--src/blr3.dtpbin459968 -> 459997 bytes
-rw-r--r--src/core/bullet.cpp53
-rw-r--r--src/core/bullet.hpp11
-rw-r--r--src/core/gamescene.cpp4
-rw-r--r--src/core/player.cpp4
-rw-r--r--src/core/player.hpp2
-rw-r--r--src/master/intro.cpp2
-rw-r--r--src/plugin/pluginmgr_dl.cpp7
8 files changed, 68 insertions, 15 deletions
diff --git a/src/blr3.dtp b/src/blr3.dtp
index bda99d9..58a5de6 100644
--- a/src/blr3.dtp
+++ b/src/blr3.dtp
Binary files differ
diff --git a/src/core/bullet.cpp b/src/core/bullet.cpp
index 7a5682b..ddbf964 100644
--- a/src/core/bullet.cpp
+++ b/src/core/bullet.cpp
@@ -6,7 +6,12 @@
const char* bsnames[]={"green_bullet","cyan_bullet","yellow_bullet","purple_bullet",
"red_bullet","white_bullet","blue_bullet","orange_bullet",
"grey_bullet","circle_bullet"};
-void bulletBase::init(char fstarg,...){++fstarg;exist=true;renderscale=1;special=false;}
+void bulletBase::init(char fstarg,...)
+{
+ ++fstarg;exist=true;renderscale=1;
+ special=invincible=false;scollrange=64;collrange=16;
+ scb=cb=8;
+}
void bulletBase::update()
{
if(!exist)return;
@@ -14,7 +19,18 @@ void bulletBase::update()
if(vel.l()>velim&&velim>0)vel=velim*vel.getNormalized();
pos=pos-vel;
if(!extborder&&(pos.x<-10||pos.y<-10||pos.x>810||pos.y>610))exist=false;
- //check clr & collision
+ if((pos-player->pos).l()>scollrange)if(invincible)cscb=scb;
+ if((pos-player->pos).l()>collrange)if(invincible)ccb=cb;
+ if((pos-player->pos).l()<=scollrange&&(pos-player->pos).l()>collrange)
+ {
+ if(!invincible)scollrange=-1,++player->scoll,bmInstance->addFXBullet(grey);
+ else{if(++cscb>scb)cscb=0,++player->scoll,bmInstance->addFXBullet(grey);}
+ }
+ if((pos-player->pos).l()<=collrange)
+ {
+ if(!invincible)exist=false,++player->coll,bmInstance->addFXBullet(red);
+ else{if(++ccb>cb)ccb=0,++player->coll,bmInstance->addFXBullet(red);}
+ }
}
void bulletBase::render()
{
@@ -36,8 +52,11 @@ void bulletBonus::init(char fstarg,...)
}
void bulletBonus::update()
{
- bulletBase::update();
- if((pos-player->pos).l()<9) exist=false;
+ if(!exist)return;
+ vel=vel+acc;
+ if(vel.l()>velim&&velim>0)vel=velim*vel.getNormalized();
+ pos=pos-vel;
+ if((pos-player->pos).l()<9)exist=false;
if(vel.y<0&&!attrd[0])attrd[0]=1,acc=smvec2d(0,0);
if(attrd[0])
@@ -48,6 +67,23 @@ void bulletBonus::update()
vel=attrf[0]*vel;
}
}
+void bulletFX::init(char fstarg,...)
+{
+ fstarg=0;va_list val;va_start(val,fstarg);
+ pos=player->pos;
+ basecolor=(TColors)va_arg(val,int);
+ rendercolor=0x33FFFFFF;
+ va_end(val);renderscale=0.4;collrange=scollrange=-1;
+ attrf[0]=0;attrd[0]=0;exist=special=invincible=true;
+ vel.x=rand()%1000-500;vel.y=rand()%1000-500;
+ vel=(2+rand()%3+rand()%10/10.)*vel.getNormalized();
+}
+void bulletFX::update()
+{
+ pos=pos-vel;
+ rendercolor=SETA(rendercolor,GETA(rendercolor)-2);
+ if(GETA(rendercolor)<=2)exist=false;
+}
void bulletManager::init()
{
@@ -73,8 +109,7 @@ void bulletManager::updateBullet()
{
bullets[i]->exist=false;
smvec2d p=bullets[i]->pos;
- int ptr=allocBullet<bulletBonus>();
- bullets[ptr]->init(0,p.x,p.y);
+ bullets[allocBullet<bulletBonus>()]->init(0,p.x,p.y);
}
for(int i=0;i<alloced;++i)
if(bullets[i]->exist)
@@ -88,6 +123,12 @@ void bulletManager::renderBullet()
bullets[i]->render();
}
}
+void bulletManager::addFXBullet(TColors col)
+{
+ int c=rand()%5+5;
+ for(int i=0;i<c;++i)
+ bullets[allocBullet<bulletFX>()]->init(0,col);
+}
smEntity2D* bulletManager::getBulEntity2D(TColors col){return bulent2d[col];}
smEntity3D* bulletManager::getBulEntity3D(TColors col){return bulent3d[col];}
bulletBase* bulletManager::getHandle(int id){if(id<alloced)return bullets[id];else return NULL;}
diff --git a/src/core/bullet.hpp b/src/core/bullet.hpp
index afba038..a917b95 100644
--- a/src/core/bullet.hpp
+++ b/src/core/bullet.hpp
@@ -16,8 +16,8 @@ public:
//extborder: true=not removed if out of screen.
//invincible: true=not removed if collided with player or in range of CLR.
bool exist,addblend,special;
- int attrd[8];
- double attrf[8];
+ int attrd[16],scb,cscb,cb,ccb;
+ double attrf[16];
TColors basecolor;
DWORD rendercolor;
virtual void init(char fstarg,...);
@@ -31,6 +31,12 @@ public:
void init(char fstarg,...)override;
void update()override;
};
+class bulletFX:public bulletBase
+{
+public:
+ void init(char fstarg,...)override;
+ void update()override;
+};
class bulletManager
{
private:
@@ -74,6 +80,7 @@ public:
}
void updateBullet();
void renderBullet();
+ void addFXBullet(TColors col);
bulletBase* getHandle(int id);
smEntity2D* getBulEntity2D(TColors col);
smEntity3D* getBulEntity3D(TColors col);
diff --git a/src/core/gamescene.cpp b/src/core/gamescene.cpp
index 32fea88..99f61c3 100644
--- a/src/core/gamescene.cpp
+++ b/src/core/gamescene.cpp
@@ -60,6 +60,10 @@ bool gameScene::sceneRender()
udly+=sm->smGetDelta();
extern sceneManager *sceneMgr;float lps=sceneMgr->getLPS();
if(udly>1){udly=0;utime=sceneMgr->getTHUpdateTime();}
+ ttfont.updateString(L"Coll: %d\n",player->coll);
+ ttfont.render(0,50,0xFFFFFFFF,ALIGN_LEFT);
+ ttfont.updateString(L"SColl: %d\n",player->scoll);
+ ttfont.render(0,65,0xFFFFFFFF,ALIGN_LEFT);
ttfont.updateString(L"LPS: %.2f",lps);
ttfont.render(0,680,0xFFFFFFFF,ALIGN_LEFT);
ttfont.updateString(L"Update Time: %dns",utime);
diff --git a/src/core/player.cpp b/src/core/player.cpp
index 5cbc47e..d461b52 100644
--- a/src/core/player.cpp
+++ b/src/core/player.cpp
@@ -11,7 +11,7 @@ playerBase::playerBase(double _x,double _y)
plyrctl[0]=SMK_UP;plyrctl[1]=SMK_DOWN;
plyrctl[2]=SMK_LEFT;plyrctl[3]=SMK_RIGHT;
plyrctl[4]=SMK_SHIFT;
- rot=0;
+ rot=0;scoll=coll=0;vel=3.5;velp=1.5;
}
playerBase::~playerBase()
{
@@ -22,7 +22,7 @@ void playerBase::update()
//player control...
static double realspeed=0;
if(sm->smGetKeyState(plyrctl[4]))
- realspeed=0.85;else realspeed=3.5;
+ realspeed=velp;else realspeed=vel;
if(sm->smGetKeyState(plyrctl[0]))
{if(pos.y>15)pos.y-=realspeed;else pos.y=15;}
if(sm->smGetKeyState(plyrctl[1]))
diff --git a/src/core/player.hpp b/src/core/player.hpp
index 51f4c79..2580e7a 100644
--- a/src/core/player.hpp
+++ b/src/core/player.hpp
@@ -10,7 +10,7 @@ private:
public:
smvec2d pos;
double rot,vel,velp;
- int plyrctl[6];
+ int plyrctl[6],coll,scoll;
playerBase(double _x=400,double _y=400);
~playerBase();
diff --git a/src/master/intro.cpp b/src/master/intro.cpp
index f8cf46b..1e45ddb 100644
--- a/src/master/intro.cpp
+++ b/src/master/intro.cpp
@@ -182,7 +182,7 @@ introScene::introScene()
sm=smGetInterface(SMELT_APILEVEL);
pos=new smvec2d[1024];vel=new smvec2d[1024];
scale=new float[1024];acc=new smvec2d[1024];
- extern const char* bsnames[];
+ extern const char* bsnames[];delay=0;
smTexInfo *ti=ssanm.getTextureInfo(bsnames[rand()%8]);
blt=new smEntity2D(ti->tex,ti->rect);
blt->setCentre(12,12);
diff --git a/src/plugin/pluginmgr_dl.cpp b/src/plugin/pluginmgr_dl.cpp
index f3ab816..337fa99 100644
--- a/src/plugin/pluginmgr_dl.cpp
+++ b/src/plugin/pluginmgr_dl.cpp
@@ -1,17 +1,18 @@
#include <dlfcn.h>
#include <dirent.h>
+#include <cstring>
#include "pluginmgr.hpp"
pluginManager::pluginManager()
{
- pluginFolder="./plugins";
+ strcpy(pluginFolder,"./plugins");
}
void pluginManager::scanPlugin()
{
DIR *dir;
struct dirent *file;
- if(dir=opendir(pluginFolder))
+ if((dir=opendir(pluginFolder)))
{
- while(file=readdir(dir))
+ while((file=readdir(dir)))
//puts(file->d_name);
if(strcmp(file->d_name+strlen(file->d_name)-3,".so")==0)
strcpy(fn[fcnt++],file->d_name);