Re: Modeling events that occur in a game world
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Sun, 22 Apr 2007 09:17:52 +0200
On 21 Apr 2007 10:24:32 -0700, Aaron J. M. wrote:
I need a way of representing and tracking different events that occur in a game
I'm working on. I have a world composed of one or more Maps. Each Map location
(coordinate) may or may not have a Creature. A Creature is controlled by an AI,
which may also be the player's UI, though the Creatures themselves are not
necessarily aware of their AIs. Creatures may move to different coordinates or
attack other Creatures.
Right now the two events I know I'll want to keep track of is when a Creature
attacks another Creature and when a Creature dies, and I see myself coming up
with new events as my game grows more intricate. Different parts of my game
would be interested in different kinds of events. The graphical display would
be interested in all events so that it may display an appropriate animation.
More importantly, the different AIs would need to observe recent events to
modify their behaviour. If a Creature is attacked, the AI controlling it has a
vested interest in knowing about it.
I'm having trouble modeling this because the different kinds of events would
keep potentially arbitrary information, making it hard to generalize. An attack
event would know the attacking Creature, the target Creature, and the amount of
damage done. A death event would just know the Creature that died. I might
also implement Creatures grabbing and throwing other Creatures, so a throw event
would need to know the throwing Creature, the thrown Creature, and where the
thrown Creature landed. For this reason I can't really make them subclasses of
a single Event class, since they hold such different information.
Why are they events? I would say, that death, under attack, flight etc are
not events, they are states. If creatures are models of physical objects,
then the only event they need is a timer or scheduling event. The object
reads the sensors, changes its state and writes the actuators.
So how would I model these events and let my system handle and respond to them?
Multiple-dispatching operations, if your language can it. Otherwise you
have to emulate multiple dispatch.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- Follow-Ups:
- Re: Modeling events that occur in a game world
- From: Aaron J. M.
- Re: Modeling events that occur in a game world
- References:
- Modeling events that occur in a game world
- From: Aaron J. M.
- Modeling events that occur in a game world
- Prev by Date: Re: Modeling events that occur in a game world
- Next by Date: Re: Modeling events that occur in a game world
- Previous by thread: Re: Modeling events that occur in a game world
- Next by thread: Re: Modeling events that occur in a game world
- Index(es):
Relevant Pages
|