Jump to content

  • Log In with Google      Sign In   
  • Create Account

_orm_

Member Since 16 May 2010
Offline Last Active Jun 12 2013 12:48 PM

#5068022 Monday morning code...

Posted by _orm_ on 07 June 2013 - 08:48 AM

One can never be sure enough! tongue.png

 

Also check if nullptr is actually null.

nullptr is a C++11 keyword that is guaranteed to be null.




#4867688 Solid App for all Game Engines

Posted by _orm_ on 30 September 2011 - 01:00 PM

I think I understand whhat you're saying, and no, I don't know of anything like that. The thing about software is mine is always better than yours or theirs. Everybody touts their own software as being the ultimate solution, so your best bet is to just evaluate everything yourself.


#4859548 How does a game loop work?

Posted by _orm_ on 09 September 2011 - 09:23 AM

Something else you may want to consider as part of your design is passing the time between logic updates to the update function of your game objects.

float logicTime = 1.0f/25 ;// 25 logical ticks per second is really all you will ever need.
float elapsedTime = 0;

while(gamerunning()) 


{
      elapsedTime += TimeBetweenFrames();
 	if(elapsedTime > logicTime)
 	{
        player->Update(elapsedTime); // because the true elapsed time between logical updates can vary, you want the game objects to know about it so they can decide what to do with it.

        elapsedTime = 0;

    }
    player->draw(backBuffer) ;

 }



#4832034 Implementing a map; arrays in arrays?

Posted by _orm_ on 06 July 2011 - 07:17 PM

For associative arrays in my game engine, I have an interface that does not declare any functions called "IObject". In the compiled code I have a thin wrapper around the std::map that takes asIScriptObject as both template parameters. So basically, it allows me to hash any IObject with any other IObject in a similar way to how Java containers work. So far it has worked extremely well, especially for the scripted AI in my game engine.

class CScriptMap
{
public:
    CScriptMap() : m_RefCount(1) {}
    void Insert(asIScriptObject* key,asIScriptObject* value)
    {
        if(Contains(key))
        {
            key->Release();
            value->Release();
            return;
        }
        m_Map[key] = value;
    }

    void Erase(asIScriptObject* key)
    {
        ObjMap::iterator k = m_Map.find(key);

        if(!Contains(key)) { key->Release(); return; }

        asIScriptObject* value = (*k).second;
        m_Map.erase(key); value->Release(); key->Release();
    }

    bool Contains(asIScriptObject* key)
    {
        return m_Map.find(key) != m_Map.end();
    }

    asIScriptObject* Find(asIScriptObject* key)
    {
        if(Contains(key))
        {
            m_Map[key]->AddRef();
            key->Release();
            return m_Map[key];
        }
        key->Release();
        return NULL;
    }

    // I'll get around to implementing these... eventually...
    /*CScriptMapIterator* Begin()
    {
        return new CScriptMapIterator
    }

    CScriptMapIterator* End()
    {
    }*/

    CScriptArray* Keys()
    {
        ObjMap::iterator i = m_Map.begin();
        ObjMap::iterator end = m_Map.end();

        while(i != end)
        {

            i++;
        }
    }

    CScriptArray* Values()
    {
        
    }

    int Size() const { return m_Map.size(); }

    void AddRef(){m_RefCount++;}
    void Release() { if(--m_RefCount == 0) delete this; }


private:
    typedef std::map<asIScriptObject*,asIScriptObject*> ObjMap;
    ObjMap m_Map;
    int m_RefCount;
};

The functions that take an asIScriptObject* as a parameter, or parameters, are registered as taking an IObject@.


#4826411 help with making Angelscript call my entrypoint with an object

Posted by _orm_ on 22 June 2011 - 07:14 AM

If there are multiple instances of the Script class, it may be that the error is in you registering the "Entity" type multiple times, as well as the "World" in RegisterEntity and RegisterWorld. The script engine instance only needs to have types registered to it once, and they are then available globally.

[EDIT]: Sorry about that, just realized that _engine is unique per script. In that case, you have a design issue on your hands, as I can see that being horribly inefficient.

Beside that, I can see you doing some angelscript operations there without checking what is returned. Most Angelscript operations return an int which you can check for errors. I myself have a nice little macro that handles this for me.


#define AS_CHECK(x) \
        if(x<0) \
        { \
            std::cout<<"Angelscript operation failed. File: " \
            <<__FILE__<<" Line: "<<__LINE__<<".\n"; \
            std::cout<<"Operation returned "<<GetErrorString(x)<<"\n"; \
            assert(x>=0); \
        }

GetErrorString is just a function that reads from a hash table stored somewhere in global scope to convert the numerous error codes into a string. It gives me a good indication of what happened and has reduced my debug time by a fair margin.


#4805277 Osama Bin Laden is Dead.

Posted by _orm_ on 01 May 2011 - 10:27 PM

It's been far too long coming. He was a threat not only to America, but to the entire world. If he had succeeded in destroying us, he would have only found someone else to hate. Such was the sorry bastard's mentality.

For freedom, and rest in pieces you sorry sack of ****.

http://www.guardian.co.uk/world/2011/may/02/osama-bin-laden-dead-obama


PARTNERS