VPN termux about China.net

BUGS part2



#ifdef __APPLE__
#include<GLUT/glut.h>
#include<openGL/openGL.h>

#else
#include<GL/glut.h>
#endif
#include <stdlib.h>
#include <string.h>
 #include <GL/gl.h>
#include <GL/glu.h>
#include<GL/glut.h>

#include <new>




#define  LIST_OBJECT  128


  //global                                                                                                              
GLfloat d = 0.1;
int refreshMillis = 30; 
//end global
    


  
    
struct kulka
{     
            
GLfloat x;
GLfloat y ;

} kulka={0.0, -0.5} , wall= {1.0 , 1.0} , speed= {0.03, 0.04};
            
struct point
{
GLfloat x;
GLfloat y;
} point, quad;


namespace glut {


void CreateList(void)
{

for (int i=0; i<32; i++)
{
 glNewList(LIST_OBJECT *i, GL_COMPILE);
{


glColor3f(1.0,1.0,.0);
 
    glutSolidSphere(d,4,4);
glFlush ();

}

  glEndList();

}

}

void enemy()
{


int i=0;
point.x=-0.9;
point.y=-0.0;
quad.x=0.9;
quad.y=0.7;

glBegin(GL_POLYGON);
glVertex2f(-quad.x, quad.y);
glVertex2f(quad.x, quad.y);
glVertex2f(quad.x, 0.0);
glVertex2f(-quad.x, 0.0);
glEnd();
do

{

i++;
if ( (point.x>quad.x-0.2)&& (quad.y>point.y))
{
point.y=point.y+0.2;
point.x=-quad.x;

}
glPushMatrix();
glTranslatef(point.x ,point.y, 0.0);
  glCallList(LIST_OBJECT *i);
point.x=point.x+0.2;
 glPopMatrix();
 if (((point.y-0.2)<kulka.y+d) &&   (kulka.x<d +(point.x-0.2) )&& ((point.x-0.2)<d+kulka.x) &&((kulka.y-0.2)<d+point.y)  )
{
glDeleteLists(LIST_OBJECT *i, 1);

}   
}
 while( quad.x>point.x && quad.y>point.y);






  
 glFlush ();


}

};
namespace glut {

GLfloat x2 , y2=-0.7;

void drawBall2(GLfloat x2,  GLfloat y2)
{

    glColor3f(1.0,0.0,.0);

    glPushMatrix();

    glTranslatef(x2, y2,0.0);

    glutSolidSphere(d,20,20);

    glPopMatrix();


}
void keyboard (unsigned char key, int x, int y )   //core dumpted p.
{

switch (key) {
case 'd':
x2=x2+0.1;
glutPostRedisplay();
break;
case 'a':
x2=x2-0.1;
glutPostRedisplay();
break;
case 'w':
y2=y2+0.1;
glutPostRedisplay();
break;
case 's':
y2=y2-0.1;
glutPostRedisplay();
break;
}
}

};
                                                        //p.

namespace glut {                //class


       



void drawBall1()
{

    glColor3f(0.0,1.0,.0);

    glPushMatrix();

    glTranslatef(kulka.x,kulka.y,0.0);

    glutSolidSphere(d,20,20);

    glPopMatrix();
}


void update()
{
kulka.x+=speed.x;
kulka.y+=speed.y;
if (kulka.x>wall.x)
{
speed.x=-speed.x;
}
if ( kulka.y>wall.y)
{
speed.y=-speed.y;
}
  if(kulka.x<-wall.x)
 {
speed.x=-speed.x;
}

if((  kulka.y<d + glut::y2) && (kulka.x <d +glut::x2  )&& (glut::x2-kulka.x<d) )
{

speed.y=-speed.y;
}


}

};
void display()
{
    glClear(GL_COLOR_BUFFER_BIT);

    glMatrixMode(GL_MODELVIEW);

    glLoadIdentity();


 glShadeModel(GL_SMOOTH);



glut::drawBall2(glut::x2, glut::y2);   
glut:: drawBall1();
glut::update();
glut::enemy();

                 



glutSwapBuffers();
}



void initRendering()
{
    glEnable(GL_DEPTH_TEST);    //que ce se?? p
}

void reshape(int w,int h)
{
    glViewport(0,0,w,h);

    glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
  
 
glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
}             

void Timer(int value)          //kopjuj wklej p.
 {
   glutPostRedisplay();    // Post a paint request to activate display()
   glutTimerFunc(refreshMillis, Timer, 0); // subsequent timer call at milliseconds
}


int main(int argc,char **argv)                   //kopjuj wklej p.

{

    glutInit(&argc,argv);

    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

    glutInitWindowSize(400,400);

    glutCreateWindow("gra Q");

  initRendering();
    glut::CreateList();


    glutReshapeFunc(reshape);

  glutKeyboardFunc(glut::keyboard);

glutTimerFunc(0, Timer, 0); 

   glutDisplayFunc(display);
    glutMainLoop();

    return 0;

}

No comments:

Post a Comment