Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<iostream>
- #include<conio.h>
- using namespace std;
- char tabel[21][21];
- int n=21,cSt,cDr;
- char e,aux;
- void generare_careu(){
- int i;
- for ( i = 2; i < n; i++){
- tabel[1][i] = '#';
- tabel[i][1] = '#';
- tabel[n][i] = '#';
- tabel[i][n] = '#';
- }
- tabel[1][1]='#';
- tabel[1][n]='#';
- tabel[n][1]='#';
- tabel[n][n]='#';
- }
- void afisare_careu(){
- int i,j;
- for(i=1;i<=n;i++){
- for(j=1;j<=n;j++)
- cout<<tabel[i][j];
- cout<<endl;
- }
- }
- void creare_linie(char m ){
- switch( m ){
- case '1':
- tabel[19][11]='*';
- break;
- case '2':
- tabel[19][11]='*';
- tabel[19][10]='*';
- tabel[19][12]='*';
- break;
- case '3':
- tabel[19][11]='*';
- tabel[19][10]='*';
- tabel[19][12]='*';
- tabel[19][9]='*';
- tabel[19][13]='*';
- break;
- default :
- cout<<"Cazul nu exista"<<endl;
- Sleep(1000);
- system("cls");
- }
- }
- void inter(char &ch1, char &ch2){
- aux = ch1;
- ch1 = ch2;
- ch2 = aux;
- }
- void moveRight(){
- cDr++;
- inter(tabel[19][cSt], tabel[19][cDr]);
- cSt++;
- }
- void moveLeft(){
- cSt--;
- inter(tabel[19][cDr], tabel[19][cSt]);
- cDr--;
- }
- void animatie_linie(){
- if (_kbhit()){
- e=_getch();
- if (e == 'a' || e == 'A'){
- if(cSt > 2)
- moveLeft();
- }
- else
- if (e == 'd' || e == 'D'){
- if(cDr < 20)
- moveRight();
- }
- }
- }
- int main (){
- int p=2,q=11;
- char m;
- cout<< " Ce nivel alegi?"<<endl<< "1-greu"<<endl<<"2-mediu"<<endl<<"3-usor"<<endl;
- cin>>m;
- if(m == '1'){
- cSt=11;
- cDr=11;
- }
- if(m == '2'){
- cSt=10;
- cDr=12;
- }
- if(m == '3'){
- cSt=9;
- cDr=13;
- }
- cout<<cSt<<" "<<cDr;
- generare_careu();
- creare_linie(m);
- tabel[p][q]='0';
- while(p != q)
- animatie_linie()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement