Advertisement
apl-mhd

gameRapidRoolGamev2

Dec 18th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.57 KB | None | 0 0
  1. # include "iGraphics.h"
  2. /*
  3. function iDraw() is called again and again by the system.
  4. */
  5.  
  6. double counter = 0, increse = 50, circleYaxis = 500, circleXaxis=200;
  7.  
  8.  
  9.  
  10.  
  11. void ipointIncrese(){
  12.  
  13.  
  14.  
  15.     //if ((increse+20) > circleYaxis && circleXaxis>150 && circleXaxis<250 ){
  16.     if ((increse + 20) > circleYaxis && circleXaxis>150 && circleXaxis<250){
  17.  
  18.         increse += 1;
  19.  
  20.         circleYaxis +=1 ;
  21.     }
  22.     /*
  23.     else if ((increse + 30) > circleYaxis ){
  24.  
  25.  
  26.         increse += 1;
  27.  
  28.         circleYaxis += 1;
  29.     }*/
  30.     else{
  31.  
  32.  
  33.  
  34.         increse += 1;
  35.  
  36.         circleYaxis -= 1;
  37.  
  38.     }
  39.  
  40.     //printf("%d", circleXaxis);
  41. }
  42.  
  43.  
  44. void iDraw()
  45. {
  46.     //place your drawing codes here
  47.     iClear();
  48.  
  49.     //iSetColor(255, 255, 255);
  50.  
  51.     //iShowBMP(0, 0, "img/home.bmp");
  52.  
  53.     //iShowBMP(150, 300, "img/newGame.bmp");
  54.     //iShowBMP(150, 00, "img/a.bmp");
  55.     //iShowBMP(155, 250, "img/setting.bmp");
  56.     //iShowBMP(150, 200, "img/highScore.bmp");
  57.     //iShowBMP(160, 150, "img/exit.bmp");
  58.  
  59.     iSetColor(255, 255, 0);
  60.     //iPoint(0, 0, increse);
  61.     //iFilledCircle(circleXaxis, circleYaxis, 10);
  62.  
  63.     if (circleYaxis == 50){
  64.    
  65.         circleYaxis = 500;
  66.     }
  67.  
  68.     if (increse ==500){
  69.        
  70.         increse = 50;
  71.     }
  72.  
  73.     if (circleYaxis == increse){
  74.    
  75.        
  76.  
  77.     }
  78.  
  79.     //printf("increse = %d  \n", increse);
  80.  
  81.  
  82.     iFilledCircle(circleXaxis, circleYaxis, 10);
  83.  
  84.  
  85.  
  86.  
  87.     //iFilledRectangle(10, increse, 100, 10);
  88.     //iFilledRectangle(300, increse, 100, 10);
  89.     iFilledRectangle(150, increse+10, 100, 10);
  90.     iFilledRectangle(5, increse, 100, 10);
  91.  
  92.    
  93.  
  94.     //iFilledRectangle(10, 500, 100, 20);
  95.     //void iText(GLdouble x, GLdouble y, char *str, void* font = GLUT_BITMAP_8_BY_13)
  96.  
  97. }
  98. /*
  99. function iMouseMove() is called when the user presses and drags the mouse.
  100. (mx, my) is the position where the mouse pointer is.
  101. */
  102. void iMouseMove(int mx, int my)
  103. {
  104.  
  105.  
  106. printf(" %d %d\n",  mx, my);
  107. }
  108. /*
  109. function iMouse() is called when the user presses/releases the mouse.
  110. (mx, my) is the position where the mouse pointer is.
  111. */
  112. void iMouse(int button, int state, int mx, int my)
  113. {
  114.     if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
  115.     {
  116.        
  117.  
  118.        
  119.         //xCo = 10;
  120.         //iSetColor(255, 0, 0);
  121.  
  122.         //iRectangle(10, 20, 100, 200);
  123.  
  124.     }
  125.     if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
  126.     {
  127.         //place your codes here
  128.     }
  129. }
  130. /*
  131. function iKeyboard() is called whenever the user hits a key in keyboard.
  132. key- holds the ASCII value of the key pressed.
  133. */
  134. void iKeyboard(unsigned char key)
  135. {
  136.     if (key == 'q')
  137.     {
  138.         //do something with 'q'
  139.     }
  140.     //place your codes for other keys here
  141. }
  142. /*
  143. function iSpecialKeyboard() is called whenver user hits special keys likefunction
  144. keys, home, end, pg up, pg down, arraows etc. you have to use
  145. appropriate constants to detect them. A list is:
  146. GLUT_KEY_F1, GLUT_KEY_F2, GLUT_KEY_F3, GLUT_KEY_F4, GLUT_KEY_F5, GLUT_KEY_F6,
  147. GLUT_KEY_F7, GLUT_KEY_F8, GLUT_KEY_F9, GLUT_KEY_F10, GLUT_KEY_F11,
  148. GLUT_KEY_F12, GLUT_KEY_LEFT, GLUT_KEY_UP, GLUT_KEY_RIGHT, GLUT_KEY_DOWN,
  149. GLUT_KEY_PAGE UP, GLUT_KEY_PAGE DOWN, GLUT_KEY_HOME, GLUT_KEY_END,
  150. GLUT_KEY_INSERT */
  151. void iSpecialKeyboard(unsigned char key)
  152. {
  153.     if (key == GLUT_KEY_UP)
  154.     {
  155.         //if (circleYaxis<=500)
  156.         circleYaxis += 1;
  157.         //exit(0);
  158.     }
  159.  
  160.     if (key == GLUT_KEY_DOWN)
  161.     {
  162.  
  163.         circleYaxis -= 1;
  164.         if (circleYaxis == increse){
  165.            
  166.             circleYaxis = 500;
  167.         }
  168.         //exit(0);
  169.     }
  170.  
  171.  
  172.     if (key == GLUT_KEY_LEFT)
  173.     {
  174.  
  175.         circleXaxis -= 20;
  176.         //exit(0);
  177.     }
  178.  
  179.     if (key == GLUT_KEY_RIGHT)
  180.     {
  181.  
  182.         circleXaxis += 20;
  183.         //exit(0);
  184.     }
  185.  
  186.  
  187.     //place your codes for other keys here
  188. }
  189. int main()
  190. {
  191.     //place your own initialization codes here.
  192.  
  193.     iSetTimer(1, ipointIncrese);
  194.     iInitialize(400, 600, "demooo");
  195.     return 0;
  196. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement