aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2015-10-12 22:55:41 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2015-10-12 22:55:41 +0800
commit9b5621bda033c2e6b7c622c7494c56a172543554 (patch)
treef5fd661441867ca8a100d5c8aedcce430864d9d4
parent627d814f487ac38d4f9b9b71da9bef46f33b3dad (diff)
downloadbullet-lab-remix-9b5621bda033c2e6b7c622c7494c56a172543554.tar.xz
Initial implementation of smPath.
Minor changes on the (s)coll effect.
-rw-r--r--extensions/smpath.cpp13
-rw-r--r--include/smpath.hpp46
-rw-r--r--src/core/bullet.cpp12
-rw-r--r--src/core/bullet.hpp2
-rw-r--r--src/makefile4
-rw-r--r--src/plugin/pluginmgr_dl.cpp7
6 files changed, 75 insertions, 9 deletions
diff --git a/extensions/smpath.cpp b/extensions/smpath.cpp
new file mode 100644
index 0000000..d86e18b
--- /dev/null
+++ b/extensions/smpath.cpp
@@ -0,0 +1,13 @@
+#include <cmath>
+#include "smpath.hpp"
+smPathSegment::smPathSegment(smvec2d _a,smvec2d _b){a=_a,b=_b;}
+smvec2d smPathSegment::getPointOnPath(double percentage)
+{return a+percentage*(b-a);}
+double smPathSegment::getPathLength()
+{return (a-b).l();}
+smPathCircular::smPathCircular(smvec2d _ctr,double _a,double _b,double _r)
+{ctr=_ctr,a=_a,b=_b,r=_r;}
+smvec2d smPathCircular::getPointOnPath(double percentage)
+{return smvec2d(ctr.x+r*cos(a+percentage*(b-a)),ctr.y+r*sin(a+percentage*(b-a)));}
+double smPathCircular::getPathLength()
+{return fabs(a-b)*r;}
diff --git a/include/smpath.hpp b/include/smpath.hpp
new file mode 100644
index 0000000..48bb930
--- /dev/null
+++ b/include/smpath.hpp
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+/*
+ * Simple MultimEdia LiTerator(SMELT)
+ * by Chris Xiong 2015
+ * Path/Curve header & implementation
+ *
+ * WARNING: This library is in development and interfaces would be very
+ * unstable.
+ *
+ */
+#ifndef SMPATH_H
+#define SMPATH_H
+#include "smmath.hpp"
+class smPathBase
+{
+public:
+ virtual smvec2d getPointOnPath(double percentage);
+ virtual double getPathLength();
+ virtual ~smPathBase(){};
+};
+class smPathSegment:public smPathBase
+{
+private:
+ smvec2d a,b;
+public:
+ smPathSegment(smvec2d _a,smvec2d _b);
+ smvec2d getPointOnPath(double percentage);
+ double getPathLength();
+};
+class smPathCircular:public smPathBase
+{
+private:
+ smvec2d ctr;
+ double a,b,r;
+public:
+ smPathCircular(smvec2d _ctr,double _a,double _b,double _r);
+ smvec2d getPointOnPath(double percentage);
+ double getPathLength();
+};
+class smPathCollection
+{
+private:
+ smPathBase* paths[16];
+public:
+};
+#endif
diff --git a/src/core/bullet.cpp b/src/core/bullet.cpp
index ddbf964..15cfef0 100644
--- a/src/core/bullet.cpp
+++ b/src/core/bullet.cpp
@@ -23,13 +23,13 @@ void bulletBase::update()
if((pos-player->pos).l()>collrange)if(invincible)ccb=cb;
if((pos-player->pos).l()<=scollrange&&(pos-player->pos).l()>collrange)
{
- if(!invincible)scollrange=-1,++player->scoll,bmInstance->addFXBullet(grey);
- else{if(++cscb>scb)cscb=0,++player->scoll,bmInstance->addFXBullet(grey);}
+ if(!invincible)scollrange=-1,++player->scoll,bmInstance->addFXBullet(grey,5,5);
+ else{if(++cscb>scb)cscb=0,++player->scoll,bmInstance->addFXBullet(grey,5,5);}
}
if((pos-player->pos).l()<=collrange)
{
- if(!invincible)exist=false,++player->coll,bmInstance->addFXBullet(red);
- else{if(++ccb>cb)ccb=0,++player->coll,bmInstance->addFXBullet(red);}
+ if(!invincible)exist=false,++player->coll,bmInstance->addFXBullet(red,15,15);
+ else{if(++ccb>cb)ccb=0,++player->coll,bmInstance->addFXBullet(red,15,15);}
}
}
void bulletBase::render()
@@ -123,9 +123,9 @@ void bulletManager::renderBullet()
bullets[i]->render();
}
}
-void bulletManager::addFXBullet(TColors col)
+void bulletManager::addFXBullet(TColors col,int base,int var)
{
- int c=rand()%5+5;
+ int c=rand()%var+base;
for(int i=0;i<c;++i)
bullets[allocBullet<bulletFX>()]->init(0,col);
}
diff --git a/src/core/bullet.hpp b/src/core/bullet.hpp
index a917b95..244e944 100644
--- a/src/core/bullet.hpp
+++ b/src/core/bullet.hpp
@@ -80,7 +80,7 @@ public:
}
void updateBullet();
void renderBullet();
- void addFXBullet(TColors col);
+ void addFXBullet(TColors col,int base,int var);
bulletBase* getHandle(int id);
smEntity2D* getBulEntity2D(TColors col);
smEntity3D* getBulEntity3D(TColors col);
diff --git a/src/makefile b/src/makefile
index 57d9356..560f68c 100644
--- a/src/makefile
+++ b/src/makefile
@@ -1,6 +1,6 @@
CC= g++
-CXXFLAGS= -std=c++11 -Wall -g -I/home/chrisoft/devel/BulletLabRemixIII/include
-LINK= -L../smelt/sdl -L../extensions -lsmeltext -lsmelt -lCxImage -lSDL2 -lvorbis -lvorbisfile -lopenal -ljpeg -lpng -lfreetype -lz -pthread
+CXXFLAGS= -std=c++11 -Wall -g -I/home/chrisoft/devel/BulletLabRemixIII/include -I/usr/include/freetype2
+LINK= -L../smelt/sdl -L../extensions -lsmeltext -lsmelt -lCxImage -lSDL2 -lvorbis -lvorbisfile -lopenal -ljpeg -lpng -lfreetype -lm -lz -ldl -pthread
all: main
diff --git a/src/plugin/pluginmgr_dl.cpp b/src/plugin/pluginmgr_dl.cpp
index 337fa99..f6b4ef3 100644
--- a/src/plugin/pluginmgr_dl.cpp
+++ b/src/plugin/pluginmgr_dl.cpp
@@ -18,4 +18,11 @@ void pluginManager::scanPlugin()
strcpy(fn[fcnt++],file->d_name);
closedir(dir);
}
+ for(int i=0;i<fcnt;++i)
+ {
+ void* hso=dlopen(fn[i],RTLD_LAZY);
+ if(!hso)continue;
+ void* hndi=dlsym(hso,"getPluginInterface");
+ if(!hndi)continue;
+ }
}