# izackp

Member

19

215 Neutral

• Rank
Member

• Website
• Interests
Design
Production
Programming

• Github
izackp
• Steam
izackrp
1. ## 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. ## UDK 4 vs Unity - Which is better and easier to use to make a first person action game?

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. ## 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. ## 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. ## 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. ## How do you get ideas for new games?

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. ## 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. ## 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. ## 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
10. ## 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
11. ## 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.
12. ## What's everyone doing with Angelscript!

I'm using it as the scripting language for my 2d game engine.
13. ## Register object behavior with pointer to instance function

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.
14. ## Register object behavior with pointer to instance function

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 ;)
15. ## what does offset point to in GetProperty

Awesome I didn't even see that function. Thanks.