The Behavior System Revealed!

Started by
34 comments, last by riverman_paul 15 years, 11 months ago
Hi there, My name's Jacob. My brother Paul and I run a tiny indy studio called RiverMan Media. We've made a couple moderately successful casual games and are working on our first WiiWare title, MadStone. With our tiny development team, we've got a lot of factors stacked against us: Our art department has only 2 people, and one is part time. We only have two primary coders. We can't afford to hire testers. That's why it's so important to us to optimize our development process. One of our most powerful tools is the Behavior System, which my brother invented for our second game. It's an object-oriented architecture that allows objects to share behavior between objects, regardless of how dissimilar they appear to the user. For example, in Primate Panic, monkeys walking and GUI menus sliding on and off the screen use *the same code* thanks to the behavior system. The behavior system lets us focus on gameplay rather than the mechanics of programming. It is what has kept our code nearly bug-free. It's what allows us to continually coat our games with that extra polish they need to stand out. ..and until today, I really didn't understand how it worked! But when I woke up this morning, Paul had posted a lengthy article explaining *exactly* how it works and how to implement it. It's a great read. I'm so proud of him! If you're a game programmer, I highly recommend you check this out! The Behavior System Thanks! Jacob RiverMan Media
Advertisement
It sounds like your brother has essentially come up with a component based system, similar to the one described by Scott Bilas as they used for Dungeon Siege. It's a good system, and personally I think it's by far the best engineering approach to building games. (Although it can introduce some wacky and irritating complications.) We use a component system here in our engine as well.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
We use a component-based framework for the process simulation system made by the company I work for, so stay open of what it might be used for.
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
Yes! Although we think of things from a game-centric perspective, a component-based system can apply to a myriad of software engineering problems. It works especially well for real-time or simulation type applications, but I could also see it being used in image processing, markup systems, and data analysis.

Fun stuff!

-Jacob
Correct me if I'm wrong, but it sounds like Aspect Oriented Programming?
My question is, If you're going to create classes that extend game object wont you need somewhere in your update code something like this:

update(){monkey.update();tree.update();button1.update();button2.update();button3.update();etc.update();etc2.update();etc3.update();0.update();....n.update();}


I could see your main class getting very convuluted making sure that each class that extends your GameObject class gets updated. (and actually exists somewhere). Mistake me if I am wrong, I am trying to work it out in my game.

Lets say I have a bunch of objects that all extend my GameObject class. and they get created depending on if their in a map file that's being read. How will my main class now which objects exists (lets say a player, a tree, and a bad guy are created)

How does my main class know they exist and to update them specifically. Won't I need code like seen above?

Quote:Original post by NotTheCommonDose
My question is, If you're going to create classes that extend game object wont you need somewhere in your update code something like this:

*** Source Snippet Removed ***

I could see your main class getting very convuluted making sure that each class that extends your GameObject class gets updated. (and actually exists somewhere). Mistake me if I am wrong, I am trying to work it out in my game.

Lets say I have a bunch of objects that all extend my GameObject class. and they get created depending on if their in a map file that's being read. How will my main class now which objects exists (lets say a player, a tree, and a bad guy are created)

How does my main class know they exist and to update them specifically. Won't I need code like seen above?


<br>List&lt;GameObject&gt; allObjects();<br><br>// add some game objects<br><br>foreach (GameObject obj in allObjects)<br> obj.Update();<br></code><br><br>C# since the article used it. The player would probably be a seperate case as he/she has some special code though.
It appears though that he has a lot of different classes which all extend Game Object
Hey all-

NotTheCommonDose:

BlodBath is right, there are several ways to update all of your GameObjects without calling update() on each one manually. If you use a list, as BlodBath suggested, that usually works great.

In some situations (like grid based puzzle games) you may want to store them all in a 2d array and update each element of the array. It's much easier to do it this way if you want to ensure that all your objects update() and redraw() in a specific order, which is critical to the logic and drawing of a game like MadStone (video: here).

If they didn't update in order (top to bottom), falling objects would get out of sync with each other and the physics would be messed up. If they didn't draw in order, you'd see random chunks of blocks drawing in front of other ones.
You can store objects to be rendered / drawed / destroyed / instanciated in priority queues (draw front to back, left to right, destroy A, and B before C...).

That's also why many use a scenegraph (component) to automate that process, like a 2D grid, a quadtree, ect...

Everything is better with Metal.

This topic is closed to new replies.

Advertisement