• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
ThinkingsHard

Requesting Assistance

10 posts in this topic

Hello!

I have gotten back into my programming groove, after a small break, however I never got very far. I switched from Java to C++, a lot of people suggested I do so, and on top of that, a friend at work uses C++, I hope to eventually go back and learn how to perform the operations in Java, however for now I am sticking with C++.

Anyway, enough about my lifes story! Haha.

I've been reading Stoustrup's Programming Principles and Practice using C++, and I was doing one of the 'drills', when I noticed how ugly the command prompt gets with all the cin and cout in the same window.

I looked around however, I didn't see anything that was readable at my level related to my question.

The Question!

How do I request the inputs to be in a popup / child window instead of the parent / main window, to keep the program cleaner.



( Incoming Code, this is what I have made so far, and I know I don't need to include all of the #include's that I did... But they make me feel happier about my life, which is a good enough reason to have them!)

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
inline void keep_window_open() { char ch; cin>>ch;}

int main(){

cout<<"Please enter the name of the person you wish to write to.\n";
string first_name;
cin >> first_name;
cout<<"Dear" << " " << first_name <<",\n";
cout<<"How are you?\n";
string first_response;
cin >> first_response;
cout <<"I miss you.\n";
cout << "Please enter the name of our friend.\n";
string friend_name;
cin >> friend_name;
cout << "Have you seen" << " " << friend_name<< " " << "lately?\n";
cout << "Enter the sex of" << " " << friend_name << " " << "as a 'm' or 'f'.\n";
char friend_sex = 0;
cin >> friend_sex;
if (friend_sex == 'm'){
cout<<"If you see" << " " << friend_name <<" " << "please have him call me.\n";
}
if (friend_sex == 'f'){
cout<<"If you see" << " " << friend_name <<" " << "please have her call me.\n";
}
cout<< "Please enter recipients age\n";
int age;
cin >> age;
if (age != 0 && age < 110)
{
cout << "I hear you recently had a birthday, and you are now" << " " << age << " " << "years old.\n";
}
else
{
cout << "You're kidding!";
}
if (age ==17)
{
cout<< "Next year you will be able to vote!";
}
if (age > 70)
{
cout << "I hope you are enjoying retirement!";
}
cout << "Next year you will be" << " " << age+1 << ".\n";
cout << "Yours Sincerely\n";
cout << "\n";
cout << "\n";
string writers_Name;
cin >> writers_Name;
cout << writers_Name;

keep_window_open();
}




Thanks!
0

Share this post


Link to post
Share on other sites
You can do what you are talking about, have one application create a second console window, so you can have one for input and one for output.

That said, it is not a trivial thing to do. In fact it would be a fair bit of work. On windows for example, you could use the [url="http://msdn.microsoft.com/en-us/library/windows/desktop/ms681952(v=vs.85).aspx"]Console APIs[/url] to accomplish this, but trust me, such a task is not something you probably want to embark on.

Basically what happens in C++ is each application has something called stdin and stdout. These are simply buffers for text input and output. Where the actual text goes is somewhat irrelevant to C++. When you use cout or cin, you are actually writing to or reading from stdin and stdout, at least by default. Problem is, by default a new terminal window means a new process, which means a new cin and cout. You can easily redirect stdout and stdin, say... to a file. But redirecting the results to another running application is much more complicated involving cross-process communications of some form, such as a pipe. Edited by Serapth
0

Share this post


Link to post
Share on other sites
Alright.... Going to look up how to do that, and implement it.... Man this drill has no idea what's coming for it! Thanks!
0

Share this post


Link to post
Share on other sites
Well if you are a glutton for punishment, and working on Windows, [url="http://dslweb.nwnexus.com/~ast/dload/guicon.htm"]start here[/url]. The trickiest part is, your console application is going to actually be a Windows application behind the scenes. The logististics of what that actually means can prove a bit confusing, beyond the fact one type of application has a main() and the other has a WinMain() entry point. It should prove an interesting learning experience, although I warn you Alice, this rabbit hole is deep, dark and kinda scary.

EDIT:

You can probably go the pure console app route using spawn and a pipe to control communications, that should be more cross platform but perhaps a bit more confusing at the end of the day. [url="http://msdn.microsoft.com/en-us/library/edze9h7e(v=vs.71).aspx"]This example[/url] illustrates using a pipe to communicate between a parent and child process opened using spawnl(). Edited by Serapth
2

Share this post


Link to post
Share on other sites
Wouldn't it require working with a window API, like Win32?

I looked up here and I found this [url="http://www.gamedev.net/topic/516931-c-win32-spawning-a-second-console-window/"]old thread[/url]. I think it is a good start.

Well, if you manage to do it don't forget to post here how you did it. This is something I had never thought about. Edited by kuramayoko10
0

Share this post


Link to post
Share on other sites
Serapth, I take your warning seriously, however know that Alice isn't afraid of the dark, does not easily scare, and likes long walks in a forest talking about the philosophical problems and solutions related to Chance as a manipulable force.

Kuramayoko10, I will indeed my good sir / ma'am.[sup] [/sup]
1

Share this post


Link to post
Share on other sites
Apparently Serapth already answered your question, but to be honest, I don't get it... do you want to have the input requests in a different console than the output? That would, imho, not make it cleaner but totally confusing. Afterall, it's a question and answer game and I would think it's weird to give the answer to someone else than the one who asked me... I'd suggest to delay those pop-up windows until you start with GUI programming (which is not hard at all... take a look at wxwidgets or Qt, for example).

Until then I'd suggest to stick with the "ugliness" of the console and be happy (since you are coming from Java) that cin and cout is so much shorter than System.out.println and
[CODE]
BufferedReader bufferRead = new BufferedReader(new InputStreamReader(System.in));
String s = bufferRead.readLine();
[/CODE]
(yeah, I know nowadays, there's the java.io.Console class, but even that is so much more than a simple "cin"...)
;)

P.S.: I really like Java, don't get me wrong, please!
0

Share this post


Link to post
Share on other sites
brx, by ugliness, I meant it in a different way than you, I guess.

In the current form of the program, it takes all the inputs and outputs on the same screen, so when it asks you a question, you answer it in that same window, and then it responds, for instance, at the very end of the program, it asks you to say

Yours Sincerely,


<Your name>

However it ends up printing, because of the inputs being saved in the same window

Yours Sincerely,


<Your name>
<Your name>

If the inputs were accepted in a different window, then it would be a lot easier to read, it would make more sense and be overall nicer to the user.
0

Share this post


Link to post
Share on other sites
Don't worry, when you reach Chapter 12 you're going to be introduced to graphical user interfaces (GUIs) &amp; graphics :-) Chapter 16 further expands on GUIs.
// BTW, Chapter 12 is available freely: http://www.stroustrup.com/Programming/programming_ch12.pdf Edited by Matt-D
0

Share this post


Link to post
Share on other sites
I have the entire book on a PDF, 1285 pages or something like that. It's been great fun. I'm just starting Chapter 3. A lot of this stuff I already knew, from Java, and I just needed to learn how to properly translate my operations into C++. And as someone said previously, It feels a lot better to type cin or cout<< stuff << more stuff << more stuff << final stuff;

Rather than typing System.out.println


I was reading on the pipes, and spawns. And I'm going to keep reading the chapters in this PDF, and if it fails to teach me what I want (Which is simply a new window to take in he inputs and then accept those into the main window, as both in 1 window gets redundant and ugly) I shall (as I have already bookmarked the pages) find other materials to teach myself how to do said thing. I hope to have a working version within a week, that I can reply to this thread and say "Haha! I am pleased with myself! I did it by..."

Thanks to everyone for their replies. This is why I want to be a programmer, so far you are nothing but helpful, as though you want more professionals to communicate and work with. :P
0

Share this post


Link to post
Share on other sites
In terms of the code maybe you could create a function that asks a question and then gets a valid answer. I don't know if that kind of thing is something that you could do yet but it would cut down on some of the clutter there a little. This one's not too bad, but long functions make me scared, lol.

Also, something that may make your life a little easier:

cout << "Have you seen" << " " << friend_name<< " " << "lately?\n";

could just as easily be:

cout << "Have you seen " << friend_name<< " lately?\n";

Unless you're after explicit spacing there, which is fine.

Finally, please enclose code on the forum in source braces. When you're making a post and you want to insert code just click the little red brackety button at the end of the second line of buttons above the text field. It makes it a lot easier to read and has syntax hilighting and stuff:

[source lang="cpp"]cout << "How many times a day do you cin?\n";
int times = 0;
cin >> times;
cout << "Really!? " << times << " times?\nRepeat after me: \"Forgive me console, for I have cin'ed.\"\n";[/source] Edited by Khatharr
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0