diff options
author | Chris Xiong <chirs241097@gmail.com> | 2015-10-10 23:25:14 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2015-10-10 23:25:14 +0800 |
commit | f54345e4fc889471513cba99151a5e6a2dcef2d8 (patch) | |
tree | 0751093de4a8656ae24b139bf669f3f0a78ea417 /src/core | |
parent | c108631ffb580cfed1e92b1a0713e11d8dcbdddd (diff) | |
download | bullet-lab-remix-f54345e4fc889471513cba99151a5e6a2dcef2d8.tar.xz |
This fixed yesterday's problem...
In fact there was no object slicing, but it was due to my laziness...
I reused the code from BLR2 in bullet.hpp and there was no inheritance in BLR2...
Also start the implementation of the plugin system.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/bullet.cpp | 15 | ||||
-rw-r--r-- | src/core/bullet.hpp | 5 | ||||
-rw-r--r-- | src/core/player.cpp | 2 |
3 files changed, 15 insertions, 7 deletions
diff --git a/src/core/bullet.cpp b/src/core/bullet.cpp index 8fdaa99..7a5682b 100644 --- a/src/core/bullet.cpp +++ b/src/core/bullet.cpp @@ -30,18 +30,20 @@ void bulletBonus::init(char fstarg,...) pos.x=va_arg(val,double); pos.y=va_arg(val,double); basecolor=grey;rendercolor=0x33FFFFFF; - va_end(val);renderscale=0.5; + va_end(val);renderscale=0.8; attrf[0]=0;attrd[0]=0;exist=special=true; - vel.x=0;vel.y=-2;acc.x=0;acc.y=0.1; + vel.x=0;vel.y=2;acc.x=0;acc.y=-0.1; } void bulletBonus::update() { - //the player is not implemented yet... - if(vel.y>0)attrd[0]=1,acc=smvec2d(0,0); + bulletBase::update(); + if((pos-player->pos).l()<9) exist=false; + + if(vel.y<0&&!attrd[0])attrd[0]=1,acc=smvec2d(0,0); if(attrd[0]) { if(attrf[0]<10)attrf[0]+=.5;else attrf[0]=10.1; - vel=vel-player->pos; + vel=pos-player->pos; vel.normalize(); vel=attrf[0]*vel; } @@ -70,8 +72,9 @@ void bulletManager::updateBullet() if(bullets[i]->exist&&!bullets[i]->special) { bullets[i]->exist=false; + smvec2d p=bullets[i]->pos; int ptr=allocBullet<bulletBonus>(); - bullets[ptr]->init(0,bullets[i]->vel.x,bullets[i]->vel.y); + bullets[ptr]->init(0,p.x,p.y); } for(int i=0;i<alloced;++i) if(bullets[i]->exist) diff --git a/src/core/bullet.hpp b/src/core/bullet.hpp index d8f275e..afba038 100644 --- a/src/core/bullet.hpp +++ b/src/core/bullet.hpp @@ -56,6 +56,11 @@ public: if(!bullets[i]->exist)break; if(i==alloced) bullets[alloced++]=new T; + else + { + delete bullets[i]; + bullets[i]=new T; + } return i; } return -1; diff --git a/src/core/player.cpp b/src/core/player.cpp index 794bb5a..5cbc47e 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -35,6 +35,6 @@ void playerBase::update() } void playerBase::render() { - playerent->render(pos.x,pos.y,rot,0.7); + playerent->render(pos.x+8.4,pos.y+8.4,rot,0.7); } playerBase* player; |