Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <conio.h>
- #include "windows.h"
- #include <time.h>
- using namespace std;
- void gotoxy(int x, int y)
- {
- COORD c;
- c.X = x - 1;
- c.Y = y - 1;
- SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
- }
- int main(int argc, char *argv[])
- {
- int a, b;
- gotoxy(25,10);
- cout<<"Witamy w Grze o nazwie WONSZ!!!!!";
- gotoxy(1,15);//trzecia ramka
- cout<<char(218);
- for(int i=0; i<78; i++)
- cout<<char(196);
- cout<<char(191);
- for(int i=0; i<15; i++)
- {
- gotoxy(0,i+15);
- if(i==14) cout<<char(192);
- else cout<<char(179)<<endl;
- }
- gotoxy(2,30);
- for(int i=0; i<78; i++)
- cout<<char(196);
- gotoxy(79,19);
- for(int i=0; i<15; i++)
- {
- gotoxy(80,i+16);
- if(i==14) cout<<char(217);
- else cout<<char(179)<<endl;
- }
- int u,m;
- u=rand()%80;
- m=rand()%15+15;
- gotoxy(u,m);
- cout << "X";
- int znak;
- int x=20,y=20;
- gotoxy(x,y);
- cout<<"@";
- int key;
- int pkt=1;
- do
- {
- key = getch();
- if (key == 224 || key ==0 )
- {
- switch (getch ())
- {
- case 80 : y++;gotoxy(x,y); cout<<"@"; //dol
- gotoxy(x,y-pkt); cout << " ";
- break;
- case 72 : y--;gotoxy(x,y); cout<<"@"; //gora
- gotoxy(x,y+pkt); cout << " ";
- break;
- case 77 : x++;gotoxy(x,y); cout<<"@"; //prawo
- gotoxy(x-pkt,y); cout << " ";
- break;
- case 75 : x--;gotoxy(x,y); cout<<"@"; //lewo
- gotoxy(x+pkt,y); cout << " ";
- break;
- }
- }
- if ((y == 15)||(y==30)||(x==80)||(x==1)){system ("cls");
- cout << "PRZEGRANA!"<<endl;
- cout << "Liczba uzyskanych punktow: " << pkt-1;};
- if ((y==m)&&(x==u))
- {
- u=rand()%79+1;
- m=rand()%15+15;
- gotoxy(u,m);
- cout << "X";
- pkt=pkt+1;
- };
- if (key==27)break;
- /*
- */
- ;
- }
- while (true);
- //system ("PAUSE")
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement