Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- char mp[1001][1001];
- // {"###########",
- // "# #",
- // "# #",
- // "# #",
- // "# #",
- // "# #",
- // "# #",
- // "###########"};
- int szv=8,szo=11,nrt,viata=5;
- int pl=2,pc=2;
- void render(){
- for(int i=0;i<szv;i++){
- for(int j=0;j<szo;j++)
- cout<<mp[i][j];
- cout<<'\n';
- }
- cout<<"VIATA:\n";
- for(int i=1;i<=viata;i++)cout<<(char)3;
- }
- int main()
- {
- cout<<"ALEGETI MARIMEA\n";
- cout<<"VERTICAL: "; cin>>szv;
- cout<<"ORZIZONTAL: "; cin>>szo;
- cout<<"NUMAR TEPI: "; cin>>nrt;
- for(int i=0;i<szo;i++)mp[0][i]=mp[szv-1][i]='#';
- for(int i=0;i<szv;i++)mp[i][0]=mp[i][szo-1]='#';
- srand(time(NULL));
- for(int i=1;i<=nrt;i++){
- int lin=rand()%(szv-2)+1;
- int col=rand()%(szo-2)+1;
- if(lin==2&&col==2)i--;
- mp[lin][col]='^';
- }
- while(1)
- {
- render();
- mp[pl][pc]=' ';
- if(GetAsyncKeyState(VK_UP)&1==true&&pl>1){
- pl--;
- }
- if(GetAsyncKeyState(VK_DOWN)&1==true&&pl<szv-2) pl++;
- if(GetAsyncKeyState(VK_LEFT)&1==true&&pc>1) pc--;
- if(GetAsyncKeyState(VK_RIGHT)&1==true&&pc<szo-2) pc++;
- mp[pl][pc]='@';
- Sleep(50);
- system("cls");
- }
- cout << "Hello world!" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement