Re: Double Dispatch Problem: Mobile Creatures and Projectiles in a Game World
- From: "Daniel T." <daniel_t@xxxxxxxxxxxxx>
- Date: Fri, 30 Mar 2007 11:34:05 GMT
"Aaron J. M." <ajmacd@xxxxxxxxxxxxxxx> wrote:
On Mar 29, 3:48 pm, "H. S. Lahman" <h.lah...@xxxxxxxxxxx> wrote:
The only "interesting" collision collaboration seems to be
Projectiles hitting Creatures since all other combinations seem to
the no-ops. <snip> What is the problem space commonality of Mobile
that justifies generalization? It only seems to exist to support
the reflexive "collides with" relationship, but that relationship
doesn't seem to capture what you are really interested in the
problem solution (Projectiles hitting Creatures).
Most of the reason why I thought Creatures and Projectiles could be
subclasses of Mobile was because they are both able to move and they
both have a location in World (bad case of inheritance for
code-reuse?). I'm becoming convinced that I should just get rid of
Mobile though.
Maybe. Maybe Mobile should be contained within them. Is it full of code?
I'm still unsure about how I would model the timing of the movements
of everything without a single Mobile list. As I said previously I
wanted to have things in the World have different speeds which
affect what order they are told to move for every game tick,
regardless whether they're a Creature or a Projectile. Any thoughts
on how to model this?
Nothing should be "told to move", mobiles should make that decision for
themselves. I can see a mobile having a "timePasses" method which tells
it how long has passed since the last time the "timePasses" method was
called. Then it decides if it should update its position or not.
So, World keeps two lists (Creatures and Projectiles), and all
Mobiles are able to attach themselves to a World.
No. World keeps two lists of Points and something else attaches
the Mobiles to the World.
<snip>
In the idea above, World doesn't have pointers to Mobiles, and
doesn't send any messages to them. Each Mobile would act
independently.
Thanks for clarification. I'm not sure about this model though,
since I wanted World to be a proper container for Creatures and
Projectiles.
Why would you want that? This model allows all mobiles to all be
contained by another object that sends them a "tick" or "cycle" message
to let them know they can do one cycle worth of stuff, or each mobile
can be run in its own process/thread independent of all others... Just
like in real life.
.
- References:
- Double Dispatch Problem: Mobile Creatures and Projectiles in a Game World
- From: Aaron J. M.
- Re: Double Dispatch Problem: Mobile Creatures and Projectiles in a Game World
- From: Daniel T.
- Re: Double Dispatch Problem: Mobile Creatures and Projectiles in a Game World
- From: Aaron J. M.
- Re: Double Dispatch Problem: Mobile Creatures and Projectiles in a Game World
- From: Daniel T.
- Re: Double Dispatch Problem: Mobile Creatures and Projectiles in a Game World
- From: Aaron J. M.
- Double Dispatch Problem: Mobile Creatures and Projectiles in a Game World
- Prev by Date: Re: Double Dispatch Problem: Mobile Creatures and Projectiles in a Game World
- Next by Date: Re: Is Procedural Paradigm a basis of OO Paradigm?
- Previous by thread: Re: Double Dispatch Problem: Mobile Creatures and Projectiles in a Game World
- Next by thread: Re: Double Dispatch Problem: Mobile Creatures and Projectiles in a Game World
- Index(es):
Relevant Pages
|