I'm currently doing some tests in order to add scripting capabilities to the game (or even maybe the engine) throught chaiscript (
http://chaiscript.com/).
for the moment bullet behavior is defined at compile time :
void Bullet::renderLogic()
{
if(!collision())
{
sf::Vector3f pos = myEntity->getPosition();
myEntity->setPosition(pos.x+(speed.x*(myInterpolation)),
pos.y+(speed.y*(myInterpolation)));
}
else
{
unregister();
}
}
But now i'm able to write :
void Bullet::renderLogic()
{
chai.eval_file("bullet.chai");
}
And edit the bullet.chai as follow :
if(!this.collision())
{
myEntity.setPosition(posX+(speedX*(myInterpolation)),
posY+(speedY*(myInterpolation)));
}
else
{
this.unregister();
}
Providing the binding information :
chai.add(chaiscript::var(this),"this");
chai.add(chaiscript::fun(&Bullet::collision),"collision");
chai.add(chaiscript::var(myEntity),"myEntity");
chai.add(chaiscript::var(&myInterpolation),"myInterpolation");
chai.add(chaiscript::fun(&se::Entity::setPosition),"setPosition");
chai.add(chaiscript::var(&speed.x),"speedX");
chai.add(chaiscript::var(&speed.y),"speedY");
chai.add(chaiscript::fun(&se::Entity::getPosition),"getPosition");
chai.add(chaiscript::var(&myEntity->getPosition().x),"posX");
chai.add(chaiscript::var(&myEntity->getPosition().y),"posY");
chai.add(chaiscript::fun<void (Bullet::*) ()>(&Bullet::unregister),"unregister");