Friday, December 5, 2014

Latchkey #62 - Ghosts

Fixed a quick bug where when you moved to another room, the directional box didn't refresh.

After that I took a break from recoding the same old stuff and went to work on a new feature: ghosts!

Except the moment I began working on it, I realized that it can do a lot of what the player can do: move through rooms, open doors, etc.  I need to move some things around again.

Now I see the appeal of object-oriented programming.  Finally I have a need!  So now I've restructured so there is a Character class that both the Player and NPCs inherit from.

Well, I was hoping to be able to shrink the Player class a bit, and I did... but just a teensy bit, nothing major, just some shared variables.  Unfortunate the Move command, for instance, is far more complex for the Player than it needs to be for the ghosties.  Better than nothing, to get those couple of basic functions together, at least.

Man, when I get tired of trudging through the mud of recoding what I've already done, and I move on to a new feature, it just makes me rethink other major structures I've got in place.

Next, though, comes working on the realtime textbox.  Ghosts don't matter much if you don't get to see their effects.  What kind of event listener do you need for autonomous stuff running in the background?  Is that even the proper way to do that?  My initial thought is to check on each frame... something.  I want to make a generic listener that can take a ping from a ghost, or other realtime events.  Perhaps it requires a custom event, or perhaps there's something I just don't know about that already exists that can take some kind of internal signal.

Or perhaps there's a completely different way to do it that doesn't require a listener at all.  Perhaps ghosts and any other realtime object can have a pointer to the Interface class so they can manipulate the realtime textbox directly.  I think I'll try that and see if it works.

No comments:

Post a Comment