« How Anal Is That? | Main | Quality of Engineering - Does It Really Matter? »

August 06, 2009



I guess we all have experienced something similar to your curtain example at one point or another. I often encountered similar problems with GUI stuff, like mouse cursor hiding or gamepad input routing.

Reference counting might help a bit but it often adds more problems than it solves, because it can go wrong quite easily. I've already seen code like "while(!visible()) visible_ref++;" ... no, really.

The solution I tend to choose nowadays is that there is only one piece of code that decides of the final result, but instead of pulling states itself from everywhere in the game, it has a stack of triggers, each trigger being owned by the relevant part of the game (cutscene, respawn, transition). And each trigger has three states: "on", "off" and "don't care". At every update, I search the stack in sequence, looking for the first "on" or "off" value. Each part of the game can only change its own trigger, and in the end it's only a matter of deciding the right order.

I don't know if my explanation is clear, but in fact it's a lot less code than it sounds, and it is very convenient to debug.

Bryan McNett

Duplication of data is actually desirable, now that we're moving to many-core architectures with disjoint local memories. Processes have no way to communicate, except by sending copies of data through fifos.

Alan Kay: "Actually I made up the term "object-oriented", and I can tell you I did not have C++ in mind."

I would make a "curtain" process that accepts multiple messages, like

1. lower curtain
2. raise curtain
3. lower curtain, and don't raise again until i say so

Your "transition" script would call message #2 and #3, because it knows it will visually glitch otherwise. The "respawn" script would call #1 and #2.

Implementation is not for the caller to know. Probably the "until I say so" part would involve something like a reference count?

The design focus should be on sussing out all the messages required to meet the expectations of callers.

The comments to this entry are closed.

Jamie's Bragging Rights

  • Spider-Man 2
    The best superhero games of all time Game Informer
    Top five games of all time Yahtzee Croshaw
    Top five superhero games of all time MSNBC
    Top 100 PS2 games of all time Official Playstation 2 Magazine
    1001 Games You Must Play Before You Die Nomination for Excellence in Gameplay Engineering Academy of Interactive Arts & Sciences
  • Schizoid
    Penny Arcade PAX 10 Award
    Nominated for XBLA Best Original Game
    Nominated for XBLA Best Co-Op Game