Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <windows.h>
- using namespace std;
- void generator();
- int x=5;
- int y=5;
- string hero = "O";
- string gameArea[10][10];
- int main()
- {
- generator();
- while (1){
- if(kbhit())
- {
- char c = getch();
- switch(c){
- case 'w':
- x-=1;
- break;
- case 's':
- x+=1;
- break;
- case 'd':
- y+=1;
- break;
- case 'a':
- y-=1;
- break;
- default:
- continue;
- }
- cout<< endl;
- generator();
- }
- };
- };
- void generator(){
- for(int rows=0; rows<10; rows++){
- for(int cols=0; cols<10;cols++){
- if(gameArea[rows][cols]!="+"){
- gameArea[rows][cols] = "+";
- if(gameArea[rows][cols] == gameArea[x][y]){
- gameArea[rows][cols] = hero;
- }
- }
- cout << gameArea[rows][cols];
- }
- cout << endl;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment