Making a shape move (opengl, c++)

Hello guys. I wanna make the body (square) move left when I press the left arrow key. Unfortunately, it's in data structures and I don't know what to put in the "void SpecialKeys(int key, int x, int y)" part to make it move. Any help would be good. :) By the way, I'm just a beginner. Our prof explain this but it's still kind of a blur and I wanna learn as much as possible. Cheers!


#include <vector>
#include <time.h>

using namespace std;

#include "Glut_Setup.h"



struct Vertex
{
float x,y,z;
};

Vertex Body []=
{
(-0.5, -2, 0),
(0.5, -2, 0),
(0.5, -3, 0),
(-0.5, -3, 0)
};




void GameScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);





glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 1.0);
glVertex3f(-0.5, -2, 0);
glVertex3f(0.5, -2, 0);
glVertex3f(0.5, -3, 0);
glVertex3f(-0.5, -3, 0);
glEnd();







glutSwapBuffers();
}

void Keys(unsigned char key, int x, int y)
{
switch(key)
{

}
}

void SpecialKeys(int key, int x, int y)
{
switch(key)
{

}
}


Last edited on
Topic archived. No new replies allowed.