Guest User

Untitled

a guest
Apr 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. #include <console.h>
  2. #include <stdio.h>
  3. #include <time.h>
  4. #include <windows.h>
  5.  
  6.  
  7. class kijelzo{ //ez egy osztály|tipus
  8. private: // MAGÁN ANYÁD!!!!!!!!!!
  9. int meret;
  10. int hatter_szin;
  11. int ertek;
  12. int ertek_szin;
  13. int csucs;
  14. int csucs_szin;
  15. public: // Ezt már használhatod ^-^
  16. void meret_change (int m) {
  17. if(m<5) m=5;
  18. if(m>20)m=20;
  19. meret=m; }
  20.  
  21. void hatter_szin_change (int sz){hatter_szin=sz;}
  22.  
  23. void ertek_change (int e){
  24. if(e<0) e=0;
  25. if(e>meret) e=meret;
  26. ertek=e; if(csucs<ertek) csucs=ertek; }
  27.  
  28. void ertek_szin_change (int sz){ertek_szin=sz;}
  29. void csucs_szin_change (int sz) { csucs_szin=sz; }
  30.  
  31. void tiky_taky() { if(csucs>ertek) csucs--; }
  32.  
  33. void ki_rajzol (int also_x, int also_y){
  34. for(int i=0;i<meret;i++){ Sleep(0);
  35.  
  36. if(i<ertek) textcolor(ertek_szin);
  37. else textcolor(hatter_szin);
  38.  
  39. gotoxy(also_x,also_y-i);
  40.  
  41. printf("X");
  42. textcolor(csucs_szin);
  43. tiky_taky();
  44. if(csucs>0) { gotoxy(also_x,also_y-csucs+1);
  45.  
  46. printf("O");} } }
  47. };
  48.  
  49.  
  50. kijelzo k;
  51.  
  52. int main() {
  53. srand(time(NULL));
  54. // console_fullscreen();
  55. int x=0; //x kordináta válltoztatása
  56. int x1 =78;
  57. char c=0;
  58. while(kbhit()!=1 || getch(c)!=27) {
  59.  
  60. if(kbhit() || c=='w'|| c=='W') x1++;
  61. if(kbhit() || c=='s'|| c=='S') x1--;
  62.  
  63. k.meret_change(10);
  64. k.ertek_szin_change(10*16);
  65. k.hatter_szin_change(1*16);
  66. k.csucs_szin_change(12*16);
  67.  
  68. x=rand()%x1+1;
  69.  
  70. k.ertek_change(rand()%11+1);
  71. k.ki_rajzol(x,24);
  72. }
  73. return 0;
  74. }
Add Comment
Please, Sign In to add comment