Click here to Skip to main content
15,921,660 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: OO design question Pin
Shog94-Aug-02 19:45
sitebuilderShog94-Aug-02 19:45 
GeneralRe: OO design question Pin
David Wulff5-Aug-02 1:33
David Wulff5-Aug-02 1:33 
GeneralRe: OO design question Pin
Shog95-Aug-02 5:14
sitebuilderShog95-Aug-02 5:14 
GeneralRe: OO design question Pin
David Wulff5-Aug-02 6:46
David Wulff5-Aug-02 6:46 
GeneralRe: OO design question Pin
Stan Shannon5-Aug-02 8:47
Stan Shannon5-Aug-02 8:47 
GeneralRe: OO design question Pin
Stan Shannon5-Aug-02 2:04
Stan Shannon5-Aug-02 2:04 
GeneralRe: OO design question Pin
David Wulff5-Aug-02 2:29
David Wulff5-Aug-02 2:29 
GeneralRe: OO design question Pin
Stan Shannon5-Aug-02 3:43
Stan Shannon5-Aug-02 3:43 
First, remember that I have never designed a game, so I probably have no clue as to what I am saying. I am just thinking of the problem, to the limited extent I understand it, in terms of OO.


David Wulff wrote:
A game object is an object in the game, be it a player or similar unit, a camera, a light, a helper object, etc. Each object when created will register it's interest in certain events (the example I have been using to-date is frame events). The events themselves are triggered and sent by the "Game" object (read: "CGame" not "CGameObject") which in turn takes care of the rendering, etc, etc.

What I am trying to do is to seperate all of the higher level game objects from the game itself, so as far as the game is conerned it only has a bunch of game objects to create, update and destroy. It never knows about animation, intelligence, states, etc, and it never knows if it is a player object or a camera - it just knows where it is and what it want's to know. It is by design that the "Game" object does not know anything about animation, inteligence, states, etc, either.


That all sounds like a good design except that you are trying to get these objects to share state information. The concept of a Frame needs to be abstracted out of the concept of a game object. If the game objects need to update on a frame by frame basis, than collectively, they represent the state of the frame at any given moment, not vice versa. On a frame event all game objects need to be given the chance to update, but they are all trying to update the same frame, because, obviously, there is only one frame per state (a singleton perhaps?).

Think of a frame not as a state that the game objects share, but as an entity that they belong to. They are *its* state. The frame is itself a game object. The frame is a state management game object. All the other game objects belong to it. It can serve as a kind of factory class which generates the game objects it contains in a polymorphic fashion, thus acheiving the extensibility you desire.

To me, the game object itself should only ever be aware of one thing - the frame, and the frame manages the game's state from moment to moment. You could then swap derived frame types in and out of a game to achieve a very extensible design.

I'm not a real reverend, I just play one on CP.
GeneralRe: OO design question Pin
Ravi Bhavnani5-Aug-02 3:37
professionalRavi Bhavnani5-Aug-02 3:37 
GeneralRe: OO design question Pin
Tomasz Sowinski4-Aug-02 23:51
Tomasz Sowinski4-Aug-02 23:51 
GeneralRe: OO design question Pin
David Wulff5-Aug-02 1:22
David Wulff5-Aug-02 1:22 
Generalusing CBitmapButton Pin
Mavrock4-Aug-02 11:58
Mavrock4-Aug-02 11:58 
GeneralRe: using CBitmapButton Pin
Ravi Bhavnani4-Aug-02 15:00
professionalRavi Bhavnani4-Aug-02 15:00 
GeneralGetting selected text globally Pin
Christian Skovdal Andersen4-Aug-02 11:19
Christian Skovdal Andersen4-Aug-02 11:19 
GeneralRe: Getting selected text globally Pin
Tomasz Sowinski5-Aug-02 0:07
Tomasz Sowinski5-Aug-02 0:07 
GeneralRe: Getting selected text globally Pin
Gene Yu14-Jan-03 8:56
Gene Yu14-Jan-03 8:56 
GeneralDefault font set for window's dialogs Pin
CaesarCZ4-Aug-02 10:28
CaesarCZ4-Aug-02 10:28 
GeneralRe: Default font set for window's dialogs Pin
pépé5-Aug-02 2:18
pépé5-Aug-02 2:18 
GeneralScrollbar size Pin
CaesarCZ4-Aug-02 10:22
CaesarCZ4-Aug-02 10:22 
GeneralRe: Scrollbar size Pin
PJ Arends4-Aug-02 12:40
professionalPJ Arends4-Aug-02 12:40 
GeneralRe: Scrollbar size Pin
alex.barylski4-Aug-02 16:51
alex.barylski4-Aug-02 16:51 
GeneralOpen Filename dialog won't show. Pin
redeemer4-Aug-02 8:43
redeemer4-Aug-02 8:43 
GeneralRe: Open Filename dialog won't show. Pin
Pavel Klocek4-Aug-02 10:06
Pavel Klocek4-Aug-02 10:06 
QuestionHow to link msvcr70.dll into my program in VC++.net Pin
tfElep4-Aug-02 8:40
tfElep4-Aug-02 8:40 
AnswerRe: How to link msvcr70.dll into my program in VC++.net Pin
Philip Patrick4-Aug-02 9:10
professionalPhilip Patrick4-Aug-02 9:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.