Just wanted to say that it seems like you have a great community going here. I'm a complete rookie in C++, and I've been trying to find some good tutorials to practice with. So far, I'm in way over my head, but day by day it gets less confusing, and that's a good thing. I decided, though, that the best way to go about learning is to try my hand at making a text-based game from scratch, using only reference sites.
I recently stumbled across this forum post describing how to print out a string, character by character, using iterators. Full disclosure: I haven't reached iterators in my tutorials yet.
Code follows:
// builder.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <cstdlib>
#include <iostream>
#include <string>
#include <windows.h>
int main()
{
typedef std::string::const_iterator iter;
std::string msg ( "This is a message" );
iter begin = msg.begin();
iter end = msg.end();
for ( iter it = begin; it != end; ++it ) {
std::cout.put ( *it );
Sleep (75);
}
std::cout<<std::endl;
}
This is perfect. Exactly the right speed, exactly what I wanted it to do. The only problem is that it uses a static value for the string ("This is a message"), whereas I'd like my entire (text-based) game to be displayed with this scrolling effect. The idea is that I include the above code in a separate header file, and call to the function whenever text needs to be displayed, thereby creating the desired effect for all the text in the game (except menus, which will have their own header file).
I'm having a really hard time trying to convert the function from static input to dynamic input; any ideas how I might get this done?
Thanks in advance for the patience, I still don't quite know my elbow from my ass.