OOP Game Layout / Program Flow

BlitzMax Forums/BlitzMax Beginners Area/OOP Game Layout / Program Flow

boomboom(Posted 2008) [#1]
Hi, I assume there has been discussion before about general OOP design for games and program flow, scene management etc..

Does anyone have some good resources (my search came up sparse).

I don't need 'how do i program in oop?' type information more 'right, i get opp, how do i lay everything out to take advantage of it'.

Thanks


tonyg(Posted 2008) [#2]
I have been looking for quite a while.
This got a big fat zero responses. and I have never seen everything covered in one area although A FLEXIBLE AND EXPANDABLE ARCHITECTURE
FOR COMPUTER GAMES
is interesting.
A typical response on gamedev is to read "Design Patterns :
Elements of Reusable Object-Oriented Software" which lists recurring design patterns but I am sure there is scope for a book on the subject.
Maybe Game Code Complete will help but it never gave me the detail that those articles in my link gave for invidiual components : Does that make sense?


boomboom(Posted 2008) [#3]
Its weird this isn't more widely covered and discussed, I would assume everyone goes through this at some stage of their 'learning oop' life?


MGE(Posted 2008) [#4]
The only thing I use OOP for is a few classes (types). Otherwise I just use the standard function based programming methods like I've always used. That's the beauty of Blitzmax. All the OOP is there, when/if you (need it) or (want to use it).


boomboom(Posted 2008) [#5]
Interesting MGE, that's similar to what they say here: http://www.gamedev.net/community/forums/topic.asp?topic_id=373866


ImaginaryHuman(Posted 2008) [#6]
OOP is just another part of the picture, not all of it. Sometimes things are easier and better done procedurally. Nothing wrong with that.

For example, in my engine I have this one sort of `node` type, of which there can be many, which contains multiple `extensions` (custom types). Each sub type then contains usually either other sub types or arrays of data. For example, for sprites/particles I have parallel arrays of data, like an array of X coords, an array of Y coords, etc, rather than like one whole new type for each particle with an isolated single set of data. Putting all of the data inside the enclosed world of a custom type for every single object isn't necessarily efficient. It's handy for creating and removing items, but it can decrease performance. I try to opt for a blend of oop and procedural, plus a blend of linked list-style object storage and array-based.

You need to look at what vision you have for your game or games, and then what subsystems it's going to need. OOP is really, in a way, just about fragmenting stuff, separating things out, and keeping all stuff relating to the same topic or area in one place. One place for all your graphics stuff, one place for all your sound stuff, etc. The idea is to think of your game/engine as a collection of `objects`, or to map objects/types to areas/concepts in your game. Supposedly that's what oop is good for, organizing stuff, creating a structure, laying things out, grouping things together, keeping stuff that has nothing to do with graphics away from the graphics code, etc. That way you get a cleaner application, you can easily change one area without affecting all the other areas, instead of having stuff strewn all throughout the whole thing.

With procedural coding, and especially if you tend to hard-code stuff, you could essentially have your graphics and audio and physics and AI code all sort of blended in together in various places throughout your code. Then it's hard to manage it, hard to modify it, hard to find it, etc. It's too specific. Using `objects` (type) is an attempt to get a little bit more abstract, group things under a generic `type` of object or data. Instead of having one big hardcoded ultra-procedural mishmash of hacked together solution-specific code, you can make things easier to manage and modify and keep track of by getting it much more organized. Even if you end up doing lots of procedural stuff within the various custom types, that's fine, but at least a little use of types will help you out.

One thing I found before I used types, was that I would end up with a pretty big program, maybe a lot of functions, not very much structure or order, and I just couldn't SEE. It's like being in the middle of a dense forest of trees where you can only see the trees all around you and no clearings, no paths, no organization, no standardised protocols for accessing information, and it's all very locked-in and hard to expand or add to. It can be quite confining. Oop is more abstract and open and generalizing and standardizing, which helps for the most part, up to a point. Once I started to group things together and keep them away from other unrelated parts, I found it much easier and more freeing to be able to see how to expand and add stuff.


dmaz(Posted 2008) [#7]
my approach is different but digesteroids which shipped with bmax in the samples directory is an example. check out dynamicgame.bmx and how it's implemented in the main source.