Advertisement
apl-mhd

RapidRollFinalV1

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