G
Guest
Guest
Archived from groups: rec.games.roguelike.development (More info?)
I just added (openable/closeable/smashable) doors to my game. Right now
right-clicking on a door brings up the actions that you can perform on it in
a nice context menu (here's a screenshot -
http://www.stanford.edu/~jjshed/blog/pics/witherwyncontext.png).
The exercise has given me an inkling of a design problem that I'ven't
anticipated. How do I model interactions between game entities?
At the moment, I have an abstract Entity class which I subclass for Items,
Doors, and Critters (the PC is a critter). The get the doors working, I just
added several functions to the Door entity (Open, Close, Smash). Then, when
I need to generate a list of actions that can be taken on a tile, I loop
through all the entities on that tile, check if it's a door, check the
door's state, and generate the appropriate list of actions.
This is kind of messy, and door interactions are pretty simple. So I think I
need some sort of event/message processing system? The thing I am trying to
avoid is having, for example, a Critter entity trying to open a door, call
the Door entity's OpenDoor() function directly. I think all these requests
should be channeled through a message system of some sort. This should make
it easier to manage things like printing out notifications to the text
console...
If I sound confused and unsure, it's because I am. The system I've worked
out as far as the Entities are concerned, I think, is pretty good and has
worked well so far. So maybe someone can help me with the last piece.
PS - I'd also like it to be easy to generate a list of all actions that can
be taken on an Entity - both for pushing this info to the GUI and for
pushing environment data/options to the AI.
--
Blog:
Shedletsky's Bits: A Random Walk Through Manifold Space
http://www.stanford.edu/~jjshed/blog
I just added (openable/closeable/smashable) doors to my game. Right now
right-clicking on a door brings up the actions that you can perform on it in
a nice context menu (here's a screenshot -
http://www.stanford.edu/~jjshed/blog/pics/witherwyncontext.png).
The exercise has given me an inkling of a design problem that I'ven't
anticipated. How do I model interactions between game entities?
At the moment, I have an abstract Entity class which I subclass for Items,
Doors, and Critters (the PC is a critter). The get the doors working, I just
added several functions to the Door entity (Open, Close, Smash). Then, when
I need to generate a list of actions that can be taken on a tile, I loop
through all the entities on that tile, check if it's a door, check the
door's state, and generate the appropriate list of actions.
This is kind of messy, and door interactions are pretty simple. So I think I
need some sort of event/message processing system? The thing I am trying to
avoid is having, for example, a Critter entity trying to open a door, call
the Door entity's OpenDoor() function directly. I think all these requests
should be channeled through a message system of some sort. This should make
it easier to manage things like printing out notifications to the text
console...
If I sound confused and unsure, it's because I am. The system I've worked
out as far as the Entities are concerned, I think, is pretty good and has
worked well so far. So maybe someone can help me with the last piece.
PS - I'd also like it to be easy to generate a list of all actions that can
be taken on an Entity - both for pushing this info to the GUI and for
pushing environment data/options to the AI.
--
Blog:
Shedletsky's Bits: A Random Walk Through Manifold Space
http://www.stanford.edu/~jjshed/blog