Hi
I’m just beginning with programming OpenGL. I try to make small animation of stuck or LIFO but I don’t know how to move the cubes. I have made a cube with display list. First cube is folling and stopping on the bottom of the screen but I don’t know how to make 4 other cubes also to fall and stop on this first one.
My english isn’t well so maybe You better understand it from the code:
y=6.0f; //position from which cube is folling
yp=0.01f; //speed of falling
nrk=1;//should be a number of cube
GLvoid glRysujS()
{
glLoadIdentity();
glTranslatef(0.0f,-2.0f + (nrk*0.5),-1.0f + z);
glRotatef(100.0f,1.0f,0.0f,0.0f);
glRotatef(20.0f,0.0f,0.0f,1.0f);
glCallList(klocek);
}
GLvoid glRysujStos()
{ glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,z);
auxInitDisplayMode(AUX_DOUBLE | AUX_RGBA);
for(loop=1;loop<6;loop++)
{
glTranslatef(0.0f,y,-1.0f+z);
if(y>-2.0f + (nrk*0.5))
{
glPushMatrix();
glLoadIdentity();
y-=yp;
glTranslatef(0.0f,y,-1.0f+z);
glRotatef(100.0f,1.0f,0.0f,0.0f);
glRotatef(20.0f,0.0f,0.0f,1.0f);
glCallList(klocek);
glPopMatrix();
glFlush();
auxSwapBuffers();
}
else
{
glRysujS();
}
}
Sleep(1);
}
int DrawGLScene(GLvoid)
{
....
glRysujStos();
}
Please help!!
Thanks!