aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/bullet.cpp40
-rw-r--r--src/core/bullet.hpp7
-rw-r--r--src/core/fncmodules.cpp12
-rw-r--r--src/core/player.cpp4
-rw-r--r--src/core/player.hpp4
-rw-r--r--src/core/scriptshared.hpp18
-rw-r--r--src/core/vmrunner.cpp3
-rw-r--r--src/core/vmrunner.hpp15
8 files changed, 32 insertions, 71 deletions
diff --git a/src/core/bullet.cpp b/src/core/bullet.cpp
index c8cb50f..e016300 100644
--- a/src/core/bullet.cpp
+++ b/src/core/bullet.cpp
@@ -42,48 +42,8 @@ void bulletManager::deinit()
for(int i=0;i<(int)COLOR_COUNT;++i)
{delete bulent2d[i];delete bulent3d[i];}
}
-/*template<class T>
-int bulletManager::allocBullet()
-{
- if(!alloced)
- {
- alloced=1;
- bullets[0]=new T;
- return 0;
- }
- else
- {
- int i;
- for(i=0;i<alloced;++i)
- if(!bullets[i]->exist)break;
- if(i==alloced)
- bullets[alloced++]=new T;
- return i;
- }
- return -1;
-}
-template<class T>
-int bulletManager::createBullet()
-{
- //stub...
- int ptr=allocBullet<T>();
- bullets[ptr]->init();
- return ptr;
-}*/
void bulletManager::updateBullet()
{
- /*static int b=0;
- ++b;
- if(b>15)
- {
- int a=createBullet<bulletBase>();
- bulletBase* x=getHandle(a);
- x->pos=smvec2d(400,300);
- x->vel=smvec2d(rand()%100-50,rand()%100-50);
- x->vel.normalize();
- x->rendercolor=0xC0FFFFFF;
- b=0;
- }*/
for(int i=0;i<alloced;++i)
if(bullets[i]->exist)
bullets[i]->update();
diff --git a/src/core/bullet.hpp b/src/core/bullet.hpp
index e3dc8fe..f3dd9f2 100644
--- a/src/core/bullet.hpp
+++ b/src/core/bullet.hpp
@@ -7,16 +7,17 @@ class bulletBase
{
public:
smvec2d pos,vel,acc;
- float velim;
+ double velim;
//velim: velocity scalar limit.
- float collrange,scollrange,renderscale;
+ double collrange,scollrange;
+ float renderscale;
//collision range and semi-collision range. Replacing "collable" and "scollable".
bool extborder,invincible;
//extborder: true=not removed if out of screen.
//invincible: true=not removed if collided with player or in range of CLR.
bool exist,addblend;
int attrd[8];
- float attrf[8];
+ double attrf[8];
TColors basecolor;
DWORD rendercolor;
virtual void init(...);
diff --git a/src/core/fncmodules.cpp b/src/core/fncmodules.cpp
index 08747c8..767556e 100644
--- a/src/core/fncmodules.cpp
+++ b/src/core/fncmodules.cpp
@@ -6,7 +6,7 @@ Idata randr()
{
Idata ret;ret.type=1;
extern blrScriptVM *vm;
- ret.r()=(float)vm->re->nextDouble((float&)callStk.pop().r(),(float&)callStk.pop().r());
+ ret.r()=(float)vm->re->nextDouble(callStk.pop().r(),callStk.pop().r());
return ret;
}
Idata randi()
@@ -18,18 +18,18 @@ Idata randi()
}
Idata createBullet()
{
- float x,y,bs,rad;
- rad=callStk.pop().r();
- bs=callStk.pop().r();
- y=callStk.pop().r();
+ double x,y,bs,rad;
x=callStk.pop().r();
+ y=callStk.pop().r();
+ bs=callStk.pop().r();
+ rad=callStk.pop().r();
extern bulletManager *bmInstance;
int i=bmInstance->createBullet<bulletBase>();
bmInstance->getHandle(i)->pos.x=x;
bmInstance->getHandle(i)->pos.y=y;
bmInstance->getHandle(i)->vel=bs*smvec2d(cos(rad),sin(rad));
bmInstance->getHandle(i)->acc=smvec2d(0,0);
- bmInstance->getHandle(i)->basecolor=blue;
+ bmInstance->getHandle(i)->basecolor=cyan;
bmInstance->getHandle(i)->rendercolor=0xC0FFFFFF;
bmInstance->getHandle(i)->collrange=4;
bmInstance->getHandle(i)->scollrange=16;
diff --git a/src/core/player.cpp b/src/core/player.cpp
index 3407a0c..794bb5a 100644
--- a/src/core/player.cpp
+++ b/src/core/player.cpp
@@ -2,7 +2,7 @@
#include "player.hpp"
#include "../master/resources.hpp"
SMELT* playerBase::sm=NULL;
-playerBase::playerBase(float _x,float _y)
+playerBase::playerBase(double _x,double _y)
{
sm=smGetInterface(SMELT_APILEVEL);
playerent=new smEntity2D(ssanm.getTextureInfo("player")->tex,ssanm.getTextureInfo("player")->rect);
@@ -20,7 +20,7 @@ playerBase::~playerBase()
void playerBase::update()
{
//player control...
- static float realspeed=0;
+ static double realspeed=0;
if(sm->smGetKeyState(plyrctl[4]))
realspeed=0.85;else realspeed=3.5;
if(sm->smGetKeyState(plyrctl[0]))
diff --git a/src/core/player.hpp b/src/core/player.hpp
index 408c174..51f4c79 100644
--- a/src/core/player.hpp
+++ b/src/core/player.hpp
@@ -9,10 +9,10 @@ private:
static SMELT* sm;
public:
smvec2d pos;
- float rot,vel,velp;
+ double rot,vel,velp;
int plyrctl[6];
- playerBase(float _x=400,float _y=400);
+ playerBase(double _x=400,double _y=400);
~playerBase();
void update();
void render();
diff --git a/src/core/scriptshared.hpp b/src/core/scriptshared.hpp
index 01d423a..65c02bc 100644
--- a/src/core/scriptshared.hpp
+++ b/src/core/scriptshared.hpp
@@ -3,28 +3,28 @@
#include <cmath>
#define eps 1e-6
typedef union _Udata{//data union
- int i;float r;unsigned long d;
+ int i;double r;unsigned long d;
_Udata(){d=0;}
}Udata;
typedef struct _Idata{//data union, with type tag and operators
_Udata D;
- int type;//0=int, 1=float
+ int type;//0=int, 1=double
_Idata(){D.d=0;type=0;}
_Idata(int _type,int _data)
- {type=_type;if(type==0)D.i=_data;else D.r=(float)_data;}
- float &r(){return D.r;}
+ {type=_type;if(type==0)D.i=_data;else D.r=(double)_data;}
+ double &r(){return D.r;}
int &i(){return D.i;}
unsigned long &d(){return D.d;}
_Idata operator =(_Idata r)
{
- if(type==1&&r.type==0)this->r()=(float)r.i();
+ if(type==1&&r.type==0)this->r()=(double)r.i();
else if(type==0&&r.type==1)this->i()=(int)r.r();
else this->d()=r.d();
return *this;
}
_Idata operator +=(_Idata r)
{
- if(type==1&&r.type==0)this->r()+=(float)r.i();
+ if(type==1&&r.type==0)this->r()+=(double)r.i();
if(type==0&&r.type==1)this->i()+=(int)r.r();
if(type==0&&r.type==0)this->i()+=r.i();
if(type==1&&r.type==1)this->r()+=r.r();
@@ -32,7 +32,7 @@ typedef struct _Idata{//data union, with type tag and operators
}
_Idata operator -=(_Idata r)
{
- if(type==1&&r.type==0)this->r()-=(float)r.i();
+ if(type==1&&r.type==0)this->r()-=(double)r.i();
if(type==0&&r.type==1)this->i()-=(int)r.r();
if(type==0&&r.type==0)this->i()-=r.i();
if(type==1&&r.type==1)this->r()-=r.r();
@@ -40,7 +40,7 @@ typedef struct _Idata{//data union, with type tag and operators
}
_Idata operator *=(_Idata r)
{
- if(type==1&&r.type==0)this->r()*=(float)r.i();
+ if(type==1&&r.type==0)this->r()*=(double)r.i();
if(type==0&&r.type==1)this->i()*=(int)r.r();
if(type==0&&r.type==0)this->i()*=r.i();
if(type==1&&r.type==1)this->r()*=r.r();
@@ -48,7 +48,7 @@ typedef struct _Idata{//data union, with type tag and operators
}
_Idata operator /=(_Idata r)
{
- if(type==1&&r.type==0)this->r()/=(float)r.i();
+ if(type==1&&r.type==0)this->r()/=(double)r.i();
if(type==0&&r.type==1)this->i()/=(int)r.r();
if(type==0&&r.type==0)this->i()/=r.i();
if(type==1&&r.type==1)this->r()/=r.r();
diff --git a/src/core/vmrunner.cpp b/src/core/vmrunner.cpp
index fb4c5e6..9df68a0 100644
--- a/src/core/vmrunner.cpp
+++ b/src/core/vmrunner.cpp
@@ -53,7 +53,8 @@ void blrScriptVM::readPara(SPara *para)
int l=0;
switch(para->type)
{
- case 0: case 1: case 4: case 5: l=4;break;
+ case 1: l=8;break;
+ case 0: case 4: case 5: l=4;break;
case 2: case 3: case 6: case 7: l=1;break;
default: break;
}
diff --git a/src/core/vmrunner.hpp b/src/core/vmrunner.hpp
index ee03385..d0e9af5 100644
--- a/src/core/vmrunner.hpp
+++ b/src/core/vmrunner.hpp
@@ -7,20 +7,19 @@
const Idata ione=Idata(0,1),izero=Idata(0,0);
const Idata rone=Idata(1,1),rzero=Idata(1,0);
template<class memb>
-class callStack//a queue, in fact.
+class callStack
{
private:
- int l,r;
+ int t;
memb data[16];
public:
callStack(){clear();}
- void clear(){l=0;r=-1;}
- int size(){return r-l+1;}
+ void clear(){t=-1;}
+ int size(){return t+1;}
bool empty(){return size()==0;}
- void push(memb a){memcpy(data+(++r),&a,sizeof(a));if(r>15)throw;}
- memb pop(){if(l<=r+1)return data[l++];else throw;}
- memb front(){return data[l];}
- memb back(){return data[r];}
+ void push(memb a){memcpy(data+(++t),&a,sizeof(a));if(t>15)throw;}
+ memb pop(){if(~t)return data[t--];else throw;}
+ memb top(){if(~t)return data[t];else throw;}
};
typedef struct _fncEntry{int hash,pos;}fncEntry;
class blrScriptVM