Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include <conio.h>
- #include <stdio.h>
- #include <time.h>
- #include <unistd.h>
- #include <dos.h>
- #include <windows.h>
- using namespace std;
- char polje[30][30];
- char pros='w';
- char a = ' ';
- void popuni()
- {
- for(int i=0; i<30; i++)
- {
- for(int j=0; j<30; j++)
- {
- polje[i][j]='.';
- }
- }
- }
- void ispisi()
- {
- for(int i=0; i<30; i++)
- {
- for(int j=0; j<30; j++)
- cout<<polje[i][j];
- cout<<endl;
- }
- }
- bool provjera()
- {
- int broj=0;
- for(int i=0; i<30; i++)
- {
- for(int j=0; j<30; j++)
- {
- if(polje[i][j]=='*')
- broj++;
- }
- }
- if(broj==30*30-1)
- return true;
- else
- return false;
- }
- void promjena()
- {
- }
- int main()
- {
- popuni();
- int y=15,x=15,prosli=0;
- polje[y][x]='@';
- //ispisi();
- a=_getch();
- pros=a;
- while(true)
- {
- if(kbhit())
- {
- a=_getch();
- pros=a;
- }
- ispisi();
- if(pros=='w' or pros=='W')
- {
- prosli=y;
- y--;
- if(polje[y][x]=='*')
- {
- cout<<"Game Over"<<endl;
- return 0;
- }
- polje[prosli][x]='*';
- polje[y][x]='@';
- if(x>29 or y>29 or x<0 or y<0)
- {
- cout<<"Game Over"<<endl;
- return 0;
- }
- Sleep(150);
- }
- if(pros=='s' or pros=='S')
- {
- prosli=y;
- y++;
- if(polje[y][x]=='*')
- {
- cout<<"Game Over"<<endl;
- return 0;
- }
- polje[prosli][x]='*';
- polje[y][x]='@';
- if(x>29 or y>29 or x<0 or y<0)
- {
- cout<<"Game Over"<<endl;
- return 0;
- }
- Sleep(150);
- }
- if(pros=='a' or pros=='A')
- {
- prosli=x;
- x--;
- if(polje[y][x]=='*')
- {
- cout<<"Game Over"<<endl;
- return 0;
- }
- polje[y][prosli]='*';
- polje[y][x]='@';
- if(x>29 or y>29 or x<0 or y<0)
- {
- cout<<"Game Over"<<endl;
- return 0;
- }
- Sleep(150);
- }
- if(pros=='d' or pros=='D')
- {
- prosli=x;
- x++;
- if(polje[y][x]=='*')
- {
- cout<<"Game Over"<<endl;
- return 0;
- }
- polje[y][prosli]='*';
- polje[y][x]='@';
- if(x>29 or y>29 or x<-1 or y<-1)
- {
- cout<<"Game Over"<<endl;
- return 0;
- }
- Sleep(150);
- }
- system("CLS");
- //promjena();
- }
- //a=_getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement