Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

Menu główne w grze w konsoli CMD

Ostatnio zmodyfikowano 2019-08-08 19:57
Autor Wiadomość
gaweljar0
Temat założony przez niniejszego użytkownika
Menu główne w grze w konsoli CMD
» 2019-08-08 17:39:34
Podczas zmiany wartości zmiennej "pointingmenu" nic się nie dzieje.

C/C++
#include <iostream>
#include <cstdlib>
#include <windows.h>
#include <conio.h>
#include <cstdio>
using namespace std;
string movingmenu;
int repeatmenu;
int pointingmenu = 2;
int main()
{
    do
    {
        if( pointingmenu == 1 )
        {
            system( "cls" );
            pointingmenu = 2;
        }
        if( pointingmenu == 2 )
        {
            system( "cls" );
            cout << "           Title" << endl;
            cout << "-PLAY" << endl;
            cout << " language" << endl;
            cout << " exit" << endl;
        }
        if( pointingmenu == 3 )
        {
            system( "cls" );
            cout << "           Title" << endl;
            cout << " play" << endl;
            cout << "-LANGUAGE" << endl;
            cout << " exit" << endl;
        }
        if( pointingmenu == 4 )
        {
            system( "cls" );
            cout << "           Title" << endl;
            cout << " play" << endl;
            cout << " language" << endl;
            cout << "-EXIT" << endl;
        }
        if( pointingmenu == 5 )
        {
            system( "cls" );
            pointingmenu = 4;
        }
        movingmenu = getch();
        if( movingmenu == "w" )
        {
            pointingmenu = - 1;
            repeatmenu = 2;
        }
        if( movingmenu == "s" )
        {
            pointingmenu = + 1;
            repeatmenu = 2;
        }
       
    } while( repeatmenu == 2 );
   
}
P-174988
pekfos
» 2019-08-08 18:08:35
getch() zwraca jeden znak, a nie napis.
P-174989
gaweljar0
Temat założony przez niniejszego użytkownika
» 2019-08-08 18:16:21
Zatem w postaci jakiej zmiennej to zapisać?
P-174991
pekfos
» 2019-08-08 18:32:59
Typ znakowy to char, a literał znakowy to 'a' (a nie "a").
P-174992
gaweljar0
Temat założony przez niniejszego użytkownika
» 2019-08-08 19:41:19
Dziękuję, lecz to nie rozwiązało kłopotu. Dalej nic się nie dzieje.

C/C++
#include <iostream>
#include <cstdlib>
#include <windows.h>
#include <conio.h>
#include <cstdio>
using namespace std;
int movingmenu;
int repeatmenu;
int pointingmenu;
int game()
{
   
}
int settings()
{
   
}
int main()
{
    do
    {
        if( pointingmenu == 1 )
        {
            system( "cls" );
            pointingmenu = 2;
        }
        if( pointingmenu == 2 )
        {
            system( "cls" );
            cout << "           Title" << endl;
            cout << "-PLAY" << endl;
            cout << " language" << endl;
            cout << " exit" << endl;
        }
        if( pointingmenu == 3 )
        {
            system( "cls" );
            cout << "           Title" << endl;
            cout << " play" << endl;
            cout << "-LANGUAGE" << endl;
            cout << " exit" << endl;
        }
        if( pointingmenu == 4 )
        {
            system( "cls" );
            cout << "           Title" << endl;
            cout << " play" << endl;
            cout << " language" << endl;
            cout << "-EXIT" << endl;
        }
        if( pointingmenu == 5 )
        {
            system( "cls" );
            pointingmenu = 4;
        }
        movingmenu = getch();
        if( movingmenu == 119 )
        {
            pointingmenu = - 1;
            repeatmenu = 2;
        }
        if( movingmenu == 115 )
        {
            pointingmenu = + 1;
            repeatmenu = 2;
        }
        if( movingmenu != 115 || movingmenu != 119 || movingmenu != 101 )
        {
            pointingmenu = pointingmenu;
            repeatmenu = 2;
        }
        if( movingmenu == 101 )
        {
            if( pointingmenu == 1 )
            {
                return 0;
            }
            if( pointingmenu == 2 )
            {
                game();
            }
            if( pointingmenu == 3 )
            {
                settings();
            }
            if( pointingmenu == 4 )
            {
                return 0;
            }
            if( pointingmenu == 5 )
            {
                game();
            }
        }
       
    } while( repeatmenu == 2 );
   
}
P-174993
pekfos
» 2019-08-08 19:57:05
C/C++
pointingmenu = - 1;
C/C++
pointingmenu -= 1

C/C++
pointingmenu = + 1;
C/C++
pointingmenu += 1
P-174994
« 1 »
  Strona 1 z 1