Advertisement
apl-mhd

fourthBlock

Dec 22nd, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.43 KB | None | 0 0
  1. # include "iGraphics.h"
  2.  
  3. int circleY = 590,  circleX = 190;
  4. int     firstX = 0, firstY = 0, firstMidY = 75, secondY = 150;
  5. int thirdY = 250, thirdMidY = 350, thirdX;
  6. int fourthY = 450, fourthMidY = 400, fourthX;
  7.  
  8. //int firstX = 0, firstY = 0, firstMidY = 75;
  9.  
  10. struct xyCordinate{
  11.  
  12.     int leftX;
  13.     int leftY;
  14.  
  15.     int midX;
  16.     int midY;
  17.  
  18.     int rightX;
  19.     int rightY;
  20.  
  21.  
  22. };
  23. struct xyCordinate xyAxis[5];
  24.  
  25.  
  26. void assignXY(){  /* assign xy cordinate in a structer varuab*/
  27.  
  28.    
  29. }
  30.  
  31. void incrementY(){
  32.  
  33.     if (firstY >= 585){ /*firtst Y*/
  34.         firstY = 0;
  35.         firstMidY = 75;
  36.         secondY = 150;
  37.         thirdMidY = 350;
  38.         thirdY = 250;
  39.  
  40.         fourthY = 450;
  41.         fourthMidY = 400;
  42.     }
  43.     else
  44.     {
  45.  
  46.         firstY += 4;
  47.         firstMidY += 4;
  48.         secondY += 4;
  49.  
  50.         thirdMidY += 4;
  51.         thirdY += 4;
  52.  
  53.         fourthY += 4;
  54.         fourthMidY += 4;
  55.     }
  56.     //if (firstMidY >= 585)
  57.         //firstMidY = 50;
  58.     //else
  59.         //firstMidY += 4; /*End First Y*/
  60.  
  61.     /***
  62.     if (secondY >= 585){ //second Y
  63.         secondY = 100;
  64.     }
  65.     else
  66.  
  67.         secondY += 4;
  68.    
  69.     ****/
  70.  
  71.  
  72.  
  73.    
  74.     if (circleY < 0){/*circle incrementing decrementing section and initialize*/
  75.  
  76.         circleY = 590;
  77.  
  78.     }
  79.     else{
  80.         if ((circleY - firstMidY) <= 25 && (circleY - firstMidY) > 20 &&  circleX <260 && circleX>150){
  81.        
  82.             circleY += 4;
  83.  
  84.         }
  85.         else{
  86.             circleY -= 4;
  87.         }
  88.     } /*circle end*/
  89.  
  90.    
  91. }
  92.  
  93. //leftX.xyAxis[1] = 100;
  94.  
  95. void iDraw()
  96. {
  97.  
  98.     iClear();
  99.     iSetColor(100, 200, 50);
  100.     iFilledCircle(circleX, circleY, 10);
  101.  
  102.     iSetColor(224, 91, 63); /* start first block*/
  103.  
  104.     iFilledRectangle(50, firstY, 100, 15); //first left block
  105.  
  106.     iFilledRectangle(150, firstMidY, 100, 15);  //mid
  107.  
  108.     iFilledRectangle(250, firstY, 100, 15);  //  first right Block
  109.  
  110.     /******Start second Block******/
  111.  
  112.     iSetColor(74, 255, 106);/*red*/
  113.  
  114.     iFilledRectangle(100, secondY, 100, 15); // second left block
  115.  
  116.  
  117.  
  118.     iFilledRectangle(300, secondY, 100, 15);  //End second Block
  119.  
  120.  
  121.     /**********Start third block******/
  122.  
  123.  
  124.     iSetColor(49, 140, 19); /* start third block*/
  125.  
  126.     iFilledRectangle(50, thirdY, 100, 15); //third left block
  127.  
  128.     iFilledRectangle(130, thirdMidY, 100, 15);  //mid
  129.  
  130.     iFilledRectangle(250, thirdY, 100, 15);  //  third right Block
  131.  
  132.  
  133.     /*************end third block***********************************/
  134.  
  135.     /*startfourth block*/
  136.         iSetColor(25, 139, 27);
  137.  
  138.         iFilledRectangle(50, fourthY, 100, 15);
  139.  
  140.         iFilledRectangle(275, fourthMidY, 100, 15);
  141.  
  142.     /*end fourth block*/
  143.  
  144.  
  145.  
  146. }
  147.  
  148. void iMouseMove(int mx, int my)
  149. {
  150.  
  151.  
  152.     printf(" %d %d\n", mx, my);
  153. }
  154.  
  155. void iMouse(int button, int state, int mx, int my)
  156. {
  157.     if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
  158.     {
  159.  
  160.     }
  161.     if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
  162.     {
  163.  
  164.     }
  165. }
  166.  
  167. void iKeyboard(unsigned char key)
  168. {
  169.     if (key == 'q')
  170.     {
  171.  
  172.     }
  173.  
  174. }
  175.  
  176.  
  177. void iSpecialKeyboard(unsigned char key)
  178. {
  179.     if (key == GLUT_KEY_UP)
  180.     {
  181.        
  182.         circleY += 4;
  183.         printf("%d\n", circleY - firstMidY);
  184.         //exit(0);
  185.     }
  186.  
  187.     if (key == GLUT_KEY_DOWN)
  188.     {
  189.  
  190.         circleY -= 4;
  191.         printf("%d\n", circleY-firstMidY);
  192.        
  193.         /*
  194.         if ((circleY - firstMidY) <= 25 && circleX <250 && circleX>150){
  195.             circleY = 590;
  196.  
  197.         }
  198.         else
  199.             circleY -= 4;
  200.         printf("%d\n", circleX);
  201.         //exit(0);
  202.         */
  203.     }
  204.  
  205.  
  206.     if (key == GLUT_KEY_LEFT)
  207.     {
  208.  
  209.         circleX -= 15;
  210.  
  211.         //exit(0);
  212.     }
  213.  
  214.     if (key == GLUT_KEY_RIGHT)
  215.     {
  216.         circleX += 15;
  217.  
  218.         //exit(0);
  219.     }
  220.  
  221. }
  222. int main()
  223. {
  224. //  firstX = 0, firstY = 0, firstMidY = 75,secondY=150;
  225.  
  226.  
  227.     iSetTimer(10, incrementY);
  228.     iInitialize(400, 600, "demooo");
  229.     return 0;
  230. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement