Archived

This topic is now archived and is closed to further replies.

dragov

Keeping the player in the middle of the screen??

Recommended Posts

How can I have the player be in the middle of the screen, and the screen move as the player move?? Not sure if you understand, but if you do, an answer would be greatly welcome . ~-~-~-~-~-~-~-~-~ RPG D&D

Share this post


Link to post
Share on other sites
I think i know what you mean .. in which case dont move the player, but just move the background.

Share this post


Link to post
Share on other sites
If you''re using gluLookAt to position the camera, then you just need to make the camera look at your object and position the camera a little bit behind it.
gluLookAt(player.x, player.y, player.z - 10, player.x, player.y, player.z, upvector.x, upvector.y, upvector.z);

i think that should do the trick.

Share this post


Link to post
Share on other sites
I do the exact same thing, except, instead of keeping the player in the middle - I keep a spacecraft in the middle.
I do not use gluLookAt. I just apply all of the transformations to all the things that should be zooming by while the player would be "moving". In other words, instead of moving the player 3 units on the Y-Axis, I move a tree -3 units on the Y-axis.
It is really simple, once you get the hang of it.

Hope this helps,

TommyB

Share this post


Link to post
Share on other sites
That'' the other way to make it.
Depends on how you see everything. Either the worls moves around your fixed player, or the player moves around a fixed world

Share this post


Link to post
Share on other sites
And in the end, stationary camera is in eye space and everything moves around it

Share this post


Link to post
Share on other sites
I have also been trying to solve this problem... I understand what you mean about the camera following the character around the screen but, i dont know how you get the position the character is facing. What i have for now is a cube that is infront of the camera, using a gluLookat eventually i dont want to actually see the character only look though its eyes. The only person that will see this character is someone looking at it though a network. So i need to me able to store those varibles (xPos,YPos,zPos, yRot,xRot, ZRot) somewhere right now i have a structure to keep track of it. I can sort of get the camera to follow the cube, but i cant get it to rotate with the camera, when i us ethe mouse. Im not sure if im explaining it clearly or not.

If you need to see the exe or source code to help let me know either replying to this message or sending me an email at E_Williams@Rogers.com.

Share this post


Link to post
Share on other sites