Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

OpenGL simple space ship movement question

This topic is 2499 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

well I am attempting to move a space ship up the screen using opengl, I have googled this quite extensively but to no avail.
here is the code I am working on.
[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"][color="#000000"] AlienUp()[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/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(-5.0f,-0.25f+i,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-5.25f,-0.5f+i,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-5.5f,-0.5f+i,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-5.0f,0.5f+i,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-4.5f,-0.5f+i,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-4.75f,-0.5f+i,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-5.0f,-0.25f+i,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glEnd();[/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"][font="Consolas"][size="2"]I know it probably an obvious answer but I for the life of me cant figure it out.I will do more research.[/font][/font]

Share this post


Link to post
Share on other sites
Advertisement
if you don't want any rotation, simply call glTranslatef(x,y,0.0f) before you draw the object(make sure you call glLoadIdentity at the start of your draw code as well); and change the value of x/y to move it around.

Share this post


Link to post
Share on other sites
well here is my code
[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"][color="#000000"] AlienLeft()[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glMatrixMode(GL_MODELVIEW);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glLoadIdentity();[/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"]glPushMatrix();[/font][/font]


[font="Consolas"][size="2"][font="Consolas"][size="2"]glTranslatef(0.0f,0.0f,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]k+=0.01f;[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]I am trying to rotate a space ship.[/font][/font]

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!