Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

animating primitives

This topic is 2379 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to move 2 primitives each with keyboard input.here is the code I am working with.
[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/font][/font][/font]


[font="Consolas"][size="2"][font="Consolas"][size="2"]DrawShip()[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glPushMatrix();[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glColor3f(0.0f,1.0f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glBegin(GL_LINE_LOOP);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(0.0f,-0.25f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-0.25f,-0.5f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-0.5f,-0.5f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-0.0f,0.5f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(0.5f,-0.5f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(0.25f,-0.5f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(0.0f,-0.25f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glEnd();[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glPopMatrix();[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/font][/font][/font]


[font="Consolas"][size="2"][font="Consolas"][size="2"]DrawAlien()[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glPushMatrix();[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glLoadIdentity();[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glTranslatef(2.0f,0.0f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glColor3f(1.0f,0.0f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glBegin(GL_LINE_LOOP);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(0.0f,-0.25f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-0.25f,-0.5f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-0.5f,-0.5f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-0.0f,0.5f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(0.5f,-0.5f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(0.25f,-0.5f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(0.0f,-0.25f,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glEnd();[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glPopMatrix();[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/font][/font][/font]


[font="Consolas"][size="2"][font="Consolas"][size="2"]RenderScene()[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]DrawShip();[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]DrawAlien();[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glutSwapBuffers();[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/font][/font][/font]


[font="Consolas"][size="2"][font="Consolas"][size="2"]ShipLeft()[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glRotatef(m,0.0f,0.0f,1.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]m+=0.1f;[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/font][/font][/font]


[font="Consolas"][size="2"][font="Consolas"][size="2"]ShipRight()[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/font][/font][/font]


[font="Consolas"][size="2"][font="Consolas"][size="2"]ShipUp()[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/font][/font][/font]


[font="Consolas"][size="2"][font="Consolas"][size="2"]ShipDown()[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/font][/font][/font]


[font="Consolas"][size="2"][font="Consolas"][size="2"]ShipBullet()[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/font][/font][/font]


[font="Consolas"][size="2"][font="Consolas"][size="2"]AlienUp()[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glTranslatef(0.0f,i,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]i+=0.1f;[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/font][/font][/font]


[font="Consolas"][size="2"][font="Consolas"][size="2"]AlienDown()[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glTranslatef(0.0f,j,0.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]j-=0.1f;[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/font][/font][/font]


[font="Consolas"][size="2"][font="Consolas"][size="2"]AlienLeft()[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glRotatef(k,0.0f,0.0f,1.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]k+=0.1f;[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/font][/font][/font]


[font="Consolas"][size="2"][font="Consolas"][size="2"]AlienRight()[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]glRotatef(l,0.0f,0.0f,1.0f);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]l-=0.1f;[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]?[/font][/font]

Share this post


Link to post
Share on other sites
Advertisement
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)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!