Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / object oriented query

Author
Message
Cras
22
Years of Service
User Offline
Joined: 15th Oct 2002
Location: United Kingdom
Posted: 16th Jan 2006 13:46
im thinking about getting the dark game sdk when its compatible with the new visual c++ express, however im curious. it says in the sales bumf u can use object oriented code, but when making a 3d object eg.

dbMakeObjectCube ( 1, 10 );

you still have to number the object. is that object number still a global value, or specific to the class you make it in?

uk.geocities.com/maniacimagine check it out. ill soon be formally opening it.
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 16th Jan 2006 14:05 Edited at: 16th Jan 2006 14:06
It actually says : Combine all of this with the features that C++ offers such as the chance to use object oriented cod, which means that your own code can be object-orientated, but DarkSDK isn't (or rather in most parts it isn't, but 3D objects can be, using sObject-><function> )

So, to answer your question the idNumber is global, and the same number can be used everywhere to create (or delete) stuff.

Blog:http://spaces.msn.com/members/BouncyBrick/
Web Site:http://www.nicholaskingsley.co.uk
Smoke me a computer chip, I'll be baking breakfast.
Kaiyodo
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: UK
Posted: 16th Jan 2006 14:06
The DarkSDK functions themselves are just the DBPro functions with slightly different names, they haven't been converted to C++. You'll have to wrap the functions in your own classes if you want to make them object oriented.

One of the first things I wrote when I got the SDK was a resource manager class so that I did't have to use object numbers everywhere

Kaiyodo.
Cras
22
Years of Service
User Offline
Joined: 15th Oct 2002
Location: United Kingdom
Posted: 16th Jan 2006 14:20
thanks, i didnt think so but figured i wud ask anyway. been a while since ive been on these forums.
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 16th Jan 2006 15:00
Kaiyodo has explained it exactly as it is... you would use the existing DB functions inside a class that you could build and resuse to implement more complex and variant descendants of that class...

... which, in turn would make your development much easier

--Mike
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 16th Jan 2006 16:44 Edited at: 20th Jan 2006 10:26
I stopped to wrap all dgDK commands inside my classes, but use more complex and specific methods that use the db...commands inside the methods.

For "pure" db...commands I use the ID from the objects (which is stored inside the classes).

I found it quite great to have the objects stored inside a custom map-container.

Then I use commands like "dbPickObject(...)" somewhere in my code.

The ID range I get from my containers, for example, the ObjectContainer for "Item"-objects.
And the ID returned by it (->dbPickObject) I use with the map-container to get the pointer to the actual object.
The object has attributes like Color, a unique name, a tag, etc

So, with the example, if dbPickObject returns a value > 0 then I KNOW that it is a "Item"-object and also can get the Unique Tag, the "name", the color, the texturename, .. everything I decided to store inside the object-class.
But I dont put commands like dbMoveObjectDown() etc into my classes,
first, this will be only a wrapper so it probably steals some frames from my app. (imagine thousands of objects) (Maincode calls method of object, object calls DarkGame library.) I decided to call them directly. (Maincode gets id from object, maincode calls db-command( ID))

But I implement methods that describe a more complex behaviour of the object which then will use several DarkGame commands to do it.


Unfortunately, the dgSDK isnt OOP.. in the newest beta though, you will get the STRUCTURE (in this case, a class with only public attributes (and methods?)) of the object which provides good informations already.
(as described in the posts above)

Well,... It took some time for me to figure out what framework I have to setup. IDGenerators, IDManagers, then base-classes, the Objectfactories etc etc. but it works quite well!!

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 16th Jan 2006 18:07 Edited at: 16th Jan 2006 18:09
the DBSDK isn't OOP, but that shouldn't stop you from writing up an OOP based engine with it from the ground up...

you don't have to encapsulate the entire api... jus tuse the functions that you need... i did something similar with 3Impact, which is very similar in structure to the DBSDK...

it is a straight c framework... just like the DBSDK is... set up the graphics and inital environment, then call the api functions in the main loop...

what i did was change things around so that it you could add new game objects, objects i derived from classes i created during set up of the environment, then enter the main loop, which called each objects update function, and away we went...

this way i never had to rely on the DB api, but simply call the methods for each object...

for example... the base object was the GAME object, which by default instantiated a PLAYER object (everygame has a player) and a VIEW object (every game has a view into it right...

my game has crewmen aboard a ship, so i would instatiate a new CREWMAN derived EXECOFFICER object, and call the PLAYER's SetControlObject method with the new EXECOFFICER object as the param... then i could call something like Exec.Walk() and the player would walk around...

i could also derive new CREWMAN type objects from the existing CREWMAN code which would inherit his behaviors and add additional behaviors...

this method of development is the only way to go as far as i'm concerned... the DBSDK api is encapsulated in the sense that once you make something, it becomes a 'black box' so to speak, exposing methods that on the surface make it easier to code the new game objects derived from them...

after all Exec.Walk() is a lil more logical to what a character might do, as oposed to move object 3,3,3 or whatever...

--Mike
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 16th Jan 2006 20:23 Edited at: 16th Jan 2006 20:25
If you dont understand my scribble above then:
I think similar to what Red Ocktober says

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
Cras
22
Years of Service
User Offline
Joined: 15th Oct 2002
Location: United Kingdom
Posted: 17th Jan 2006 22:44
thanks for ur help guys - i like the sound of a resource manager and can think of how to implement it to make my code OO so now i guess ill just wait for a dgSDK that works on 2005 express. Meanwhile ill plan my 1st project - an epic MMORPG that will rival World of Warcraft! - or just pong.
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 18th Jan 2006 11:07
Quote: "Meanwhile ill plan my 1st project - an epic MMORPG that will rival World of Warcraft! - or just pong."

lol

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
Dark Lord
19
Years of Service
User Offline
Joined: 19th Aug 2005
Location: Australia
Posted: 19th Jan 2006 07:10
Smithy did you use STL to implement your map container?
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 19th Jan 2006 08:48 Edited at: 19th Jan 2006 09:41
Yes I did.
For "testing" I just used STL but probably will switch to boost (www.boost.org) or a similar library later...
So far I have no performance problems.

//edit:
Every DarkGame-object class has a property (or attribute with setter/getter methods)
for the unique ID (=DarkGame ID).
When I instance a DarkGame-object class, I set the ID property
using my ID generators/managers and then,
when adding the instance to the container,
I get the ID from the instance and use it as unique identifier
for the map-container.

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
Dark Lord
19
Years of Service
User Offline
Joined: 19th Aug 2005
Location: Australia
Posted: 20th Jan 2006 00:14 Edited at: 20th Jan 2006 00:14
Did you set the ID from a static member function or is there some better way?
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 20th Jan 2006 09:40 Edited at: 20th Jan 2006 11:28
Hmm, let me explain the way I do it.
(dunno if it is BETTER)


I use some classes for ID generating
and then, set the generated IDs with a method or in the constructor
of my Game-object classes.

I try to give an example.
I need DarkGame 3d-object-IDs for my GUI (say textured Planes).


I use it like this:



//edit:
ps: l_ = local variable (and g_ = global)

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
Dark Lord
19
Years of Service
User Offline
Joined: 19th Aug 2005
Location: Australia
Posted: 20th Jan 2006 10:22
If I was implementing my own with the possible use of map containers from STL do you think it is better if I use strings rather then char arrays?
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 20th Jan 2006 10:32 Edited at: 20th Jan 2006 11:18
Well, that is your choice, I go with strings as I use stringstreams etc. and with the macro below I convert it to char-arrays if expected by various functions.

MACRO:


At the end, it is your choice, personally I go with strings as
they are more comfortable to use IMO.


//edit:
I use the ID and a pointer to my objects for the map.

std::map< int, CGUIButton*> containerMyGUIButtons;

For the example in the post above, I would use the following to do some stuff with the clicked object:


//edit: added how I would insert the button-object into the container.
And re-named the map-container so it would only work with CGUIButton-objects (of course, you can use a more abstract base-class or interface to store inside the container)

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
Dark Lord
19
Years of Service
User Offline
Joined: 19th Aug 2005
Location: Australia
Posted: 20th Jan 2006 10:51
Thanks for the help.
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 20th Jan 2006 11:11 Edited at: 20th Jan 2006 11:13
You're welcome, DarkGame fellow and I am glad to help if I can...!

...but please don't blame me if something doesn't work as you expect hehe

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
Dark Lord
19
Years of Service
User Offline
Joined: 19th Aug 2005
Location: Australia
Posted: 20th Jan 2006 11:40
Sorry about all the questions but what would I do if I wanted my map container to return a pointer to a BASE_CLASS object when I enter a string or an ID, and what if I want to get the object ID from the string? <- This way would allow me to give my objects a name tag.
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 20th Jan 2006 13:24 Edited at: 20th Jan 2006 13:33
Hmm, I dont understand a part of your question ...

Quote: "
what if I want to get the object ID from the string?
"


But if you want to use tag names, there are several options.

-If you only use tag names, you can use a map that stores the pointer with the tag name as unique identifier instead of the ID.
map< string, BASE_CLASS*> (string is the tag)

This is not a good solution usually as the DarkGame engine returns only the ID.

The other thought I have:
-If you want to get an object with a certain tag using a map like I described before (so: map< int, BASE_CLASS*> when int is the ID),
you would iterate (using iterators) trough the map and check every objects tag and return the matching one.
PSEUDO CODE


Then you can get the ID from the object you get. (assuming you provide a getter-method for the ID which is has to be an attribtue of the BASE_CLASS )


//edit:
ps: I have to go to a meeting right now so I will answer later

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
Dark Lord
19
Years of Service
User Offline
Joined: 19th Aug 2005
Location: Australia
Posted: 20th Jan 2006 23:38
Thanks for the help. I found a CD yesterday with the full STL documentation, I will study map containers and implement them in my object system.
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 23rd Jan 2006 12:04
Right... as my example of iterate trough the container..
is not a good technique for "accociative" containers like a map!



Anyway, you're welcome and I am sure you will find a solution

--smithy

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;

Login to post a reply

Server time is: 2024-11-19 04:34:20
Your offset time is: 2024-11-19 04:34:20