void ConDrawConsole()
{
ConCheckState();
glDisable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D, contex.texID);
glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f);glVertex2f(0,1280);
glTexCoord2f(0.0f,1.0f);glVertex2f(0, cy);
glTexCoord2f(1.0f,1.0f);glVertex2f(1024,cy);
glTexCoord2f(1.0f,0.0f);glVertex2f(1024,1280);
glEnd();
glTranslatef (0, -30,0);
glEnable(GL_DEPTH_TEST);
}
void ConAnimateUp()
{
cy += 5;
if(cy >= 1280)
{
cy = 1280;
constate = CONUP;
conactive = false;
drawcon = false;
}
}
void ConAnimateDown()
{
cy -= 5;
if(cy <= 640)
{
cy = 640;
constate = CONDOWN;
}
}
void ConToggle()
{
if(conactive == true)
{
conactive = false;
constate = CONMOVINGUP;
}
else
{
conactive = true;
constate = CONMOVINGDOWN;
}
ConCheckState();
}
int ConCheckState()
{
if(!conactive)
{
if(constate != CONMOVINGUP)
{
drawcon = false;
}
return 0;
}
else
{
drawcon = true;
}
if(constate == CONMOVINGUP)
{
ConAnimateUp();
return 1;
}
if(constate == CONMOVINGDOWN)
{ ConAnimateDown();
return 1;
}
}
Thanks.
InFerN0
Not all who wander are lost...
Animation Problems
I have created a quake like console and I am having some trouble with animation. When the console is activated it comes partway down and then stops. when it is activated again it continues to half waydown the screen(the correct position) and wll not go back up. Code below:
InFerN0Not all who wander are lost...
I''m not sure about the implimintation, so I just wrote it a little differant for you.
All you need to do to make the console come down is this:
conactive = true;
cd=-5;
To make it go up:
cd=5;
Once the console is all the way up, it stops drawing it. This way there is a lot less function calls, and less variables.
void ConDrawConsole(){ if(conactive) { glDisable(GL_DEPTH_TEST); glBindTexture(GL_TEXTURE_2D, contex.texID); glBegin(GL_QUADS); glTexCoord2f(0.0f,0.0f);glVertex2f(0,1280); glTexCoord2f(0.0f,1.0f);glVertex2f(0, cy); glTexCoord2f(1.0f,1.0f);glVertex2f(1024,cy); glTexCoord2f(1.0f,0.0f);glVertex2f(1024,1280); glEnd(); glTranslatef (0, -30,0); glEnable(GL_DEPTH_TEST); cy+=cd; // cd means console direction if(cy > 1280) { cy = 1280; } if(cy < 0) { cy = 0; conactive = false; }}
All you need to do to make the console come down is this:
conactive = true;
cd=-5;
To make it go up:
cd=5;
Once the console is all the way up, it stops drawing it. This way there is a lot less function calls, and less variables.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement