Advertisement
Guest User

Untitled

a guest
Feb 14th, 2013
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1.     #include<iostream>
  2.     #include<windows.h>
  3.     #include<ctime>
  4.     using namespace std;
  5.  
  6.     char map[20][20];
  7.     int x = 10;
  8.     int ey = 1;
  9.     int ex = 4;
  10.     int hp = 5;
  11.     void randomizeenemypos() {
  12.            time_t t;
  13.            time(&t);
  14.            srand(t);
  15.            ex = rand() % 19;
  16.            if(ex == 0) {
  17.                  ex = 2;
  18.            }
  19.            map[20][ex] = 'v';    
  20.     }
  21.     int main() {
  22.      for(int i = 0; i <= 20; i++) {
  23.               for(int j = 0; j <= 20; j++)
  24.               map[i][j] = 'x';
  25.                
  26.      }
  27.      for(int i = 1; i <= 19; i++) {
  28.               for(int j = 1; j <= 19; j++)
  29.               map[i][j] = '.';
  30.      }
  31.      map[17][10] = '^';
  32.      while(true) {
  33.      Sleep(100);
  34.      if(ey == 19) {
  35.         ey = 1;
  36.         randomizeenemypos();
  37.      }
  38.      map[ey][ex] = '.';
  39.      ey += 1;
  40.      map[ey][ex] = 'v';
  41.      system("cls");            
  42.      for(int i = 0; i <= 20; i++) {
  43.               for(int j = 0; j <= 20; j++)
  44.               cout << map[i][j];
  45.               cout << endl;
  46.      }
  47.      if(GetAsyncKeyState(VK_LEFT)) {
  48.           if(map[17][x-1] == 'x') {
  49.                  map[17][x] = '.';
  50.                  x += 1;
  51.                  map[17][x] = '^';              
  52.           }
  53.                  map[17][x] = '.';
  54.                  x -= 1;
  55.                  map[17][x] = '^';
  56.      }
  57.      if(GetAsyncKeyState(VK_RIGHT)) {
  58.           if(map[17][x+1] == 'x') {
  59.                  map[17][x] = '.';
  60.                  x -= 1;
  61.                  map[17][x] = '^';              
  62.           }
  63.                  map[17][x] = '.';
  64.                  x += 1;
  65.                  map[17][x] = '^';
  66.      }
  67.     }
  68.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement