diff options
Diffstat (limited to 'src/core/bullet.hpp')
-rw-r--r-- | src/core/bullet.hpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/core/bullet.hpp b/src/core/bullet.hpp index b240e81..e3dc8fe 100644 --- a/src/core/bullet.hpp +++ b/src/core/bullet.hpp @@ -38,8 +38,32 @@ private: public: void init(); void deinit(); - template<class T>int allocBullet(); - template<class T>int createBullet(); + template<class T>int 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 createBullet() + { + //stub... + int ptr=allocBullet<T>(); + bullets[ptr]->init(); + return ptr; + } void updateBullet(); void renderBullet(); bulletBase* getHandle(int id); |