Jump to content

  • Log In with Google      Sign In   
  • Create Account

A bottleneck problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 lride   Members   -  Reputation: 633

Like
0Likes
Like

Posted 14 December 2012 - 08:13 PM

In my bomberman clone, I want bombs to explode when they get hit by other bombs.
[source lang="cpp"]void Bomb::handleMessage(const Message & msg){ if(msg.msg==MessageType::HIT_BY_BOMB) { alive=false; gameWorld->cancelAllMessagesTo(this); gameWorld->getGameMap().onExit(currentLoc.x, currentLoc.y, this); //I'm having problem here... for(Entity * eachEntity : gameWorld->getAllEntitiesWithin(currentLoc.x, currentLoc.y, range); gameWorld->getPostOffice().sendMessage(this, eachEntity, MessageType::HIT_BY_BOMB); }}[/source]

As you can see when a bomb receives a message that it got hit by an another bomb, it sends out messages to every single entities within the range of the bomb.

Untitled.png
This is how messages would get delivered if bomb A explodes
A->C, E
C->A, B, D, E
E->C, A
B-> C, D
D->C, B
...

As you can see, there are many redundant message delivery. This slows down my game so much.
What is a better design to this problem?
An invisible text.

Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 13576

Like
0Likes
Like

Posted 14 December 2012 - 09:09 PM

When a tile receives a message, tag it and don’t send the same message to it again.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS