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 / Few questions before diving in

Author
Message
Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 5th Feb 2006 05:45
Im pretty new to c++, but im very confident I can pick it up. Ive used DBPro for many years, and im finally starting to feel the constraints. Its time to start writting like the big boys.

Anyway, couple quick questions...

1.) Is it possible to tell if a variable or array has already been declared? My architecture is a sort of 'central data store', so I need each subsystem to make sure all required variables are declared, incase one of the other systems (which might also use the same data) is not initialized.

2.) Can a 'system' have its own local functions? Meaning they can only be called by that system, and they can have duplicate function names of functions in other systems?

3.) Are there easy ways to 'pass' data to/from systems? Again this is a central data store architecture, so the only interaction one system has with another is through data. So I want to send a list of variables, arrays, ect... to a system, let the system process that data, then 'return' it to the central data store. What are my options here?

4.) In a nutshell can anyone explain the concept of 'classes'? Ive heard a lot, but know very little.

5.) Any known issues with Dark SDK and VS 2003?

6.) Will all my plugins work with Dark SDK? 3d cloth and particles, BLUE gui, ect...?

Thanks in advance

All you need is zeal
Acolyte
18
Years of Service
User Offline
Joined: 3rd Feb 2006
Location:
Posted: 5th Feb 2006 07:10
While i'm not new to c++, i'm not a guru by any means, but i'll try my best to help you out. In response to your questions:

1.) Your compiler will tell you when you try to compile of you are trying to use a variable that hasn't been intialized, so you really don't have to worry about screwing up here.

2.) I'm not quite sure exactly what your defining as a 'system'; however, inside a class, or you can have multiple function calls. Classes are like declaring types in DBPro, but their much more indepth in c++. You can't declare another function inside a function as far as I know. This one is a little hard to answer with a short answer because there are so many possibilities in c++ such as structs, unions, classes, templates, etc.

3.) The good news here is that passing variables in c++ is almost the same as in DbPro. The only difference is that when you use the function you have to make sure it's declared at the top of the file your currently in. As far as returning your data, all you have to do is use the return command just as in DbPro, and with classes you just put the return statement outside of the class followed by a semicolon.

4.) Glad you asked, Classes are just like Types in DbPro. I like to think of them as declaring your own data type. You can declare things like integers, doubles, floats and things like that, and after you create a class with it's own data members you can use that like it's own data type. Just check your DbPro manual to refresh your memory. Granted Classes are a lot more in depth than Types, but I could go on forever about that.

5.) I'm using VS 2003 with my Dark SDK, and it's going very well so far. There have been talks with updating the next version so that it can run with DevC++ and possibly VS 2005. I hope so, cause the 2005 version is free right now. The only issures your likely to run into with writing in Dark SDK are probably from the DarkSDK.

6.) Sadly no. Things like BLUE gui were developed specifically for DbPro, and since c++ is run from within a totally separate program there is no correspondance. Now other things like developing with plugins so that your app can use the plugins should work. If you have a plugin that does calculations, or takes advantage of the Windows API then they should still work because they're all compiled into a universal DLL.

Hoped I helped a little bit. If you have any questions just e-mail me. Happy coding!

The scarecrow has no mind, but serves its function well.
Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 8th Feb 2006 04:45 Edited at: 8th Feb 2006 04:49
Well the reason I asked about checking to see if a variable had already been declared wasnt for user/compiler issues, but rather program/architecture issues. I plan to INTENTIONALLY declare the same variables multiple times for each of my sub programs/systems.

Why? Because my architecture is a central data store. For example, I would initialize one program (timeofday) and declare some common variables (I dont want them to be global, I guess they are 'main loop variables'). These common variables would sit (again I guess in the "main loop area"), then get passed to the various sub programs, processed, and eventually passed back to the central data store (main loop).

The purpose of all this is, there are never any system to system dependencies. No system is allowed to call the functions of another system. A system simply requests data from the main loop, processes it, then spits it back out. However, since all systems are working with the same data, they are in essence working with each other.

The problem is, since a 'timeofday' program uses a 'time' variable to keep track of the time, and the 'sky' program might also use that same variable to determine what color the sky should be, I NEED to declare the variable twice in both programs, just incase one of the programs isnt initialized (or even included period). Otherwise one system might request a 'time' variable to process, the main loop wont have it declared, then everything freaks out and crashes.

There was a really interesting article on gamasutra about this whole architecture. Ill post the link when I get home.

* also on a side note, I understand what types are (use em all the time in dbpro) but dont understand what a class is. How is it MORE than myvariable.xpos, myvariable.string, ect...

All you need is zeal
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 8th Feb 2006 10:58 Edited at: 8th Feb 2006 11:00
Quote: "* also on a side note, I understand what types are (use em all the time in dbpro) but dont understand what a class is. How is it MORE than myvariable.xpos, myvariable.string, ect..."


A class is basically a type with its own functions.
The public functions (that you will use when working with an instance of your class, the object) are the "methods" of the object and describe the "behaviour" of the object and are used to access the private members called "attributes".

Usually, you dont access things like myvariable.xpos, but rather use a setter/getter function like myvariable.get/setXPos().
This will give you the advantage to do checks or changes etc inside your getter method and not affecting the main-code (the code that calls the methods).
The setter/getter will ensure that you always have a valid value.

Better though you look at some of the millions of OOP tutorials

//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;
Paisleys finest
19
Years of Service
User Offline
Joined: 11th Nov 2005
Location: In a house
Posted: 9th Feb 2006 17:24 Edited at: 9th Feb 2006 17:26
Ahem

Just to expand on Smithy's point-> A type with methods and private data is nothing special in C++. Even structs can have these.

The whole point of using classes is not only to abstract (hide) the implementation details from the clients (the people who develop with the classes YOU make) but also to derive new classes for your own use. In OO terms, you can take a class and specialize it. (See Rational Rose terms for Generalization and Specialisation)

Classes are the only types in C++ that permit you to inherit their characteristics and change their behaviour (via the virtual method mechanism).

See the term PolyMorphism for more info.


PS (I hope this doesn't start a C++ war)

The "hidden" members of the class are not called "attributes" in C++. Attributes are something else entirely. The hidden members are referred to as member data or fields

Using a "getter/setter" method to access private (hidden) data is also known as encapsulation.

Right, I'm gettin the hell out of here before this explodes into a flame war

PPS:
If you're using shared data, why don't you just use a database system? Even a microsoft access database will suffice, and you don't even need Access running on your PC for you to read/update them (there is a native ODBC driver on Windows for Access). Don't re-invent the wheel unless you don't have to...

Regards, Scott T.

Looking for mature software developer to finish my Bruce Lee remake.. apply via email to MSN address.
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 13th Feb 2006 08:11 Edited at: 13th Feb 2006 08:24
Quote: "Attributes are something else entirely. "

Strange, I have learend that "member data" is also called attributes, (well, maybe not restricted to C++ only but in general OOP that is)
say I create an UML diagram, they call it attributes and methods/operations.?? Anyway, I can live with "member data" hehe

ps: no matter for starting a flame war

//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;
Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 14th Feb 2006 02:20
Thanks for the input guys I have been reading several books, and I really have a good understanding of classes now. answered most of my other questions in the process too

All you need is zeal

Login to post a reply

Server time is: 2024-11-19 04:24:41
Your offset time is: 2024-11-19 04:24:41