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[])
- {
- srand(time(NULL));
- char men;
- system("CLS");
- cout<<" Witaj w grze Wonsz \276eczny" << endl;
- cout << "1. Zagraj w gr\251" << endl;
- cout << "2. Wy\210\245cz gr\251" << endl;
- cout << endl;
- cout << endl;
- cout << "Instrukcja: "<< endl;
- cout << "Jedz zielone" << endl;
- cout << "Nie jedz czerwonych" << endl;
- cout << "Nie jedz pude\210ka" << endl;
- men = getch();
- if (men=='1')
- system("pause");
- if (men=='2')
- return 0;
- HANDLE hConsole;
- hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- int a, b;
- system("CLS");
- gotoxy(25,10);
- cout<<"Wonsz \276eczny";
- 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 u1,m2;
- u1=rand()%80;
- m2=rand()%15+15;
- gotoxy(u1,m2);
- SetConsoleTextAttribute(hConsole, 4);
- cout << "X";
- SetConsoleTextAttribute(hConsole, 7);
- int u,m;
- u=rand()%80;
- m=rand()%15+15;
- gotoxy(u,m);
- SetConsoleTextAttribute(hConsole, 2);
- cout << "X";
- SetConsoleTextAttribute(hConsole, 7);
- 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-1); cout << " ";
- break;
- case 72 : y--;gotoxy(x,y); cout<<"@"; //gora
- gotoxy(x,y+1); cout << " ";
- break;
- case 77 : x++;gotoxy(x,y); cout<<"@"; //prawo
- gotoxy(x-1,y); cout << " ";
- break;
- case 75 : x--;gotoxy(x,y); cout<<"@"; //lewo
- gotoxy(x+1,y); cout << " ";
- break;
- }
- }
- if ((y == 15)||(y==30)||(x==80)||(x==1)){system ("cls");
- cout << "PRZEGRANA! Wonsz \276eczny by\210 zbyt niebezpieczny!"<<endl;
- cout << "Liczba uzyskanych punktow: " << pkt-1<<endl;
- cout << " _______________________________________________________ "<<endl;
- cout << "| | "<<endl;
- cout << "| Ha ha, you're dead | "<<endl;
- cout << "|_________ ________________________________| "<<endl;
- cout << " |_ __/ ___---------__ "<<endl;
- cout << " | _/ / |_ "<<endl;
- cout << " | / / | "<<endl;
- cout << " | / | _ _ \ | "<<endl;
- cout << " | | / / | / | | | "<<endl;
- cout << " | | || || || | "<<endl;
- cout << " | | | |_//\|_/ | | "<<endl;
- cout << " | | |_| (||) |_______| | "<<endl;
- cout << " | | | || | _ / / | "<<endl;
- cout << " | | |_________|| \/ / / "<<endl;
- cout << " | |_ |_|_|_|_|/| _/___/ "<<endl;
- cout << " |__> _ _/_ _ / | "<<endl;
- cout << " .|_|_|_|_| | "<<endl;
- cout << " | / "<<endl;
- cout << " |__________/ "<<endl;
- cout << "ESC aby wyj\230\206";
- };
- if ((y==m)&&(x==u))
- {
- u=rand()%79+1;
- m=rand()%15+15;
- gotoxy(u,m);
- SetConsoleTextAttribute(hConsole, 2);
- cout << "X";
- SetConsoleTextAttribute(hConsole, 7);
- pkt=pkt+1;
- gotoxy(u1,m2);
- cout << " ";
- u1=rand()%79;
- m2=rand()%15+14;
- gotoxy(u1,m2);
- SetConsoleTextAttribute(hConsole, 4);
- cout << "X";
- SetConsoleTextAttribute(hConsole, 7);
- gotoxy(25,12);
- cout << "Liczba uzyskanych punktow: " << pkt-1;
- };
- if ((y==m2)&&(x==u1))
- {
- system("cls");
- cout << "PRZEGRANA! Wonsz \276eczny by\210 zbyt niebezpieczny!"<<endl;
- cout << "Liczba uzyskanych punktow: " << pkt-1<<endl;
- cout << " _______________________________________________________ "<<endl;
- cout << "| | "<<endl;
- cout << "| Ha ha, you're dead | "<<endl;
- cout << "|_________ ________________________________| "<<endl;
- cout << " |_ __/ ___---------__ "<<endl;
- cout << " | _/ / |_ "<<endl;
- cout << " | / / | "<<endl;
- cout << " | / | _ _ \ | "<<endl;
- cout << " | | / / | / | | | "<<endl;
- cout << " | | || || || | "<<endl;
- cout << " | | | |_//\|_/ | | "<<endl;
- cout << " | | |_| (||) |_______| | "<<endl;
- cout << " | | | || | _ / / | "<<endl;
- cout << " | | |_________|| \/ / / "<<endl;
- cout << " | |_ |_|_|_|_|/| _/___/ "<<endl;
- cout << " |__> _ _/_ _ / | "<<endl;
- cout << " .|_|_|_|_| | "<<endl;
- cout << " | / "<<endl;
- cout << " |__________/ "<<endl;
- cout << "ESC aby wyj\230\206";
- };
- if (key==27)break;
- /*
- */
- ;
- }
- while (true);
- //system ("PAUSE")
- return 0;
- }
Add Comment
Please, Sign In to add comment