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 / code not working right

Author
Message
Dragonslayer
20
Years of Service
User Offline
Joined: 4th Nov 2003
Location: New Lenox Illinois U.S.A.
Posted: 14th Dec 2004 08:36
I have been trying to get thid code to work. It will print out the word answer but it does not print the answers.

Is there any tutorials for the SDK yet? I'm not really getting much from the help files.
Dragonslayer
20
Years of Service
User Offline
Joined: 4th Nov 2003
Location: New Lenox Illinois U.S.A.
Posted: 14th Dec 2004 09:19
Well has anyone checked out my code yet? I have been playing around with it and still can't get it to print the answers. I know this is easy I just can't get it!

In regular c++ it would be
cout << "Answer is " << answer endl;

I have tried different variations of the db command but can't get it. Is there examples of code uses in the help files cause I can't find them!
Steve O
AGK Bronze Backer
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: The Netherlands
Posted: 14th Dec 2004 10:11 Edited at: 14th Dec 2004 10:16
like this:



billy the kid
19
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 14th Dec 2004 10:12
Well why do you have quotes around Answer when calling dbPrint()?

I dont know how dbPrint() works, but you never put quotes around an actual variable in c++. I would suspect that you either need to do:

dbPrint(Answer);

OR

dbPrint("%d", Answer);

But again Im not sure how you are supposed to use dbPrint(), but I bet the reason it isnt working is those quotes.
Dragonslayer
20
Years of Service
User Offline
Joined: 4th Nov 2003
Location: New Lenox Illinois U.S.A.
Posted: 14th Dec 2004 10:28
That works but I wanted to see how it prints an answer like this

int answer
answer = 2+2
print answer
Steve O
AGK Bronze Backer
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: The Netherlands
Posted: 14th Dec 2004 10:52
like this:

dbPrint(dbStr(answer));

or

dbText(0,0,dbStr(answer));

Dragonslayer
20
Years of Service
User Offline
Joined: 4th Nov 2003
Location: New Lenox Illinois U.S.A.
Posted: 14th Dec 2004 10:55
Ok that did it

thanks
Dragonslayer
SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 14th Dec 2004 11:01
I think they need to simplify a few of the commands. Plus you shouldn't have to pass the value off to a string conversion to get it to print. Maybe use cout and cin if possible. They should really change the name to Dark C++ and start removing commands that make no sense when C++ has commands that do similar things.
I can deal with having to pass data to functions in C++, it's just having to call a bunch of functions within a function to get a result. Of course if you wanted to get technical, you could say that's how we program in C++ with main() being the controlling function of the entire program and us having to call functions within main() to do something.
SoulMan

This is as backwards as is This
Dragonslayer
20
Years of Service
User Offline
Joined: 4th Nov 2003
Location: New Lenox Illinois U.S.A.
Posted: 14th Dec 2004 11:06
I was thinking the same way, can we use cout and cin here?
Steve O
AGK Bronze Backer
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: The Netherlands
Posted: 14th Dec 2004 11:16
cout and cin is console application stuff, where as the text displayed with DGSDK is rendered onto the DirectX backbuffer.

SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 14th Dec 2004 12:01
Whoops, my bad. What I should have said, can we have something similar. I realize that those commands are availible through iostream.h(Yes I know it's now <iostream> for the console and that anything we do would have to be completely different. What I am asking for is a command set that is similar.
SoulMan

This is as backwards as is This
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 14th Dec 2004 16:09
Quote: "Plus you shouldn't have to pass the value off to a string conversion"

You always have to convert it as the commands keep to the DBPro layout.

Beware the cat... The alien... The heretic...
SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 15th Dec 2004 02:51
TCA,
I understand that the commands need to keep to the DBPro layout however, with templates, you should be able to pass it as any data type to handle the printing job. If you think about it, DBPro already handles this. You can just type print a and whatever value a is, it will print. If you type print "a" it would print a lowercase a. The Dark SDK is not about just keeping with the DBPro program. It's about moving on to other languages. With what Mike has posted, I don't think this will be a problem.
http://forum.thegamecreators.com/?m=forum_view&t=44262&b=22
SoulMan

This is as backwards as is This
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 16th Dec 2004 00:08
Thats the thing with BASIC - it does a lot of work for you, whilst C doesn't.

Beware the cat... The alien... The heretic...
SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 16th Dec 2004 02:53
What do you mean it doesn't do a lot of work for you. I believe that you have at least looked through some of the headers that are used for console programming. Such as iosteam(istream and ostream) and stdio? Here let me provide a copy of my istream header from the Dev-CPP install. It features templates and operator overloading for input.

Now if you wanted something that would do nothing for you unless you programmed it in, try assembly or machine code programming.
Without headers in C++, you would have the same exact thing. Unless that is what you are attempting.
SoulMan

This is as backwards as is This
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Dec 2004 04:08
Hmmm. I think that you are each missing the others point. One of you is talking about C, and the other is talking about C++.

I think it unlikely that Mike will release any templated code. Or if he does, it will be minor stuff. This is because templates pretty much commit you to releasing source code, and I don't think that will happen. Besides, he can get the same effect most of the time by providing overloaded functions instead.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 16th Dec 2004 10:43
IanM,
I believe that's correct. Now about the templates, I am not talking about releasing the templates. I am talking about templating some of the functions for the Dark SDK. For example, the print function. Instead of having to convert numbers into strings, you just pass a number value, the function determines based on a template what type of value it is and then throws the result of that value to the correct operation base on it's type. Just how cin and cout works. printf and scanf I really don't care for. In fact, C programming I don't care about. C whilst not a bad language to still use, is no longer being taught as the standard. C++ is. C is offered more as a side course. I took C just so that I could at least learn the roots of C++. I just don't have a need for it. Programming wise with C++, things are handled better. Doesn't mean you can use C for programming games using Dark SDK though. Today if you want to learn a programming language, C++ is the preferred choice. Just as C was in the 80's, C++ is in the late 90's and now 2000 era.
SoulMan

This is as backwards as is This
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Dec 2004 20:04
Quote: "Instead of having to convert numbers into strings, you just pass a number value, the function determines based on a template what type of value it is and then throws the result of that value to the correct operation base on it's type"


That's overloading you're talking about there.

void Print(int a);
void Print(char* a);

Define a routine for each of your argument types, and let the compiler choose the best fit.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 17th Dec 2004 02:27 Edited at: 17th Dec 2004 02:28
IanM,
We shouldn't have to do that ourselves. If the commands for Dark Basic Pro such as the Print command was written to take several different types of data(Strings, Numbers, etc...) then the Dark SDK version should as well. Instead of having to do
Quote: "dbPrint(dbStr(answer));"
we should be to do this
Quote: "dbPrint(answer);"
The variable would be of any data type and the function could handle it.
If Mike were to overload the function for that, I think it would solve the problems above or like I said use templates.It would have to be done with a template function though.

http://babbage.cs.qc.edu/STL_Docs/templates.htm#T1

SoulMan

This is as backwards as is This
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Dec 2004 03:17
You are right in that you shouldn't have to write this code, but you are wrong about the templates.

Templates are not suited to putting different print functions together because they only handle different types, not different code.

The code to display an int is nothing like the code to display a string. That's why there should be code to display an int, plus completely different piece of code to display a string, or a float etc.



*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk

Login to post a reply

Server time is: 2024-03-29 15:42:25
Your offset time is: 2024-03-29 15:42:25