Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <console.h>
- #include <stdio.h>
- #include <time.h>
- #include <windows.h>
- class kijelzo{ //ez egy osztály|tipus
- private: // MAGÁN ANYÁD!!!!!!!!!!
- int meret;
- int hatter_szin;
- int ertek;
- int ertek_szin;
- int csucs;
- int csucs_szin;
- public: // Ezt már használhatod ^-^
- void meret_change (int m) {
- if(m<5) m=5;
- if(m>20)m=20;
- meret=m; }
- void hatter_szin_change (int sz){hatter_szin=sz;}
- void ertek_change (int e){
- if(e<0) e=0;
- if(e>meret) e=meret;
- ertek=e; if(csucs<ertek) csucs=ertek; }
- void ertek_szin_change (int sz){ertek_szin=sz;}
- void csucs_szin_change (int sz) { csucs_szin=sz; }
- void tiky_taky() { if(csucs>ertek) csucs--; }
- void ki_rajzol (int also_x, int also_y){
- for(int i=0;i<meret;i++){ Sleep(0);
- if(i<ertek) textcolor(ertek_szin);
- else textcolor(hatter_szin);
- gotoxy(also_x,also_y-i);
- printf("X");
- textcolor(csucs_szin);
- tiky_taky();
- if(csucs>0) { gotoxy(also_x,also_y-csucs+1);
- printf("O");} } }
- };
- kijelzo k;
- int main() {
- srand(time(NULL));
- // console_fullscreen();
- int x=0; //x kordináta válltoztatása
- int x1 =78;
- char c=0;
- while(kbhit()!=1 || getch(c)!=27) {
- if(kbhit() || c=='w'|| c=='W') x1++;
- if(kbhit() || c=='s'|| c=='S') x1--;
- k.meret_change(10);
- k.ertek_szin_change(10*16);
- k.hatter_szin_change(1*16);
- k.csucs_szin_change(12*16);
- x=rand()%x1+1;
- k.ertek_change(rand()%11+1);
- k.ki_rajzol(x,24);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment