Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int i=0;
- int j=0;
- int px=4;
- int py=4;
- while(true)
- {system("cls");
- for (int i=0; i<10; i++){
- for(j=0; j<10; j++){
- if((j==px) && (i==py))
- {
- cout<<"@";
- }
- else{
- cout<<".";
- }
- }
- cout<<"\n";
- }
- char input=0;
- cin>>input;
- if(input=='w')
- {
- py=py-1;
- }
- else if(input=='a')
- {
- px=px-1;
- }
- else if(input=='s')
- {
- py=py+1;
- }
- else if(input=='d')
- {
- px=px+1;
- }
- if (py==-1){
- if (input=='w'){
- py=9;
- }
- }
- if(py==10){
- if(input=='s'){
- py=0;
- }
- }
- if(px==-1){
- if(input=='a'){
- px=9;
- }
- }
- if(px==10){
- if(input=='d'){
- px=0;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment