Jump to content
  • Advertisement
Sign in to follow this  
Irlan Robson

Entity Manager->Game Logic

This topic is 2141 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

I'm using a method that takes a game (the logic) that handles collisions between the entities and I'm fraid of not doing it well or if has a better (and simple) way to solve this.

 

The method:

void Update(const float& frameTime, const float& dt, const int& subSteps, Game* game);

Should I create a class called Logic to minimize the World-Logic dependencies?

Thanks.

Edited by irlanrobson

Share this post


Link to post
Share on other sites
Advertisement

I try to only create objects for "tangible" ideas. A MouseManager manages the mouse, a Application executes a game, ect. All logic for your Game object should go in your Game class, but if you feel it's becomming bloated or messy try and think of a way to abstract it. Maybe take a look at an opensource library like libgdx and see How they're managing entities. Try not to create more objects then you need, having a "logic" class for game logic seems a bit out of place.

 

You really shouldn't worry about code design as much as you might think. Next game you'll salvage as many mangled pieces of this game as you can and probably rewrite most of your code base with new found experience.

 

I've taken up using Unity because I cannot stop myslef over engineer my frameworks. Maybe look at an engine if games are your focus. There is shame yes but it's nice to actually make progress.

Edited by GameGeazer

Share this post


Link to post
Share on other sites

All logic for your Game object should go in your Game class,

 

The logic for game object should be in draw and update method of the game object. game class should load the game objects beforehand. Then the game class will update and draw them in a game loop. 

Edited by warnexus

Share this post


Link to post
Share on other sites

Off topic, sorry, but there's no point in passing primitive types by const reference. Your signature should probably be:

void Update(float frameTime, float dt, int subSteps, Game* game);

or:

void Update(float frameTime, float dt, int subSteps, Game& game);

Share this post


Link to post
Share on other sites

Off topic, sorry, but there's no point in passing primitive types by const reference. Your signature should probably be:

void Update(float frameTime, float dt, int subSteps, Game* game);

or:

void Update(float frameTime, float dt, int subSteps, Game& game);

You mean... just for readability?? Because the frameTime and dt is constant... 

Share this post


Link to post
Share on other sites

You mean... just for readability?? Because the frameTime and dt is constant...

If they're constant, then use:
void Update(const float frameTime, const float dt, const int subSteps, Game& game);

It is more costly to repeatedly dereference a pointer-to primitive type than it is to simply copy said primitive type.

Share this post


Link to post
Share on other sites


I'm using a method that takes a game (the logic) that handles collisions between the entities and I'm fraid of not doing it well or if has a better (and simple) way to solve this.
Yes, there's a better and simpler way of dealing with collision. It's called "using a proper collision library", which will provide you industry-grade collision quality and performance at very low cost.

If you're interested in doing things right, there's nothing better than starting playing with the right tools - those you will end up using anyway in the future - unless you're yet another one playing with collisions "as a learning exercise".

Share this post


Link to post
Share on other sites

You didn't understood my question. But thanks anyway. I've just figure out that the EntityManager (World) will dispatch the collisions to the Game Container via ptr/ref. It's for a thesis and I'm trying to work the readability and the simplicity of the code.

 

 


I'm using a method that takes a game (the logic) that handles collisions between the entities and I'm fraid of not doing it well or if has a better (and simple) way to solve this.
Yes, there's a better and simpler way of dealing with collision. It's called "using a proper collision library", which will provide you industry-grade collision quality and performance at very low cost.

If you're interested in doing things right, there's nothing better than starting playing with the right tools - those you will end up using anyway in the future - unless you're yet another one playing with collisions "as a learning exercise".

 

You didn't understood my question. But thanks anyway. I've just figure out that the EntityManager (World) will dispatch the collisions to the Game Container via ptr/ref. It's for a thesis and I'm trying to let it simple and fast.

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.

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!