Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

126 Neutral

About DarkPizzaX

  • Rank
  1. DarkPizzaX

    Question about inheritance

    Having been trying to get it to work (thanks for the info, btw) it raised two more questions:   1. According to the docs, to create a class instance I should be able to simply call asIScriptFunction *factory = type->GetFactoryByDecl("MyClass @MyClass()"); (with MyClass being replaced with whatever script class I have) prepare and execute the function, then I can retrieve it as an asIScriptObject*. Unfortunately, it fails to find the factory function (returns NULL). My script class doesn't have any special constructors. I'm not quite sure what I'm doing wrong.   2. How do you register a C++ constructor for a value/pod type? I need a type from another library to be able to used but I'd like to use the various constructors the type has in the script.
  2. DarkPizzaX

    Question about inheritance

    I haven't had too much experience with AngelScript, so forgive me if I'm off about something.   But anyways, to explain my question/situation I basically have a class that fundementally is something like this (of course, this is just an example): class Behaviors { public: void Behavior1(int v) { val *= v; } int Behavior2() { return val; } private: int val; }; Now, the class is getting really messy (and there's behavior that it contains that I'd prefer scripted anyways) so I'm trying to get the class to work off of components instead.   So I'm effectively trying to achieve something like this: struct IBehavior1 { virtual void Behavior1(int v)=0; }; struct IBehavior2 { virtual int Behavior2()=0; }; struct Behavior1Impl : IBehavior1 { Behavior& behavior; Behavior1Impl(Behavior& b) : behavior(b) { } void Behavior1(int v) { behavior.val *= v; } }; struct Behavior2Impl : IBehavior1 { Behavior& behavior; Behavior2Impl(Behavior& b) : behavior(b) { } int Behavior2() { return behavior.val; } }; class Behavior { friend struct Behavior1; friend struct Behavior2; public: Behavior() { behavior1 = static_cast<Behavior1*>(new Behavior1Impl(*this)); behavior2 = static_cast<Behavior2*>(new Behavior2Imp(*this)); } ~Behavior() { delete behavior1; delete behavior2; } void Behavior1(int v) { behavior1->Behavior1(v); } int Behavior2() { return behavior2->Behavior2(); } private: int val; IBehavior1 *behavior1; IBehavior2 *behavior2; }; What I want to do is replace, what is equivalent to this example's "Behavior1Impl" and "Behavior2Impl", with a scripted class, that implements the behavior of the components but is invisible to the container that it's scripted. Sorry if the example I gave is confusing.   I looked at the AngelScript documents and it has not made it clear to me what's required in order achieve something like this. Or even what I want to do is possible.   Any information regarding this would be appreciated.
  3. DarkPizzaX

    scriptbuilder error in angelscript 2.30.1

    Thanks for the quick reply. Adding #include <string.h> fixed it for me.
  4. I just updated my angelscript SDK to 2.30.1 but I couldn't get scriptbuilder.h to compile correctly (am using GCC 4.9.2 on Windows), it was informing me that the function _strcmpi did not exist. While I fixed it by including windows.h and changing the function to _stricmp, but now I have to deal with windows.h being included.   I'm not sure if this is a bug or something, or if I'm just really bad at including libraries, but still. Does anybody else have this problem?  
  5. DarkPizzaX

    The "Entity Component" pattern

    That's not really how I think of "entity-component." What you're talking about is really just regular composition. "Entity-component" means that there isn't a central "entity object" that owns all of the components. Instead there are subsystems that store homogeneous collections of components and an "entity" is an index or key into those collections. Communication between components is done by having the subsystems talk to each other. So if you had a mesh renderer component and a rigid body component on an entity, the mesh renderer component would live with all the other mesh renderers (and therefore be processed at the same time as them) and the rigid body component would live with all the other rigid body components. To access either one, you'd ask their parent subsystems for them by passing them a unique identifier that represents a particular "entity". I've never used it, but I hear Artemis is a decent implementation of an entity system .Even if you're not using Java, you might find it useful to nevertheless look to it for some inspiration. Implementations in other languages will probably do things differently (eg. a C++ implementation might not have a "Component" base class/interface or even use virtual inheritance at all), but the basic ideas are therein.     Thanks for the link. Unfortunately, despite being able to obtain the source code, the official website link on the google code wiki for the project is dead.   One thing though, who generates and manages the key? I assume the key for one entity is the same across all subsystems.
  6. I only recently heard about this pattern and while it sounds good in theory I'm confused about how you'd actually implement it.   I tried to implement one that used template types to add, remove, and get components stored in an entity (which was just a fancy interface that simply held a vector of component pointers). The basics worked fine but the result was messy and hard to use. I never made it into anything.   I tried to find any information regarding actual working example implementations of the pattern, but I couldn't find anything other than quick summeries, most of which never gave any useful information. I would like to know what I should be doing if any of you have done such pattern before. Thanks!
  • 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!