Jump to content
  • Advertisement

izackp

Member
  • Content Count

    19
  • Joined

  • Last visited

Everything posted by izackp

  1. izackp

    Banshee Engine Architecture - Introduction

    This is fantastic, I was aiming for a similar goal for a play in editor, but built on top of Urho3d. I had additional goals of my engine being deterministic with mostly automatic networking (All the user would have to do is choose what variables are 'gameplay variables' and then input/events would be synced between clients). Until I realized C++ is an annoying and redundant language, I wanted a clean modular engine built on the best language possible. At which point, I started looking into Scala and other languages.   Nonetheless, I hope your able to get some steam behind your project. Don't be afraid to reiterate unlike most game engines out there. (Don't be afraid to break things)   I will definitely try out your engine once you have C# support integrated.
  2. http://martiancraft.com/blog/2014/08/an-unreal-decision/ ^ read this article   I would say that unreal is (was) designed to make FPS games so I would choose that over unity. However, In other cases, I would choose unity over UE4.
  3. izackp

    Distance formula in c++

    My favorite method for calculating approximate distance: u32 approx_distance( s32 dx, s32 dy ) { u32 min, max, approx; if ( dx < 0 ) dx = -dx; if ( dy < 0 ) dy = -dy; if ( dx < dy ) { min = dx; max = dy; } else { min = dy; max = dx; } approx = ( max * 1007 ) + ( min * 441 ); if ( max < ( min << 4 )) approx -= ( max * 40 ); // add 512 for proper rounding return (( approx + 512 ) >> 10 ); } http://www.flipcode.com/archives/Fast_Approximate_Distance_Functions.shtml   Its useful for pathfinding and AI.. though it might be weird for collision. I recommend storing everything collide-able inside of an array and iterating through them while checking to see if the edges of the objects over lap with each other via box collision or separating axis theorem.    Box Collision: bool DoBoxesIntersect(Box a, Box b) { return (abs(a.x - b.x) * 2 < (a.width + b.width)) && (abs(a.y - b.y) * 2 < (a.height + b.height)); } http://gamedev.stackexchange.com/questions/586/what-is-the-fastest-way-to-work-out-2d-bounding-box-intersection   Separating Axis Theorem: http://www.metanetsoftware.com/technique/tutorialA.html 
  4. izackp

    So... C++14 is done :O

    I'm all for readability more than anything. I wish they would make the language more DRY (Don't repeat yourself).   I'm sick and tired of having to update .h files when changing .cpp files and vice-versa.   Also, class scopes are annoying too. Wouldn't it be simple to do something like: class MyClass { public:     void hello() {     } } instead of: void MyClass::hello() { } MyClass:: is usually everywhere :/
  5. izackp

    College or Solo?

    If you're good enough to intern thats the best thing you can do because you get to focus on programming all day long. It also gives you a chance to work with 'professionals' (occasionally there is the guy who thinks they know what they're doing).   The quickest and maybe the cheapest way is to become friends with someone who is in the industry and knows what they're doing. (or hire a tutor; again make sure they know what they're doing). A lot of teachers don't teach 'clean code' which is the next best thing to learn after syntax.   Which this book goes over: http://books.google.com/books?id=_i6bDeoCQzsC&dq=clean+code&source=gbs_navlinks_s   However, I've also been recommended this book but I have yet to read it: http://books.google.com/books?id=3JfE7TGUwvgC&dq=Code+Complete&hl=en&sa=X&ei=TjfaU6eoOs7NsQTOwYKYBw&ved=0CB4Q6AEwAA   If they know what they're doing then they know about clean code.
  6. I make the game I want to play. Ideas come to me as I play other games. Not only that video games are always on my mind, and I'm very analytical to the current games I play where I notice how different aspects of the game effect me.
  7. izackp

    Entities-Parts I: Game Objects

    Its a good article and describes an interesting architectural design. A lot of entity/component system try to solve the problems that are created from improper use of inheritance. Take a look at this wiki for 'Composition over inheritance' (http://en.wikipedia.org/wiki/Composition_over_inheritance). It should give you a good idea of why many people prefer entity/component systems.   I would also recommend watching videos from Robert C. Martin. He explains a lot of good design concepts when it comes to code architecture (https://www.youtube.com/watch?v=WpkDN78P884).   Edit - I didn't notice it, but madhed already mentioned the relation of entity/components and the inheritance issue. Nonetheless, check out the links its good info.   A side note - There are component systems that are OOP and some procedural (data-driven). OOP competes with procedural.    "Procedural code (code using data structures) makes it easy to add new functions without changing the existing data structures. OO code, on the other hand, makes it easy to add new classes without changing existing functions. " - Clean Code: A Handbook of Agile Software Craftsmanship   So if you do decide to use one over there other than It's a good idea to stick to that method and not mix the two. (http://en.wikipedia.org/wiki/BaseBean). To that point, I really like how you made all of your variables private :)  
  8. izackp

    Copy protection system

    If you really want to add anti-piracy:   Release a purposefully 'cracked' and 'buggy' version of your dll to pirate websites (high-cpu usage, frequent crashes, ect). Several versions infact, make them seem as legit as possible. You can even add a time delay to make it seem like it works perfectly at first. Having an already released 'cracked' version of you software will also deter crackers from actually cracking it too since they think its already been done and if they do crack it.. it will be just be mixed in with your version.   This should really frustrate the pirate community. Though, I'm not sure if that will result in more sales for you :P
  9. Is it possible to pass a pointer to an instanced class method (&creationsClass.createScriptObject) when registering an object behavior?   I need specific behavior for certain script objects when they're created. I'm trying to avoid using static variables and classes as much as possible which doesn't allow me to simply create a static variable to store the object type for the garbage collector and many other things I need to instantiate a script object.   I kind of want to do something like this (but obviously it doesn't work):   #define asInstanceMethod(c,m) asSMethodPtr<sizeof(c)>::Convert((&c.m)) void Texture::registerAS(asIScriptEngine* engine, ScriptObjectCreationCache& creationCache) { int r; static const char* const strComponent = "Texture"; r = engine->RegisterObjectType(strComponent, sizeof(Texture), asOBJ_REF | asOBJ_GC); assert(r >= 0); r = engine->RegisterObjectBehaviour(strComponent, asBEHAVE_FACTORY, "Texture@ f()", asInstanceMethod(creationCache, TSFactory), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterObjectBehaviour(strComponent, asBEHAVE_FACTORY, "Texture@ f(const string &in)", asInstanceMethod(creationCache, TSFactoryArg), asCALL_CDECL); assert( r >= 0 ); registerMembers<Texture>(engine, strComponent); }     I would greatly appreciate any additional info.      edit: I left a pretty crappy post earlier because I had to quickly go somewhere.. I fixed it up now ;)
  10. izackp

    Need help tracking memory leak

    I cannot for the life of me find this memory leak. I keep getting this:    (0, 0) : ERR : GC cannot free an object of type 'RenderComponent', it is kept alive by the application  (0, 0) : ERR : GC cannot free an object of type '_builtin_objecttype_', it is kept alive by the application  (0, 0) : ERR : GC cannot free an object of type 'dictionary', it is kept alive by the application  (0, 0) : ERR : GC cannot free an object of type 'Sprite', it is kept alive by the application I implement all of these functions:    void addRef();     void release();     int getRefCount();     void setGCFlag();     bool getGCFlag();   in the constructor i set the refCount to 1   and when I create a script object I notify the garbage collector like so: SpriteScripted* ScriptObjectCreationCache::SSFactory() { SpriteScripted* obj = new SpriteScripted(); if (spriteType == NULL) spriteType = engine->GetObjectTypeByName("Sprite"); engine->NotifyGarbageCollectorOfNewObject(obj, spriteType); return obj; }     this happens whenever I use that object type as a member property of a complete angelscript class (a class not declared in c++). However, i dont have a problem when I use a c++ defined class in a limited scope such as 'Texture' in setSpriteWithName: (angelscript code; I dont have problems with Texture but I do have leaks with Sprite) class RenderComponenet : Component { Sprite sprite; void setSpriteWithName(string name) { Texture texture(name); sprite.setTexture(@texture); } }   If anyone can see that I'm missing anything please let me know.   Thank you.
  11. izackp

    Need help tracking memory leak

    Well I'm glad I'm making progress and understanding angelscript more.  That code brings the ERRs down by 1 though  (0, 0) : ERR : GC cannot free an object of type 'RenderComponent', it is kept alive by the application  (0, 0) : ERR : GC cannot free an object of type 'Sprite', it is kept alive by the application  (0, 0) : ERR : GC cannot free an object of type '_builtin_objecttype_', it is kept alive by the application   However, I will figure it out.. I think I might just rebuild a minimal project to replicate the problem and try to isolate it. In situations like this I would normally breakpoint Release and AddRef and see which is being called when it isn't supposed to be called, but theres so much I don't know about the engine for me to dig through it.. Hopefully I figure this out soon xD
  12. izackp

    Need help tracking memory leak

    Not really the dictionary object just resides in a Testcomponent class which is just a container of class members and does nothing atm. Sprite registers the proper behaviors. It does implement enum references, but it doesn't hold any references as of yet. It really weird because the RenderComponent destructor gets called, but I still get the error. This is the only thing angelscript script code that I run: asIScriptModule* mod = builder.GetModule(); int testTypeId = mod->GetTypeIdByDecl("TestComponent"); asIObjectType *type = mod->GetObjectTypeByName("TestComponent"); testTypeId = type->GetTypeId(); asIScriptObject* objLogicComp = static_cast<asIScriptObject *>(engine->CreateScriptObject(testTypeId)); engine->NotifyGarbageCollectorOfNewObject(objLogicComp, type); std::cout << "Ref Count: " << objLogicComp->Release() << std::endl; std::cout << "Ref Count: " << objLogicComp->Release() << std::endl; engine->GarbageCollect(asGC_FULL_CYCLE | asGC_DETECT_GARBAGE | asGC_DESTROY_GARBAGE);     TestComponent is just an empty class with a Render Component inside of it.   So the destructor of both TestComponent and RenderComponent gets called . Yet I still get these errors in my logs: add - 2 - instanceId:1 - Sprite add - 3 - instanceId:1 - Sprite rel - 2 - instanceId:1 RenderComp Create add - 2 - instanceId:2 - RenderComponent add - 3 - instanceId:2 - RenderComponent rel - 2 - instanceId:2 TestComp Create rel - 1 - instanceId:2 //This release seems unusual Ref Count: 2 Ref Count: 1 TestComp Destroy RenderComp Destroy //Sprite does not get destroyed //Shutdown Engine (0, 0) : ERR : GC cannot free an object of type 'TestComponent', it is kept alive by the application (0, 0) : ERR : GC cannot free an object of type 'RenderComponent', it is kept alive by the application (0, 0) : ERR : GC cannot free an object of type 'Sprite', it is kept alive by the application rel - 1 - instanceId:1 (0, 0) : ERR : GC cannot free an object of type '_builtin_objecttype_', it is kept alive by the application    
  13. izackp

    What's everyone doing with Angelscript!

    I'm using it as the scripting language for my 2d game engine. 
  14. Sort of... I ended up hacking it in by adding an extra parameter to the registerObjectBehavior function so now I can do this:   void SpriteScripted::registerAS(asIScriptEngine* engine, ScriptObjectCreationCache& creationCache) { int r; static const char* const strComponent = "Sprite"; r = engine->RegisterObjectType(strComponent, sizeof(SpriteScripted), asOBJ_REF | asOBJ_GC); assert(r >= 0); r = engine->RegisterObjectBehaviour(strComponent, asBEHAVE_FACTORY, "Sprite@ f()", asMETHOD(ScriptObjectCreationCache, SSFactory), asCALL_THISCALL_ASGLOBAL, &creationCache); assert( r >= 0 ); .... }     it seems to work but I still have yet to run the angel script unit tests.
  15. izackp

    what does offset point to in GetProperty

    Awesome I didn't even see that function. Thanks.
  16. so for get property in the asScriptObject class:   GetProperty(asUINT index, const char **name, int *typeId = 0, bool *isPrivate = 0, int *offset = 0, bool *isReference = 0, asDWORD *accessMask = 0);   It assigns an offset which I assume is pointing to the data for that property, but i can't exactly tell what it is pointing to. Is it the actual raw data or some sort of angelscript wrapper?   What I'm trying to accomplish is assigning to a angelscript class's members. I need to be able to assign values (ints, ect) and references to other script objects.   Any help would be greatly appreciated
  17. I have a function like this:   asIScriptObject* ComponentScripted::getProperty(const std::string &key) const    and I'm registering it like this:   r = engine->RegisterObjectMethod(strComponent, "?& get(const string &in) const", asMETHODPR(ComponentScripted,getProperty,(const std::string&) const,asIScriptObject*), asCALL_THISCALL); assert( r >= 0 );   However, it doesn't seem like ?& is a valid return type. How would I return a asIScriptObject back to the script from c++?   Any help would be greatly appreciated. Thank you.
  18. Hmm it seems I've run into something again. I have a factory function for my LogicComponentScripted (c++ version of LogicComponent) static void LCSFactoryArgs(asIScriptGeneric *gen) { void *parentComponent = gen->GetArgAddress(0); LogicComponentScripted *self = reinterpret_cast<LogicComponentScripted*>(gen->GetObject()); assert(self != NULL); gen->SetReturnAddress(new LogicComponentScripted((asIScriptObject*)self, (Component*)parentComponent)); } Registration Function: r = engine->RegisterObjectBehaviour(type, asBEHAVE_FACTORY, "LogicComponentInner@ f(ComponentInner@& in)", asFUNCTION(LCSFactoryArgs), asCALL_GENERIC); assert( r >= 0 );     It seems if I call GetObject when I create a LogicComponentInner inside of a Scripted object's constructor it returns NULL. Which sort of makes sense since the script object isn't done constructing. Is it possible to get a reference to the scripted object when creating a c++ object in the constructor of the scripted class?   Overall, what im trying to do is have a parallel C++ object that has a reference to a Scripted object and vice-versa. 
  19. Wow thanks, I would of never have figured that out.. at least quickly..   Thanks for your help.
  20. Thanks the interface method worked pretty cleanly.  I still need a little help, so maybe you can just point me in the right direction. I was trying to create a script object in c++ of a class declared in angelscript with this code: asIScriptModule* mod = builder.GetModule(); int logicTypeId = mod->GetTypeIdByDecl("LogicComponent"); asIScriptObject* objLogicComp = static_cast<asIScriptObject *>(engine->CreateScriptObject(logicTypeId)); assert(objLogicComp != NULL);     and I get this error when calling CreateScriptObject: (0, 0) : ERR  : Failed in call to function 'Prepare' with 'null' (Code: -6)   which leads me to believe that I cant do this either or I'm missing a step that allows me to do this. I verified that the name of the class is the same as the parameter for gettypeidbydecl.. so I'm not sure what the problem is
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!