Jump to content

  • Log In with Google      Sign In   
  • Create Account

animating primitives


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 15 March 2012 - 08:56 PM

I am trying to move 2 primitives each with keyboard input.here is the code I am working with.
void


DrawShip()

{

glPushMatrix();

glColor3f(0.0f,1.0f,0.0f);

glBegin(GL_LINE_LOOP);

glVertex3f(0.0f,-0.25f,0.0f);

glVertex3f(-0.25f,-0.5f,0.0f);

glVertex3f(-0.5f,-0.5f,0.0f);

glVertex3f(-0.0f,0.5f,0.0f);

glVertex3f(0.5f,-0.5f,0.0f);

glVertex3f(0.25f,-0.5f,0.0f);

glVertex3f(0.0f,-0.25f,0.0f);

glEnd();

glPopMatrix();

}

void


DrawAlien()

{

glPushMatrix();

glLoadIdentity();

glTranslatef(2.0f,0.0f,0.0f);

glColor3f(1.0f,0.0f,0.0f);

glBegin(GL_LINE_LOOP);

glVertex3f(0.0f,-0.25f,0.0f);

glVertex3f(-0.25f,-0.5f,0.0f);

glVertex3f(-0.5f,-0.5f,0.0f);

glVertex3f(-0.0f,0.5f,0.0f);

glVertex3f(0.5f,-0.5f,0.0f);

glVertex3f(0.25f,-0.5f,0.0f);

glVertex3f(0.0f,-0.25f,0.0f);

glEnd();

glPopMatrix();

}

void


RenderScene()

{

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

DrawShip();

DrawAlien();

glutSwapBuffers();

}

void


ShipLeft()

{

glRotatef(m,0.0f,0.0f,1.0f);

m+=0.1f;

}

void


ShipRight()

{

}

void


ShipUp()

{

}

void


ShipDown()

{

}

void


ShipBullet()

{

}

void


AlienUp()

{

glTranslatef(0.0f,i,0.0f);

i+=0.1f;

}

void


AlienDown()

{

glTranslatef(0.0f,j,0.0f);

j-=0.1f;

}

void


AlienLeft()

{

glRotatef(k,0.0f,0.0f,1.0f);

k+=0.1f;

}

void


AlienRight()

{

glRotatef(l,0.0f,0.0f,1.0f);

l-=0.1f;

}

 

Sponsor:

#2 Rld_   Members   -  Reputation: 1404

Like
0Likes
Like

Posted 16 March 2012 - 05:24 AM

For plain and simple keyboard input, you can check GetASyncKeyState. Otherwise you can google for "C++ keyboard input" or something similar for something more appropriate. (there has even been enough answered on this forum if you bothered to search)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS