Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MrManby

Starting Off

This topic is 5763 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok. I''m really hyped up about getting in to game dev. I''ve read the beginner articles on the site. I just have a few questions. I''m actually just starting C++. I have MS Visual C++ and a few learning books. What else should I have?? Also when I compile the "Hello World" Program it flashes on the screen for a split second in a DOS window then closes.I think this is to do with WindowsXP Would this make a problem for further programming??? For Sale: One Parachute, Used one, Never opened, Small Stain.

Share this post


Link to post
Share on other sites
Advertisement
start the program from the command line
start -> run -> cmd

the window closes because the program ended

good luck

Share this post


Link to post
Share on other sites
Its not to do with winxp. You see all the hello world program does is tell the app to display teh string "hello world" on screen. so after the app does that it has nothing else to do so it exits. You can fix this by telling the application to let the user press a key before it exits.

first include conio.h.
#include <conio.h>

the header file conio has the prototype for function "getch()". You can use getch() to get a key code from the user. so at the end of your program do something like


  
cout<<"Hit a key to exit"<<endl;
getch();


that asks the user to hit a key and then get a key. so the app will stay there until the user presses a key.

[edit] greater then/lesss then tag fix [/edit]


:::: [ Triple Buffer V2.0 ] ::::


[edited by - IFooBar on February 1, 2003 4:54:40 PM]

Share this post


Link to post
Share on other sites
Hi. Welcome to the wonderful world of game development, enjoy your stay...

For getting the basics sorted, you have all you need - MSVC++ is enough to make simple text games. Later on, once you're comfortable with the language and the 'overview' of a game (the architecture), then you'll want to move on to more graphical stuff. You'll need tools for that, but that's still a couple of months away, so worry about it then.

The problem is that when your program has finished, XP automatically closes the DOS box. You can make your DOS box stay up on the screen:

while(!kbhit());

Add that line at the end of your main() function, and the result should be that your program sits there until you press a key. You may need to #include <conio.h> as well.

[Edit: damn you rexizt and IFooBar with your speedy clicker fingers]

Superpig
- saving pigs from untimely fates, and when he's not doing that, runs The Binary Refinery.

[edited by - Superpig on February 1, 2003 4:55:14 PM]

Share this post


Link to post
Share on other sites
Hi there! I''m also a newbie and had the same prob, but found

system("pause");

which seems to do the job and I''ve been using it ever since. I noticed that you guys didn''t suggest this though. So I need to ask, Is this okay to be using or have I just picked up another bad habit?

Share this post


Link to post
Share on other sites
how come all console apps i make dont end as desribed above ?

instead it stays open displays - Press any key to continue
pushing a key closes the program.

im using visual c++ 6, even a do nothing program does the same

int main()
{
return 0;
}

Share this post


Link to post
Share on other sites
deal,
Visual C++ 6 does that on alot of machines, like mine for example. But if you run the .exe from the debug folder it will give you the same problem as above.

Share this post


Link to post
Share on other sites
MrManby- I''m gussing all the replys these people have given you are just confussing you even more and don''t know enough c++ to use them correctly. I get the same problem but the easy way to fix it is to push ctrl+f5 which will compile and run the program in MSVC++. The difference is when you push ctrl+f5 it will pause the program as soon as its done running instead of closing it.

-----------------------------
Programming is confussing!
AIM: Trebor DoD

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!