Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include <iterator>
- #include <conio.h>
- #include <windows.h>
- #include <list>
- using namespace std;
- long long n, m, a=1, b=1, t;
- string name1;
- char c, mp[100][100], mp_npc[100][100];
- void setcur(int x, int y) // ????? ??? ????????
- {
- COORD coord;
- coord.X = x;
- coord.Y = y;
- SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
- }
- void hod(char c2){
- if (c2 == 'd'){
- if (mp[a][b+1] == ' '){
- mp[a][b+1] = char(2);
- mp[a][b] = ' ';
- b ++;
- }
- if (mp[a][b+1] == char(3)){
- mp[a][b+1] = char(2);
- mp[a][b] = ' ';
- b ++;
- m ++;
- }
- }
- if (c2 == 's'){
- if (mp[a+1][b] == ' '){
- mp[a+1][b] = char(2);
- mp[a][b] = ' ';
- a ++;
- }
- if (mp[a+1][b] == char(3)){
- mp[a+1][b] = char(2);
- mp[a][b] = ' ';
- a ++;
- m ++;
- }
- }
- if (c2 == 'a'){
- if (mp[a][b-1] == ' '){
- mp[a][b-1] = char(2);
- mp[a][b] = ' ';
- b --;
- }
- if (mp[a][b-1] == char(3)){
- mp[a][b-1] = char(2);
- mp[a][b] = ' ';
- b --;
- m ++;
- }
- }
- if (c2 == 'w'){
- if (mp[a-1][b] == ' '){
- mp[a-1][b] = char(2);
- mp[a][b] = ' ';
- a --;
- }
- if (mp[a-1][b] == char(3)){
- mp[a-1][b] = char(2);
- mp[a][b] = ' ';
- a --;
- m ++;
- }
- }
- return ;
- }
- void dv(){
- for (int i=1; i < 19; i ++){
- for (int j=0; j < 30; j ++){
- if (mp[i-1][j] == char(3)){
- mp[i][j] = '9';
- mp[i-1][j] = ' ';
- }
- }
- }
- for (int i=1; i < 19; i ++){
- for (int j=0; j < 30; j ++){
- if (mp[i][j] == '9'){
- mp[i][j] = char(3);
- }
- }
- }
- }
- int main() {
- srand (time(NULL));
- cout << "enter the name of player :: ";
- cin >> name1;
- for (int i=0; i < 20; i ++){
- for (int j=0; j < 30; j ++){
- if (i == 0 || j == 0 || i == 19 || j == 29){
- mp[i][j] = '0';
- }else {
- if (rand() % (i+j) == 0){
- mp[i][j] = char(3);
- }else
- mp[i][j] = ' ';
- }
- }
- }
- mp[a][b] = char(2);
- while (true) {
- c = _getch();
- hod(c);
- setcur(0,1);
- for (int i=0; i < 20; i ++){
- for (int j=0; j < 30; j ++){
- cout << mp[i][j];
- }
- if (i == 10){
- cout << " " << char(3) << " = " << m;
- }
- cout << endl;
- }
- dv();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement