|
List Info
Thread: Pixlib - Multiple Commands for an Event
|
|
| Pixlib - Multiple Commands for an Event |
  United States |
2007-03-30 12:08:59 |
I've been following this list for a while as I've been
learning Pixlib over
the past several weeks. It has been very helpful...keep up
the good work!
I do have a question for the group...
I'm interested in the possibility of registering multiple
Commands to an
Event in FrontController. This isn't currently possible, but
I just wanted
to get some suggestions from everyone to make sure what I'm
thinking about
makes sense. I'll give you a simplified example of what I am
facing:
Imagine you are using Pixlib to develop a simple
point-and-click adventure
game...think Myst, where you click in a direction to
"move" to that new
location. Now, ideally, you'd have some type of descriptive
text that shows
when necessary. For example, "You are now facing east.
There is a large
golden statue of Francis Bourre glimmering in the sun."
Maybe that move is
also accompanied by a sound effect. Obviously, clicking on
the left side of
your view would send out an event like
NAVIGATE_TURN_LEFT_CLICK, which would
swap out the current view with new one by executing a
generic Command called
something like SwitchView.
For flexibility reasons, I'd like to keep the text of all of
these
descriptive messages in an external XML file. Since these
messages will be
triggered by _some_ event, I thought it may be useful to
link it to an
EventType declared in EventList. The XML may look something
like this:
<messages>
<message>
<event
type="string">NAVIGATE_TURN_LEFT_CLICK</even
t>
<text type="string">You are now
facing east. There is a large golden
statue of Francis Bourre glimmering in the
sun.</text>
</message>
</messages>
So, if everyone is still with me...What I would like to do
is be able to add
new messages and link them to an event just by updating the
XML file. Using
the XML file in this way essentially acts as an extension to
the
Event/Command mapping defined in the FrontController class.
I have run
through a number of solutions, and none of them feel like
the best answer.
For example:
- Add a call to each Command that checks to see if the
current event has a
matching message. The call is made to a MessageModel, which
essentially acts
as its own FrontController, mapping Events to messages. This
would muddy up
the Commands, because not every Command would have a
matching message.
- Override FrontController's _handleEvent to check with
MessageModel when
_any_ Command is executed. This would remove some
duplication, but still
doesn't seem right.
- Override FrontController to have an event "key"
mapped to an Array of
possible Commands. This seems to be closer to getting at the
problem, but
would require overriding FrontController's push,
_getCommand, and
_executeCommand functions....and it's a pretty messy
solution.
Again, my goal is to be able to map a message to an event
through an
external XML file. I feel I've explored most of the possible
solutions, but
wanted to get other opinions to see if I'm missing anything,
if I'm too anal
about my code, or if what I'm proposing is just completely
crazy
I look forward to your responses. Thanks for taking the time
to read through
my question!
- Dan
_______________________________________________
Pixlib mailing list
Pixlib osflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org
|
|
| Re: Pixlib - Multiple Commands for an
Event |

|
2007-03-30 14:57:34 |
|
Hey Dan,
For sure you can register multiple commands to an event, by using the MacroCommand (a Command of Commands you see?)
Are you thinking to add additional events dynamically at runtime?
What you are describing sounds kind of like how we used to do text-based "choose your adventure" type of games. Anybody remember Zork?
Ah...hours of fun.
What you may wish to do is think in terms of a grid of info-objects.
So as you move about in the game, your player object is actually just updating his position index. So like, when he goes west, he goes from playfield[33] to playfield[34]. Each element of the playfield array is an object defining everything that should be happening. Maybe you use the data of that object to call factories that provide the textfields/graphics/etc that you need.
At any rate, researching those old text-based games could be a good idea. Today's MMORPGs are no different - just fancier graphics. 
People used to be obsessed with those games!
Hope it gives some ideas.
-tim.
On 3/30/07, Dan W < dreamteq hotmail.com">dreamteq hotmail.com> wrote:
I've been following this list for a while as I've been learning Pixlib over the past several weeks. It has been very helpful...keep up the good work!
I do have a question for the group...
I'm interested in the possibility of registering multiple Commands to an Event in FrontController. This isn't currently possible, but I just wanted to get some suggestions from everyone to make sure what I'm thinking about
makes sense. I'll give you a simplified example of what I am facing:
Imagine you are using Pixlib to develop a simple point-and-click adventure game...think Myst, where you click in a direction to "move" to that new
location. Now, ideally, you'd have some type of descriptive text that shows when necessary. For example, "You are now facing east. There is a large golden statue of Francis Bourre glimmering in the sun." Maybe that move is
also accompanied by a sound effect. Obviously, clicking on the left side of your view would send out an event like NAVIGATE_TURN_LEFT_CLICK, which would swap out the current view with new one by executing a generic Command called
something like SwitchView.
For flexibility reasons, I'd like to keep the text of all of these descriptive messages in an external XML file. Since these messages will be triggered by _some_ event, I thought it may be useful to link it to an
EventType declared in EventList. The XML may look something like this:
<messages> <message> <event type="string">NAVIGATE_TURN_LEFT_CLICK</event> <text type="string">You are now facing east. There is a large golden
statue of Francis Bourre glimmering in the sun.</text> </message> </messages>
So, if everyone is still with me...What I would like to do is be able to add new messages and link them to an event just by updating the XML file. Using
the XML file in this way essentially acts as an extension to the Event/Command mapping defined in the FrontController class. I have run through a number of solutions, and none of them feel like the best answer.
For example:
- Add a call to each Command that checks to see if the current event has a matching message. The call is made to a MessageModel, which essentially acts as its own FrontController, mapping Events to messages. This would muddy up
the Commands, because not every Command would have a matching message. - Override FrontController's _handleEvent to check with MessageModel when _any_ Command is executed. This would remove some duplication, but still
doesn't seem right. - Override FrontController to have an event "key" mapped to an Array of possible Commands. This seems to be closer to getting at the problem, but would require overriding FrontController's push, _getCommand, and
_executeCommand functions....and it's a pretty messy solution.
Again, my goal is to be able to map a message to an event through an external XML file. I feel I've explored most of the possible solutions, but
wanted to get other opinions to see if I'm missing anything, if I'm too anal about my code, or if what I'm proposing is just completely crazy 
I look forward to your responses. Thanks for taking the time to read through
my question!
- Dan
_______________________________________________ Pixlib mailing list Pixlib osflash.org">Pixlib osflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org
|
[1-2]
|
|