Archived

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

DevLiquidKnight

How do i keep the screen on the player?

Recommended Posts

I have varibles set up for the top left hand corner of the screen and im trying to figure out how to make the screen stay centered on the player if the screen goes left to right it goes at the speed of 3 pixles per frame and the player moves at 1 pixle per frame. Ive had a few problems where the screen isnt centered correctly. How could i fix this?

Share this post


Link to post
Share on other sites
Why should you move the screen faster than the player? Just move them at the same rate. Or calculate the screen position directly based on the player position. Typically to centre something you need to subtract half the width or whatever. So to centre a 640x480 screen on a player, you set the top-left of the screen to -320, -240 compared to the player.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

Share this post


Link to post
Share on other sites