aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/bullet.cpp15
-rw-r--r--src/core/bullet.hpp5
-rw-r--r--src/core/player.cpp2
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;