Advertisement
Kimossab

FlappyAsterisk

Jan 20th, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.34 KB | None | 0 0
  1. //ALL HAIL ASTERISK!! FUCK LELOUCH, FUCK BRITTANIA, ASTERISK IS THE THING!!
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <conio.h>
  6. #include <time.h>
  7.  
  8. #define distance_tun 5
  9. //size : 25 X 80
  10. //distance : 5
  11.  
  12. int position = 12,
  13.     tun = 0,
  14.     tunpos[80/distance_tun],
  15.     tunh1[80/distance_tun],
  16.     tunh2[80/distance_tun];
  17.  
  18. void arrangearray()
  19. {
  20.     if(tunpos[0] == 0)
  21.     {
  22.         int i;
  23.         for(i=0; i<(80/distance_tun)-1; i++)
  24.         {
  25.             tunpos[i] = tunpos[i+1];
  26.             tunh1[i] = tunh1[i+1];
  27.             tunh2[i] = tunh2[i+1];
  28.         }
  29.         tunpos[i] = 0;
  30.     }
  31. }
  32.  
  33. void printflap()
  34. {
  35.     printf("\n\n\n\n\n\n\n\n\n\n\n\n");
  36.     printf("  *");
  37.     printf("\n\n\n\n\n\n\n\n\n\n\n\n");
  38.     for(int i=0; i<80; i++)
  39.         printf("-");
  40.     for(int i=0; i<20; i++)
  41.         tunpos[i] = 0;
  42. }
  43.  
  44. void prntscrnfb()
  45. {
  46.     system("cls");
  47.     int p;
  48.     for(int n=0; n<25; n++)
  49.     {
  50.         if(n == position)
  51.         {
  52.             printf("  *");
  53.             p=3;
  54.         }
  55.         else p=0;
  56.         if(n < 12)
  57.         {
  58.             for(int i=0; i<80/distance_tun; i++)
  59.             {
  60.                 if(tunpos[i] == 0) break;
  61.                 for(; p <= tunpos[i]-1; p++)
  62.                     printf(" ");
  63.                 if(n <= tunh1[i])
  64.                 {
  65.                     printf("#");
  66.                     p++;
  67.                 }
  68.             }
  69.             if(n != 24) printf("\n");
  70.             continue;
  71.         }
  72.         if(n > 12)
  73.         {
  74.             for(int i=0; i<80/distance_tun; i++)
  75.             {
  76.                 if(tunpos[i] == 0) break;
  77.                 for(; p <= tunpos[i]-1; p++)
  78.                     printf(" ");
  79.                 if(n >= tunh2[i])
  80.                 {
  81.                     printf("#");
  82.                     p++;
  83.                 }
  84.             }
  85.         }
  86.         if(n != 24) printf("\n");
  87.     }
  88. }
  89.  
  90. void play(int times=0)
  91. {
  92.     if(position > 24) return;
  93.     if(tunpos[0] == 2)
  94.     {
  95.         if(position < tunh1[0] || position > tunh2[0])
  96.             return;
  97.         else tun++;
  98.     }
  99.    
  100.     if(_kbhit())
  101.         if(_getch() == ' ')
  102.             position -= 5;
  103.     //move the screen
  104.     position++;
  105.     for(int i=0; i<80/distance_tun; i++)
  106.     {
  107.         if(tunpos[i] == 0)
  108.             break;
  109.         if(tunpos[i] == 1)
  110.         {
  111.             tunpos[i] = 0;
  112.             arrangearray();
  113.             i--;
  114.             continue;
  115.         }
  116.         tunpos[i]--;
  117.     }
  118.     if(times%(2*distance_tun) == 0)
  119.     {
  120.         int i;
  121.         for(i=0; i<80/distance_tun; i++)
  122.             if(tunpos[i] == 0)
  123.                 break;
  124.         tunh1[i] = (rand() % 10)+1;
  125.         tunh2[i] = (rand() % 10)+13;
  126.         tunpos[i] = 70;
  127.     }
  128.     prntscrnfb();
  129.     return play(times+1);
  130. }
  131.  
  132. void main()
  133. {
  134.     srand(time(NULL));
  135.     while(true)
  136.     {
  137.         printflap();
  138.         play();
  139.         printf("\n\n\n\nCongratulations, you got through %d tunels!\n", tun);
  140.         getchar();
  141.     }
  142.     printf("\n\n\nALL HAIL THE ASTERISK!!\nMade in Portugal by Kimossab the idiot!");
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement