Funkar som meny?
Hej, jag är ny inom c++ har hållt på ett litet tag nu bara. Och tänkte testa göra en meny till ett spel jag ska göra senare, när jag lärt mig hur allt fungerar.
Så skulle vilja veta vad ni tycker om denna koden till meny? Är den dö kass eller fungerar den bra för en nybörjare?
#include <cstdlib>
#include <iostream>
#include "stdlib.h"
using namespace std;
int main()
{
int choice = 0;
bool MenuLoop;
int back = 0;
system ("TITLE TROKELE");
system ("COLOR 0A");
while (MenuLoop == true);
{
system ("CLS");
cout << "1. Play" << endl;
cout << "2. Instructions" << endl;
cout << "3. About" << endl;
cout << "4. Exit" << endl << endl;
cin >> choice;
}
switch (choice)
{
case 1:
{
}
case 2:
{
system ("CLS");
cout << "UP = U" << endl << endl;
cout << "DOWN = J" << endl << endl;
cout << "LEFT = H" << endl << endl;
cout << "RIGHT = K" << endl << endl;
cout << "Write 0 for menu" << endl << endl;
cin >> back;
if (back == 0)
{
system ("CLS");
cout << "1. Play" << endl;
cout << "2. Instructions" << endl;
cout << "3. About" << endl;
cout << "4. Exit" << endl << endl;
cin >> choice;
}
}
case 3:
{
system ("CLS");
cout << "This game is made by Fredrik 'GHARN' Dahl" << endl;
cout << "Version 1.0" << endl;
cout << "Write 0 for menu" << endl;
cin >> back;
if (back == 0)
{
system ("CLS");
cout << "1. Play" << endl;
cout << "2. Instructions" << endl;
cout << "3. About" << endl;
cout << "4. Exit" << endl << endl;
cin >> choice;
}
}
case 4:
{
exit(0);
}
}
}