Jump to content
  • Advertisement
Sign in to follow this  
hahaha

CBaseEntity Help!!!

This topic is 3994 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Say in a game you have a base entity class. What sort of variables and functions would be in it?

Share this post


Link to post
Share on other sites
Advertisement
In my game i want all my objects like for eg the map every model etc... to derive from CBaseEntity and register with a manager for things like collision detection etc. Is this a good way to do it?

Share this post


Link to post
Share on other sites
Quote:
Original post by hahaha
In my game i want all my objects like for eg the map every model etc... to derive from CBaseEntity and register with a manager for things like collision detection etc. Is this a good way to do it?


An extension on model-view-controller might be more adapted. You use a controller object which sets up a model (a collision detection client object or a physics engine client object for instance) and a view (a model, a sprite).

Share this post


Link to post
Share on other sites
Ask: What sort of things do every entitity have in common?
What actions do each entitity have in common?

Share this post


Link to post
Share on other sites
Quote:
Original post by Nohup
A couple pointers for an intrusive double linked list.


What is an intrusive double linked list?

Share this post


Link to post
Share on other sites
Quote:
Original post by hahaha
Quote:
Original post by Nohup
A couple pointers for an intrusive double linked list.


What is an intrusive double linked list?


It's a violation of the single responsibility principle, which adds the responsibility of being part of a list to the responsibility of being an object.

This approach is generally shunned in all languages which have access to a standard library of containers (in practice, everything except C and assembly), because standard library containers are faster and lighter by default, provide more features and take less development time to use, in addition to respecting the single responsibility principle. The main reason is that you want to be free to make your entities part of zero, one or more containers, and you don't want to be forced to make your entities par of exactly one container (and to make that container a doubly linked list).

Share this post


Link to post
Share on other sites
Why have a base entity at all?

Why not define a single entity class, that uses component oriented design to specialize contents?

Or, if going for networked gameplay, an entity that is convenient to use with serialization (has UID, possible persistence ID) and is capable of serializing itself.

Or, have the class design mimic different types of entities, and have fields that reflect the functionality.

Or, not have the objects, and simply use arrays of structs to encapsulate functionality.

This question is akin to:"Suppose I want to drive. What kind of SUV would I use?" Well, not only is SUV not the best solution, but driving involves everything from unicycle, pogo stick, motor bike, tanks, airplanes, and, in some cases, SUVs.

In this case, the question is wrong. A better one would be describing the type of game design you want, what interactions you want, and implementation specific quirks, and then, the design of entity forms by itself.

Class design solves the problem - designing classes without context simply creates a solution looking for an answer. In this case, answering 42 would be perfectly valid. But you'd be stuck trying to figure out what the question is.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!