Advertisement

Animation Problems

Started by October 14, 2000 10:32 PM
0 comments, last by InFerN0 24 years, 3 months ago
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:

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...
InFerN0Not all who wander are lost...
I''m not sure about the implimintation, so I just wrote it a little differant for you.
    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