Jump to content

Tetris


zedealges

Recommended Posts

Boas, para este periodo tenho como projecto programar o jogo do tetris em C++

já tenho algum código mas ainda está longe de estar completo, mas dá-me alguns erros que não consigo resolver =/..

quando faço build não detecta os erros e diz 1 succeed como é suposto, mas depois faço executar, e ainda depois de introduzir os valores é que diz que a variável retorno não é declarada =/, até já experimentei pôr como varável global e deu o mesmo..

senão for muito cansativo, agradecia que dessem uma vista de olhos ao código lol se quiserem, estou a programá-lo com funções

#include <iostream>

#include <conio.h>

using namespace std;

void menu( void );
int tratarmenu( char op );
int nivel( int nl );

int main()	{
char op;
int k = 0;

do	{
	menu();	

	cin >> op;
	op = toupper(op);

	k = tratarmenu( op );

 } while( k == 0 );
}

void menu( void )	{
    cout << "Seleccione uma opção:" << endl;
cout << "J: Jogar." << endl;
cout << "N: Nível de dificuldade do jogo." << endl;
cout << "P: Pontuação." << endl;
cout << endl;
cout << "S: Sair do jogo." << endl;
}

int tratarmenu( char op )	{
char sd;
int retorno, oc;

switch(op)	{
	case 'J':	{
		break;
	}
	case 'N':	{
		oc = nivel(op);
		break;
	}
	case 'P':	{
		break;
	}
	case 'S':	{
		do	{
			cout << "Deseja sair do jogo? (y/n)" << endl;
			cin >> sd;
			sd=toupper(sd);
			if( sd == 'Y' )	{
				retorno = 1;
			}
			else if( sd == 'N' )	{
				retorno = 0;
			}
			else	{
				cout << "Opção não reconhecida!" << endl;
			}
		} while(sd!='Y' && sd !='N');

		break;
	}
	default:	{
		cout << "Opção inválida!" << endl;
	}
}

return retorno;
}

int nivel( int nl )	{
cout << "Escolha um nível de dificuldade:" << endl;
cout << " - 1" << endl;
cout << " - 2" << endl;
cout << " - 3" << endl;
cout << " - 4" << endl;
cout << " - 5" << endl;
cin >> nl;
return nl;
}

Beijinhos lá para a Mulher.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.