Object Oriented Game Design

Started by
49 comments, last by TechnoGoth 18 years, 8 months ago
I'm trying to study how the philosophy of object oriented programming applies to game design. Apparently, everything is made out of objects. The whole game is the largest object, and it is made out of other smaller objects. But what are these smaller objects? Does anybody know of a diagram showing all the classes and objects an example RPG is made out of?

I want to help design a "sandpark" MMO. Optional interactive story with quests and deeply characterized NPCs, plus sandbox elements like player-craftable housing and lots of other crafting. If you are starting a design of this type, please PM me. I also love pet-breeding games.

Advertisement
You have a CGameWorld. Let's assume we're using a fantasy game.

The game world has towns with identified maps (CTown, CTownMap), doorways to buildings within that map (CHouse), people to talk to (CActor), and triggers/scripted events (CTrigger, CScript, etc.). You also have players, including NPCs, and their equipment. (CPlayer, CPlayerRef, CItem, CWeapon, CArmor, CPotion, CItemRef, CWeaponRef, CPotionRef...).

Items. Nouns get turned into classes and those classes encompass an object, whether that object be a person, place, thing, or abstract idea (trigger).

Objects are just that... objects.
I haven't completed an RPG yet, but it might look something like this:

Character      Spell     Potion     Weapon     Renderer     World     Renderable     Task     TaskManager/       \                                       /      \                                           |Player  NPC                            OpenGLRenderer SoftwareRenderer                            Game        /  \     Enemy  Friendly


This is just off the top of my head, so I'm sure it's missing things and has some problems.

EDIT: Sorry about the formatting issues, apparently my browser has differently sized spaces in edit boxes.
\ followed by a newline is eaten by the forum software. If you want to do ascii art using the \ character you need to put an extra space after it before the newline if you want it to display properly.
Great topic, if someone could post some articles or anything related to this it would be great.. in the design of a small project I'm working on I've been finding myself going back and forth on different things due to lack of time to spend on design, and I've also been needing to come up with some hacks along the way to keep things glued together.. seeing some models of how an RPG or other Genres should be structured would be great.

Quote:Original post by Roboguy
I haven't completed an RPG yet, but it might look something like this:

Character      Spell     Potion     Weapon     Renderer     World     Renderable     Task     TaskManager/       \                                       /      \                                           |Player  NPC                            OpenGLRenderer SoftwareRenderer                            Game        /  \     Enemy  Friendly


This is just off the top of my head, so I'm sure it's missing things and has some problems.


One thing that sticks out to me would be your Potion/Weapon, I'd do it like this:
            Item           /    \          Usable     Non-Usable     /         /          \  Potions/Etc  Equipment  Other
Here's a hierarchy of the game modes my RPG will have. Each of the game modes is sort of one of the second level of objects, one below the game as a whole. And then they each contain their owns objects - like puzzle pieces only exist in puzzle mode, and you can only exchange money and objects in dialogue mode. So maybe this will help us brainstorm what objects need to exist as part of each mode.

Game

- Start-up Mode (?)
- - Splash Screen (FMV Mode)
- - Intro Music Video (FMV Mode)
- - Start/Continue? Screen (Menu Mode)
- - Character Creation To Start New Game (Menu Mode)

- Main Mode
- - Get Saved Or New Game State Data
- - Display World, PC, PC Stats
- - Start Background Music And Animations
- - Listen For Gamepad Input
- - Respond To Input
- - - Attempting To Move PC
- - - - Pathfinding
- - - - Collision Detection
- - - Act On An Object (Including Menu Or Character)
- -If Necessary, Change Game Modes
- - Update PC, PC Stats, Object(s), And World Accordingly

- Dialogue/Object Exchange Mode
- - Popup A Dialogue Box And Update Facial Expressions Accordingly
- - Listen For Gamepad Input To Advance Or Make A Choice
- - If Appropriate, Exchange Objects, Money, Relationship Score
- - If Appropriate, Repeat Above 3 Steps
- - Update Game State Data And Return To Main Mode

- Menu Mode
- - Save/Load
- - - Update Game State Data
- - Informational Map
- - - No changes Possible
- - RNPC Relationship Stats
- - - No Changes Possible
- - Diary
- - - Update Game State Data
- - Inventory
- - - Update Game State Data
- - Equippage/PC Status
- - - Update Game State Data
- - Return To Main Mode

- Scripted Scene/FMV Mode/Travel Mode
- - Play/Skip
- - Update Game State Data And Return To Main Mode

- Subgame/Puzzle/Combat Mode
- - Play/Reset/Escape Subgame
- - End Subgame And Announce Results
- - Update Game State Data
- - Play Again/Exit?
- - Return To Main Mode

[Edited by - sunandshadow on August 22, 2005 7:36:55 PM]

I want to help design a "sandpark" MMO. Optional interactive story with quests and deeply characterized NPCs, plus sandbox elements like player-craftable housing and lots of other crafting. If you are starting a design of this type, please PM me. I also love pet-breeding games.

Forgive me if this is a little bit unclear, I'm not feeling the best today...

When I try to structure my projects into objects, I try to clump together the functionality into groups separate from each other, and which make sense as a group. The goal is for when the object is finished that you only care about the interface and not the implementation.

So for the high level objects I usually have something like Video, Audio, Input and World (and often a Logger class for errors as well, and possibly a MemoryManager class). Then within the Video class for example, I'd have a separate class for dealing with WindowedBoxes for your dialog, and so on. The World class has all the smaller classes for dealing with the state of the world, such as the TileMap or CritterManager.

Sorry, I'm not making an awful lot of sense at the moment. Basically the trick is to form everything into a series of black boxes with simple interfaces from each other, then figure out a good way for all the black boxes to talk to each other. I'm not sure if this is any help or even worth posting, maybe I should try again once my aspirin starts working [smile].

I suggest you take the time to read up on UML it should help explain everything you need to know about designing classes and their interactions between other classes.

Try taking a look at this link:
UML
ClassDiagram
Just a warning: too much up front design tends not to survive contact with real code. Don't spend too much time with large UML diagrams or other complex class/object hierarchies at first. Do a rough outline, then do your first prototype. That prototype will be more help at figuring out how your classes should look than entire weeks of staring at charts.
Quote:Original post by SiCrane
Just a warning: too much up front design tends not to survive contact with real code. Don't spend too much time with large UML diagrams or other complex class/object hierarchies at first. Do a rough outline, then do your first prototype. That prototype will be more help at figuring out how your classes should look than entire weeks of staring at charts.


I'll second that, if I were to start the design process over now with the current prototype I'm building I'd have a design doc about 10 times the length as the last.. but with that said, if I'd had more time to work on the initial design doc I'd be having a much easier time in designing the prototype, which would lead to a much better visualization of the next design doc.

I'll probably be able to come up with a really nice RPG design doc in September after the prototype, being able to see an OO design beforehand would be cool, but I'd probably end up creating my own if I didn't see one anyway.


edit: Has anyone read Game Architecture and Design by Andrew Rollings? I was linked to it with the description of "object oriented game design in C++ focusing on solutions for RPGs."

[Edited by - ferr on August 20, 2005 12:37:19 PM]

This topic is closed to new replies.

Advertisement