• Advertisement
  • entries
    437
  • comments
    1000
  • views
    336530

Something, Something, Nothing

Sign in to follow this  

117 views

I've not updated for a while. I have been developing, but also been applying for the job. I hate the questions they ask, you can answer them in so many ways and you're never quite sure if you hit the nail on the head.

I've been coding up my GameMonkey binding class template. It's pretty easy to port a native C++ object to GM now.

Example:


// Native class
class Bomb
{
public:
Bomb();
void Explode();
bool isExploded;
};



// Proxy class
class gmBomb : public gmObjectT< Bomb, gmBomb >,
public Bomb
{
public:

GMOBJECT_DECLARE_FUNCTIONS( gmBomb );
GMOBJECT_DECLARE_PROPERTIES( gmBomb );

static bomb *constructor()
{
bomb *p = new bomb();
return p;
}

static int gmExplode(gmThread * a_thread)
{
bomb* p = (bomb*)a_thread->ThisUser_NoChecks();
p->explode();
return GM_OK;
}

static bool getExploded( bomb *p, gmThread * a_thread, gmVariable * a_operands )
{
a_operands[0].m_value.m_int = (int)p->isExploded;
return true;
}

static bool setExploded( bomb *p, gmThread * a_thread, gmVariable * a_operands )
{
p->isExploded = (bool)a_operands[1].m_value.m_int;
return true;
}

};

GMOBJECT_INIT_TYPE( gmBomb, "bomb" );
GMOBJECT_FUNCTION_MAP_BEGIN( gmBomb )
GMOBJECT_FUNCTION( "explode", gmExplode )
GMOBJECT_FUNCTION_MAP_END();
GMOBJECT_PROPERTY_MAP_BEGIN( gmBomb )
GMOBJECT_PROPERTY( "exploded", getExploded, setExploded )
GMOBJECT_PROPERTY_MAP_END();





// Using the class
int main()
{
gmMachine *gm = new gmMachine();
gmBomb::initialise( gm );
// Run a demo script
int r = gm->ExecuteString("b = bomb(); b.explode(); b.explode(); b.exploded = 0; b.explode();");
gm->CollectGarbage( true );

return 0;
}



Usage is pretty straight forward and it has many overridable properties. I'm hoping to submit it to the GameMonkey library when it's polished up a bit.

Other than that, I've been coding a Neural Network for fun. It's not quite working as I expected, but then they never do, do they? I wonder what happens if you use the outputs of one net as the inputs of other nets. I guess that's when you start modelling the brain more accurately [grin].

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement