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 / I have a question about the while loop in DarkGDK

Author
Message
Dragon slayer
17
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 20th Apr 2013 19:24
I have been learning C++ and am trying to port something from DBP to DarkGDK. I am not really sure what goes in this loop. I have been looking at the example code and I have seen some things where the only things in this loop are calls to a couple of functions and there is also a do loop in the program called the game loop. I thought that this while loop was a game loop.

I put some code in the while loop and it ran but I don't know if it needs to me in this loop. All it is, is like a splash screen which displays the game name and an option to start or quit the game. There are some text commands and color commands. Should I put this in a function and call it from the while loop? Do I need to have a do loop as I have seen in some code examples.

Just not quite sure what needs to go in the while loop.
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 20th Apr 2013 19:55
Just think that the only things that need to go in the loop are commands that must be repeated, like commands getting input from the mouse or keyboard, moving/rotating an object, etc.

Another way to think of it is the loop is your game, everything before the loop sets up your game, the loop starts and the game is played, and everything after the loop cleans up the game.
Dragon slayer
17
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 20th Apr 2013 20:21
Ok I understand that and kind of thought it needed to go that way so I will re-structure my code. If you are still on here, another question. I am trying to use the dbInput command and I can't get it to work. I saw on a search I did that others had problems with it. I also saw someone recommend using cin so I thought I would do that.

When I add the header file like this #include<iostream> I get a bunch of strange errors. When I do it like this #include "iostream.H"

it says it can't find it. Do I have to copy the file to my project folder to use it?
Dragon slayer
17
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 20th Apr 2013 20:55
I believe when using iostream, string.h and such, you need to change the code generation style from /MTd to /MD(this is under project properties->Config properties-

I found this on a search of the forums and It works. I can #include<iostream> like this and it compiles!
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 21st Apr 2013 07:25
I wouldn't use std::cin to get input, it won't work very well

How are you using dbInput? You should put something like this in your game loop:


That will make whatever you put in the braces happen when you press the W key.
Dragon slayer
17
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 21st Apr 2013 16:23
I have been playing with it and got a very small type in your name program to compile with dbInput but now can't get it to print out what I want. Will get it though. Thinking about looking into SDL.

With pure C++ I can get things to work with no problem. With DarkGDK I keep getting a ton of errors. To me this is taking away from really learning and advancing but then when I get them fixed I have learned something. I would stick with pure c++ and console programs for now but I want as least the 2D drawing, text and color commands for now.
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 21st Apr 2013 20:33
If you are going to make a 3D game, I would look at using Ogre3D or Irrlicht, they are both powerful, open source 3D engines. DarkGDK is just too buggy and unreliable nowadays.

I am currently using Ogre3D and I have done more with it in a week than I have done with DarkGDK in a month. Ogre is a little harder than DarkGDK as it is all object-oriented, but once you get over the hump of learning how to use it, it is so much more powerful and stable.
Dragon slayer
17
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 21st Apr 2013 20:46
For now I am still learning C++. I am about to pointers and classes. I still have a ways to go. In pure c++ and console apps I can't make lines, set up a screen or position text etc... and I would like to do some of that. That is why I would like to use DGDK for now. I think that ogre and some of the other ones are too advanced for me right now. I did get SFML and got it to work by copying some small program from a tutorial, so it does work on my system. Seems pretty nice. It seems a lot like DGDK but I can;t find a command reference list any where.
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 27th Apr 2013 08:35 Edited at: 27th Apr 2013 09:16
I thought I should point this out. When using DGDK functions that return a char*. It is best to return the string to a char* variable, to avoid memory leaks. This way you can use the delete operator to free the memory.



Edit:
Just noticed the Dark GDK documentation state the syntax as:



Wrong! I never knew that, I tend to go by what Visual Studio's IntelliSense says.

Login to post a reply

Server time is: 2024-04-24 12:02:00
Your offset time is: 2024-04-24 12:02:00