Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<windows.h>
- #include<ctime>
- using namespace std;
- char map[20][20];
- int x = 10;
- int ey = 1;
- int ex = 4;
- int hp = 5;
- void randomizeenemypos() {
- time_t t;
- time(&t);
- srand(t);
- ex = rand() % 19;
- if(ex == 0) {
- ex = 2;
- }
- map[20][ex] = 'v';
- }
- int main() {
- for(int i = 0; i <= 20; i++) {
- for(int j = 0; j <= 20; j++)
- map[i][j] = 'x';
- }
- for(int i = 1; i <= 19; i++) {
- for(int j = 1; j <= 19; j++)
- map[i][j] = '.';
- }
- map[17][10] = '^';
- while(true) {
- Sleep(100);
- if(ey == 19) {
- ey = 1;
- randomizeenemypos();
- }
- map[ey][ex] = '.';
- ey += 1;
- map[ey][ex] = 'v';
- system("cls");
- for(int i = 0; i <= 20; i++) {
- for(int j = 0; j <= 20; j++)
- cout << map[i][j];
- cout << endl;
- }
- if(GetAsyncKeyState(VK_LEFT)) {
- if(map[17][x-1] == 'x') {
- map[17][x] = '.';
- x += 1;
- map[17][x] = '^';
- }
- map[17][x] = '.';
- x -= 1;
- map[17][x] = '^';
- }
- if(GetAsyncKeyState(VK_RIGHT)) {
- if(map[17][x+1] == 'x') {
- map[17][x] = '.';
- x -= 1;
- map[17][x] = '^';
- }
- map[17][x] = '.';
- x += 1;
- map[17][x] = '^';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement