Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5.  
  6. using namespace std;
  7.  
  8. char mp[1001][1001];
  9. // {"###########",
  10. // "# #",
  11. // "# #",
  12. // "# #",
  13. // "# #",
  14. // "# #",
  15. // "# #",
  16. // "###########"};
  17. int szv=8,szo=11,nrt,viata=5;
  18. int pl=2,pc=2;
  19. void render(){
  20. for(int i=0;i<szv;i++){
  21. for(int j=0;j<szo;j++)
  22. cout<<mp[i][j];
  23. cout<<'\n';
  24. }
  25. cout<<"VIATA:\n";
  26. for(int i=1;i<=viata;i++)cout<<(char)3;
  27. }
  28.  
  29. int main()
  30. {
  31. cout<<"ALEGETI MARIMEA\n";
  32. cout<<"VERTICAL: "; cin>>szv;
  33. cout<<"ORZIZONTAL: "; cin>>szo;
  34. cout<<"NUMAR TEPI: "; cin>>nrt;
  35. for(int i=0;i<szo;i++)mp[0][i]=mp[szv-1][i]='#';
  36. for(int i=0;i<szv;i++)mp[i][0]=mp[i][szo-1]='#';
  37. srand(time(NULL));
  38. for(int i=1;i<=nrt;i++){
  39. int lin=rand()%(szv-2)+1;
  40. int col=rand()%(szo-2)+1;
  41. if(lin==2&&col==2)i--;
  42. mp[lin][col]='^';
  43. }
  44. while(1)
  45. {
  46. render();
  47. mp[pl][pc]=' ';
  48. if(GetAsyncKeyState(VK_UP)&1==true&&pl>1){
  49. pl--;
  50. }
  51. if(GetAsyncKeyState(VK_DOWN)&1==true&&pl<szv-2) pl++;
  52. if(GetAsyncKeyState(VK_LEFT)&1==true&&pc>1) pc--;
  53. if(GetAsyncKeyState(VK_RIGHT)&1==true&&pc<szo-2) pc++;
  54. mp[pl][pc]='@';
  55. Sleep(50);
  56. system("cls");
  57.  
  58. }
  59. cout << "Hello world!" << endl;
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement