Advertisement
alexon5519

v.p

Apr 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<iostream>
  3. #include<conio.h>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. char tabel[21][21];
  9. int n=21,cSt,cDr;
  10. char e,aux;
  11.  
  12.  
  13. void generare_careu(){
  14. int i;
  15. for ( i = 2; i < n; i++){
  16. tabel[1][i] = '#';
  17. tabel[i][1] = '#';
  18. tabel[n][i] = '#';
  19. tabel[i][n] = '#';
  20. }
  21. tabel[1][1]='#';
  22. tabel[1][n]='#';
  23. tabel[n][1]='#';
  24. tabel[n][n]='#';
  25. }
  26.  
  27. void afisare_careu(){
  28. int i,j;
  29. for(i=1;i<=n;i++){
  30. for(j=1;j<=n;j++)
  31. cout<<tabel[i][j];
  32. cout<<endl;
  33. }
  34. }
  35.  
  36. void creare_linie(char m ){
  37. switch( m ){
  38. case '1':
  39. tabel[19][11]='*';
  40. break;
  41. case '2':
  42. tabel[19][11]='*';
  43. tabel[19][10]='*';
  44. tabel[19][12]='*';
  45. break;
  46. case '3':
  47. tabel[19][11]='*';
  48. tabel[19][10]='*';
  49. tabel[19][12]='*';
  50. tabel[19][9]='*';
  51. tabel[19][13]='*';
  52. break;
  53. default :
  54. cout<<"Cazul nu exista"<<endl;
  55. Sleep(1000);
  56. system("cls");
  57. }
  58. }
  59.  
  60. void inter(char &ch1, char &ch2){
  61. aux = ch1;
  62. ch1 = ch2;
  63. ch2 = aux;
  64. }
  65.  
  66. void moveRight(){
  67. cDr++;
  68. inter(tabel[19][cSt], tabel[19][cDr]);
  69. cSt++;
  70. }
  71.  
  72. void moveLeft(){
  73. cSt--;
  74. inter(tabel[19][cDr], tabel[19][cSt]);
  75. cDr--;
  76. }
  77.  
  78. void animatie_linie(){
  79. if (_kbhit()){
  80. e=_getch();
  81. if (e == 'a' || e == 'A'){
  82. if(cSt > 2)
  83. moveLeft();
  84. }
  85. else
  86. if (e == 'd' || e == 'D'){
  87. if(cDr < 20)
  88. moveRight();
  89. }
  90. }
  91. }
  92.  
  93.  
  94.  
  95.  
  96. int main (){
  97. int p=2,q=11;
  98. char m;
  99. cout<< " Ce nivel alegi?"<<endl<< "1-greu"<<endl<<"2-mediu"<<endl<<"3-usor"<<endl;
  100. cin>>m;
  101. if(m == '1'){
  102. cSt=11;
  103. cDr=11;
  104. }
  105. if(m == '2'){
  106. cSt=10;
  107. cDr=12;
  108. }
  109. if(m == '3'){
  110. cSt=9;
  111. cDr=13;
  112. }
  113. cout<<cSt<<" "<<cDr;
  114. generare_careu();
  115. creare_linie(m);
  116. tabel[p][q]='0';
  117. while(p != q)
  118. animatie_linie()
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement