How do I make a circle jump up and down when I load in space?

0

I need to make a version of the game "Color Switch" in Visual Studio C ++ with Glut but I do not know how to make a geometric figure move.

Any help is welcome.

Below is the code for my circle

#include <math.h>
#include <GL/glut.h>

#ifndef M_PI
#define M_PI 3.1415926

#endif
#define CIRCLE_STEPS 50

void draw_face(int size)
{
    GLint i;
    glLineWidth(size);
    glColor3f(0, 0, 1);
    glBegin(GL_LINE_LOOP);
    glVertex2f(1.0, 0.0);

for (i = 1; i < CIRCLE_STEPS; i++)
    {
        GLfloat t = i * M_PI * 2 / CIRCLE_STEPS;
        glVertex2f(cos(t), sin(t));
    }
    glEnd();
}

void display(void) {
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1, 0, 0);
    gluOrtho2D(-4, 4, -4, 4);
    glBegin(GL_POLYGON);
    glVertex2f(-0.5, -0.5);
    glVertex2f(-0.5, 0.5);
    glVertex2f(0.5, 0.5);
    glEnd();
    draw_face(3);
    glFlush();
}

int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(500, 500);
    glutCreateWindow("simple");
    glutDisplayFunc(display);
    glutMainLoop();
}
    
asked by anonymous 01.11.2018 / 20:27

0 answers