From f54345e4fc889471513cba99151a5e6a2dcef2d8 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 10 Oct 2015 23:25:14 +0800 Subject: 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. --- src/core/bullet.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/core/bullet.cpp') 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(); - bullets[ptr]->init(0,bullets[i]->vel.x,bullets[i]->vel.y); + bullets[ptr]->init(0,p.x,p.y); } for(int i=0;iexist) -- cgit v1.2.3