Sign in to follow this  
ViolentAJ

GLUT: Player Movement

Recommended Posts

Hello. I'm working in C (stuck here since it's a project) and I'd like to know how to do keyboard and mouse motion of an avatar. I've been searching and searching but I cannot find any good tutorials specifically addressing this issue. I've done this time and again in Flash (AS2 and 3) but this is a whole different monster. Any help would be greatly appreciated. Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by ViolentAJ
Yeah, that doesn't tell you how to make a function to move the player. I've succeeded in making a basic function that works though. I already knew how to receive input from the keyboard.

Thanks anyway.


Create three variables for the player's position (x, y & z), then increment/decrement them when the correct key is pressed. When you redraw the scene, just use glTranslate(x, y, z) before drawing the player. You may want to encapsulate that with glPushMatrix() and glPopMatrix(). That's all there is to movement.

Does that answer your question? I'm not sure I understood your question in the first place, so tell me if I've misinterpreted.

Share this post


Link to post
Share on other sites
I think the player movement is all up to you. It's not that hard, I assume you know some trigonometrics (the most basic)
The implementation depends on your needs, for example you want acceleration, strafe etc. Don't wait for us to send code, it wont work for you (for example you are looking in 'x' instead of 'y' or the opposite direction)
this forum for example

googled first person movement glut, 6th hit: this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this