|
Shog9 wrote:
It would be called twice. That probably isn't what you want. So don't call it from both.
Damn, thought so. The problem is that it must be called from both as their are other objects which in turn inherit from either AnimatableGameObject or InteligentGameObject . A thought has just struck me...
** don't all say "uh oh" at once now **
If I add a parameter to each virtual function of the direct sibling objects (those like Son , Daughter , etc) like thus...
Frame([normal parameters...], bCallRootClass)
...then PlayerGameObject.Frame would look like this:
PlayerGameObject::Frame([normal parameters...], bCallRootClass)
{
AnimatableGameObject::Frame([normal parameters...], bCallRootClass);
InteligentGameObject::Frame([normal parameters...], bCallRootClass);
if (!bCallRootClass)
GameObject::Frame([normal parameters...], bCallRootClass);
}
And then do the same sort of thing in the AnimatableGameObject.Frame and InteligentGameObject.Frame methods.
That *should* work, no? The hierarchy would never go more than three deep, and it is only on the first sibling "stage" that mutliple inheritance would take place.
One 18yrs male, red and white, good condition; daily servicing required. £500 collect ono.
|
|
|
|
|
David Wulff wrote:
A thought has just struck me...
Ok, now you're *really* getting overly complex.
I wish i could remember, i just read a nice little technique for handling situations such as this... might even have been on CP. Can't recall
But anyway, the gist of it is this:
- In the base class, have two methods. One,
DoFrameStuff() is not virtual, and implements the code you want shared between all derived classes. The other, Frame() is virtual, and just calls DoFrameStuff() (if you won't be instantiating (sp?) the base class, then just make it pure virtual). - In each derived class, implement a new version of
DoFrameStuff() that does only what the derived class adds, and doesn't call the base class method. Also implement Frame() as calling only DoFrameStuff() and BaseClass::DoFrameStuff() . - In the grandchild class, implement
Frame() as calling Child1::DoFrameStuff() Child2::DoFrameStuff() and BaseClass::DoFrameStuff() in order.
In this way, you have absolute control over the order in which the methods are called at each point. I admit, your system may be a bit more complex than this (my description assumes fairly simple interdependancies between each of the methods), but working from this basic structure it shouldn't be too difficult.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
Thanks, your idea looks good.
One 18yrs male, red and white, good condition; daily servicing required. £500 collect ono.
|
|
|
|
|
David James Wulff wrote:
Thanks, your idea looks good
<cough>godhelpus
I'm not a real reverend, I just play one on CP.
|
|
|
|
|
If I might be so bold, David, I think your entire paradigm here is flawed. From what little bit of information you provide, it would seem to me that the concept of a "GameObject" itself is the issue. What the heck sort of *thing* is a gameobject? IMHO, the object you need here is a Frame object. A "frame object" is a concrete concept which you could build a logical class structure around, a "game object" is not. That is the core of your problem.
A frame object would encapsulate frame related data which could be acted upon by such methods as:
UpdateAnimation();
UpdateAI();
etc...
The data contained within the frame object could relate to individual items of game logic which you might refer to as a "Game Object". But, I think if you reversed your thinking and made the game objects belong to the frame, rather than the frame object belonging to the game objects, you would benefit from a cleaner design.
I'm not a real reverend, I just play one on CP.
|
|
|
|
|
Reverend Stan wrote:
If I might be so bold, David
How dare you be so bold! I shall have you hung drawn and quartered for this!
As I said, I am learning here - any input is welcome!
Reverend Stan wrote:
A "frame object" is a concrete concept which you could build a logical class structure around, a "game object" is not.
I understand what you are saying, I think. I just don't see how the Frame object would work withing the system.
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.
All this is supposed to make it easier to add new game objects using external scripts - well that was the idea anyway.
Have I totally missed something here?
One 18yrs male, red and white, good condition; daily servicing required. £500 collect ono.
|
|
|
|
|
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.
|
|
|
|
|
David Wulff wrote:
Could I do something like
Yes, that will work (but will also cause Parent.Frame() to be invoked twice). You can easily get around this problem by passing the current frame id in the call. Each Frame() method can ignore the call (i.e. do nothing) if it's already been invoked for this frame.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
The problem you're facing is a classic. Some people call it 'dreaded diamond hierarchy'. I'd recommend reading 'Effective C++' by Scott Meyers; item 43 could shed some light.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Hi Tomasz, thanks for the recomendation - I'll add it to my huge list of things to buy when I have the cash.
One 18yrs male, red and white, good condition; daily servicing required. £500 collect ono.
|
|
|
|
|
I am a very new programmer and Visual C++ 6.0 is the first programming I have been learning. I am not very familiar with the terminology. I am trying to put a bitmap on a button using the CBitmapButton function. However I am getting the error "error C2065: 'pParentWnd' : undeclared identifier".
I don't know what 'pParentWnd' means or how to declare it.
Thank you.
Stone
|
|
|
|
|
Hard to say without seeing your code.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi,
I have noticed that some programs can get the contents of a selection, and do something with it one a global hotkey is pressed.
Some of them are spell checkers that will spellcheck the selected word in almost any application, some of them are telephony applications that will try to dial the selected text as a telephone number.
Does anybody know how to do this?
I have tried to get numerous samples, including the PC Magazine Robotype, but this program only knows which text that has been written.
Any help would be greatly appreciated!
Thank you for reading this far
Christian Skovdal Andersen
|
|
|
|
|
To get HWND, use GetForegroundWindow (not GetActiveWindow). Then, you can check if it's edit or richedit control, and if this is the case, grab the text with EM_GETSEL.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Glad to see your response. I have been looking for an answer to a similar question for a while! Can you tell me how to get to the selected text if the foreground window is not itself a edit control or richedit control but contains such controls? What about accessing a selected text in IE browser? Would appreciate very much your answers to these questions!
Gene Yu - gene4yu@yahoo.com
|
|
|
|
|
Hi!
I need to know the font's the user has set (Desktop - Right Mouse Button ->Properties->Third tab from left... I'm doing a custom control and need the font's to share the common appearance
|
|
|
|
|
Something like :
<br />
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);<br />
hFont = CreateFontIndirect(&ncm.lfCaptionFont);<br />
There are other fonts in ths struct, I don't know which one you need.
|
|
|
|
|
Hi
anybody can help me figuring out how to learn the scroll bars "arrow buttons" size? I need to use these and user paint ALL the stuff in between as well as handle all the mouse input. How can I get the exact size of these arrow?
Thanks
|
|
|
|
|
SystemParametersInfo() should give you that information. Probably the SPI_GETNONCLIENTMETRICS action.
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
GetSystemMetrics()
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I'm trying to show an Open File dialog but it won't show and i can't figure out what i'm doing wrong, here's the code:
{
OPENFILENAME ofn;
char szFileNames[(MAX_PATH+1)*1000+2];
const char szFilter[] = "MP3 Files (*.mp3)\0" "*.mp3\0";
szFileNames[0] = 0;
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = ghWnd;
ofn.lpstrFilter = szFilter;
ofn.lpstrCustomFilter = (LPSTR)NULL;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFileNames;
ofn.nMaxFile = sizeof(szFileNames);
ofn.lpstrFileTitle = NULL;
ofn.lpstrTitle = (LPSTR)NULL;
ofn.Flags = OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = "mp3";
GetOpenFileName(&ofn);
Thanks in advance
-Rune Svendsen
|
|
|
|
|
The dialog shows O.K. for me. The only diference was I tested it with hwndOwner set to NULL. Is the owner window (ghWnd) valid and displayed window?
Sonork 100.15206;PavelK
|
|
|
|
|
I'm making a little program using VC++.net these days. But when I run my program(.EXE) on a computer without VC++.net installed, it asks for msvcr70.dll, so that I have to put this DLL together with that program. This troubles me a lot. The Property Sheet of my project has been checked carefully, what else could I do?
Thanks a lot for any hint.
Tiny Flying Elephant loves flying...
|
|
|
|
|
Well, they have to have .NET framework installed. It can be downloaded from Microsoft[^]
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
You can deploy your program using the Deployment Wizard in Visual Studio, then merge the VC++ Redistributable Merge Module with you setup files.
|
|
|
|
|