Hi, I begun the work on this game for some minutes ago:
Code:
#include <windows.h>
#include <iostream.h>
#include <stdio.h>
#define WMAX 6
#define PMAX 60
using namespace std;
inline void start(void)
{
char wayinput[WMAX];
char pname[PMAX];
cout << "What do you want to be called?\n";
cin.getline (pname, 60);
cout << "\nOk, hello " << pname << ", right now you are in Hilstone Village.";
}
inline void about(void)
{
cout << "\n FT-Adventure is a text-based game";
cout << "\n Made by Marcus Nordh / Sweden in C++.";
}
int main()
{
HANDLE hOut;
int selection;
hOut = GetStdHandle (STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hOut,
FOREGROUND_RED |
FOREGROUND_INTENSITY);
cout << "\n **Welcome to a text-based game made in C++!**"<<endl;
SetConsoleTextAttribute(hOut,
FOREGROUND_RED |
FOREGROUND_GREEN |
FOREGROUND_BLUE |
FOREGROUND_INTENSITY);
cout << "\n 1. Start\n";
cout << "\n 2. Exit\n";
cout << "\n 3. About";
cin>>selection;
switch(selection)
{
case 1:
start();
break;
case 2:
exit(0);
break;
case 3:
about();
break;
default:
MessageBox(NULL, "Wrong input, quitting", "Error", MB_OK | MB_ICONERROR);
exit(0);
}
getchar();
getchar();
}
Somewhere here its wrong:
Code:
inline void start(void)
{
char wayinput[WMAX];
char pname[PMAX];
cout << "What do you want to be called?\n";
cin.getline (pname, 60);
cout << "\nOk, hello " << pname << ", right now you are in Hilstone Village.";
}
cause I can compile it but when I press 1 (start the game) it doesnt let me input my name, instead it says "Ok, hello , right now you..."
Many thanks for answer