C++ の基本を学び始め、学んだことを実践するコードを書きたいと思いました。クラスといくつかの関数を作りたかったのです。ゲームがないことを除いて、テキストゲームを開始するためのタイトル画面になるはずです...まだ:P
開始するために 1 を入力すると、「Good Work」と表示され、Enter キーを押しても何も起こりません。
正しい方向のポイントは素晴らしいでしょう。私はビデオを見たり、機能に関するチュートリアルを読んだりしてきましたが、私が抱えている問題をカバーしていないようです...
#include <iostream>
#include <string>
using namespace std;
//Function Protos
void keyError();
int userInput(int x);
//class library
class Title
{
bool nSelect;
int x;
public:
void titleScreen()
{
while(nSelect)
{
cout << "Welcome to Biggs RPG!" << endl << "1. Play 2. Exit" << endl;
userInput(x);
if (userInput(1))
nSelect = 0;
else if (userInput(2))
{
cout << "Closing program..." <<endl;
nSelect = 0;
}
else
keyError();
}
}
};
int main()
{
Title displayTitle;
displayTitle.titleScreen();
cout << "Good work";
return 0;
}
void keyError()
{
cout << "Meow? Wrong input try again." << endl;
}
int userInput(int x)
{
x = 0;
cin >> x;
return x;
}