Advertisement
adventuretimeh

DG_NEW DEV

Sep 28th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <iostream>
  4. #include <time.h>
  5. #include <windows.h>
  6. void gotoxy(int x, int y)
  7. {
  8.  COORD coord;
  9.  coord.X = x;
  10.  coord.Y = y;
  11.  SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  12. }
  13. void delay(unsigned int mseconds)
  14. {
  15.     clock_t goal = mseconds + clock();
  16.     while (goal > clock());
  17. }
  18. void getup()
  19. {
  20.     system("cls");
  21.     gotoxy(10,2);
  22.     printf("Press X to Exit, Press Space to Jump");
  23.     gotoxy(62,2);
  24.     printf("SCORE : ");
  25.     gotoxy(1,25);
  26.     for(int x=0;x<79;x++)
  27.     printf("fl");
  28. }
  29.  
  30. int t,speed=40;
  31. void ds(int jump=0)
  32. {
  33.     static int a=1;
  34.  
  35.     if(jump==0)
  36.         t=0;
  37.     else if(jump==2)
  38.         t--;
  39.     else t++;
  40.     gotoxy(2,15-t);
  41.     printf("                 ");
  42.     gotoxy(2,16-t);
  43.     printf("         ‹€fl€€€€‹");
  44.     gotoxy(2,17-t);
  45.     printf("         €€€€€€€€");
  46.     gotoxy(2,18-t);
  47.     printf("         €€€€€flflfl");
  48.     gotoxy(2,19-t);
  49.     printf(" €      ‹€€€€flflfl ");
  50.     gotoxy(2,20-t);
  51.     printf(" €€‹  ‹€€€€€€‹‹‹ ");
  52.     gotoxy(2,21-t);
  53.     printf(" fl€€€€€€€€€€€  fl ");
  54.     gotoxy(2,22-t);
  55.     printf("   fl€€€€€€€fl     ");
  56.     gotoxy(2,23-t);
  57.     if(jump==1 || jump==2){
  58.     printf("    €€fl fl€       ");
  59.     gotoxy(2,24-t);
  60.     printf("    €‹   €‹      ");
  61.     }else if(a==1)
  62.     {
  63.     printf("    fl€€fl  flflfl    ");
  64.     gotoxy(2,24-t);
  65.     printf("      €‹         ");
  66.     a=2;
  67.     }
  68.     else if(a==2)
  69.     {
  70.     printf("     fl€‹ fl€      ");
  71.     gotoxy(2,24-t);
  72.     printf("          €‹     ");
  73.     a=1;
  74.     }
  75.     gotoxy(2,25-t);
  76.     if(jump!=0){
  77.         printf("                ");
  78.     }
  79.     else
  80.     {
  81.        
  82.         printf("flflflflflflflflflflflflflflflflfl");
  83.     }
  84.     delay(speed);
  85. }
  86. void obj()
  87. {
  88.     static int x=0,scr=0;
  89.     if(x==56 && t<4)
  90.     {
  91.     scr=0;
  92.     speed=40;
  93.     gotoxy(36,8);
  94.     printf("Game Over");
  95.     getch();
  96.     gotoxy(36,8);
  97.     printf("         ");
  98.     }
  99.     gotoxy(74-x,20);
  100.     printf("€    € ");
  101.     gotoxy(74-x,21);
  102.     printf("€    € ");
  103.     gotoxy(74-x,22);
  104.     printf("€‹‹‹‹€ ");
  105.     gotoxy(74-x,23);
  106.     printf("  €    ");
  107.     gotoxy(74-x,24);
  108.     printf("  €  " );
  109.     x++;
  110.     if(x==73)
  111.     {
  112.     x=0;
  113.     scr++;
  114.     gotoxy(70,2);
  115.     printf("     ");
  116.     gotoxy(70,2);
  117.     printf("%d",scr);
  118.     if(speed>20)
  119.         speed--;
  120.     }
  121. }
  122. int main()
  123. {
  124.     system("mode con: lines=29 cols=82");
  125.     char ch;
  126.     int i;
  127.     getup();
  128.     while(true)
  129.     {
  130.         while(!kbhit())
  131.         {
  132.             ds();
  133.             obj();
  134.         }
  135.         ch=getch();
  136.         if(ch==' ')
  137.         {
  138.             for(i=0;i<10;i++)
  139.             {
  140.             ds(1);
  141.             obj();
  142.             }
  143.             for(i=0;i<10;i++)
  144.             {
  145.             ds(2);
  146.             obj();
  147.             }
  148.         }
  149.         else if (ch=='x')
  150.             return(0);
  151.     }
  152.    
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement