Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am writing a simple 2D game (for mobile platforms) for the first time. From an abstract point of view, i have the main player controlled by the human, the enemies, elments that will interact with the main player, other living elements that will be controlled by a simple AI (both enemies and non-enemies). The human player will be totally controlled by the player, the other actors will be controlled by AI. So i have a class CActor and a class CActorLogic to start with.

I would define a CActor subclass CHero (the main player controlled with some input device). This class will probably implement some type of listener, in order to capture input events. The other players controlled by the AI will be probably a specific subclass of CActor (a subclass per-type, obviously). This seems to be reasonable. The CActor class should have a reference to a method of CActorLogic, that we will call something like CActorLogic::Advance() or similar.

Actors should have a visual representation. I would introduce a CActorRepresentation class, with a method like Render() that will draw the actor (that is, the right frame of the right animation). Where to change the animation? Well, the actor logic method Advance() should take care of checking collisions and other things.

I would like to discuss the design of a game engine (actors, entities, objects, messages, input handling, visualization of object states (that is, rendering, sound output and so on)) but not from a low level point of view, but from an high level point of view, like i have described above.

My question is: is there any book/on line resource that will help me organize things (using an object oriented approach)?

Thanks

share|improve this question
    
Search SE and the web for Component Architecture or Component Oriented Design or the like.. I think it will fit in nicely with what your thoughts currently are on design. –  James Nov 18 '11 at 19:33
1  
Component architectures may be a bit heady for someone new to OOP and writing their very first mobile game. Components are a solution to complex problems that our friend here won't experience until he's got some experience under his belt, IMO –  Patrick Hughes Nov 18 '11 at 20:28
    
@PatrickHughes Reading his description of having an object for the actor, then an object for the actors AI and then an object for the Actors representation... Well that sounds like a person already thinking in component design who might be better off just looking into them directly to answer the question of where does the animation data go –  James Nov 18 '11 at 22:00
1  
@James It's certainly a good first step in that direction and normally I'd totally agree because I <3 that stuff; but it's also the first step to breaking down a design to objects. To someone making a simple game for the first time using components is like using an elephant to hammer in a nail, messy for all concerned and you need to borrow heavy equipment. –  Patrick Hughes Nov 18 '11 at 23:03
    
You might want to check out this. A great collection of component-based design information. –  Mike C Nov 19 '11 at 1:50

1 Answer 1

"Organizing things using an object oriented approach" is a subset of Computer Science. It has nothing to do with "games," it is simply how programs are put together.

Since you're talking about an "abstract point of view" search online for references to OOAD (object oriented analysis & design), or if you like books the Head First series is really really good. This will give you mental tools to break down problems into object oriented designs.

Those designs you can then implement in your OOP language of choice, for mobile phones that's probably Java or Objective C.

Now that I've completely divorced the "game" thing from your question, the programmer's stack might be a better place to get OOP design answers. Then back to here at gamedev stack for specific questions on efficient rendering, GUI options, game state handling, audio and things like that.

After that go take a look at the mobile platform SDK that you're writing for. Even odds bet that they have sample code for a simple, 2D graphics display and probably a scrolling map with sprites and a main loop.

Another resource will be to check out commercial mobile game engines, they typically have design overviews showing how their systems fit together and they will have forums that you can use to get an idea of how people are using their system design and the problems they have.

share|improve this answer
    
I think i didn't expressed myself clearly. Writing 2D (and 3D) games in general should be an 'old' established practice. Using an OO approach for this purpose too. What i am really asking is: where can i find informations about how people already "solved" this design problem (classes identification and design, how to handle world updates, messages, etc..). It is like writing a low-level 3D engine: people are writing 3D engines since 15 years (more for 2D games), so i think that has emerged a 'standard' way to design such softwares. Just to have a good starting point... –  lukeluke Nov 18 '11 at 23:23
    
It's not a solved design problem. Game development is best seen as an R&D effort to maximize sometimes conflicting needs in deeply connected systems. The balance between hardware and software is constantly changing and beyond that the fact that the typical game industry lifetime is only 5 years means that a lot is reinvented every cycle. So the best idea really is to take lessons from outside the industry and apply them because inside the industry you won't find a consensus. –  Patrick Hughes Nov 19 '11 at 0:15
    
R&D apart, i am speaking more about pure design, not thinking too much about optimization. Let's talk clearly: there are thousands of 2D games, all with animated characters, physics, AI, input, sound output, game logic and so on. How would you describe, using an OO approach, this situation? Since i think there are a lot of 2D games (engine (low-level part) + game logic (high-level part)) programmed from 1980, i thought that some good book could present this in a clear and robust (that is, used in real projects with success) and that could be a good starting point... –  lukeluke Nov 19 '11 at 7:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.