Advertisement
apl-mhd

addTwoLevelBlock

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