Sign in to follow this  
Evil Booger

How to make scrolling camera in my racing game

Recommended Posts

Evil Booger    100
I'm making a gta2 clone and I have the car physics done, but now I need to make the screen scroll with the player. How should I go about this? Would it be better to use one large image, or a series of smaller ones. How would I scroll? Do I keep the player in the middle and move everything else? Or do I make a camera class or something? How do you guys scroll?

Share this post


Link to post
Share on other sites
Captain P    1092
This offset is only used when drawing things, and no, it's not inefficient at all - the image drawing itself takes a lot more time than two simple additions anyway. It surely is easier to work with than actually moving all game objects whenever your player moves, because that's mixing up the situation with it's visual representation. For example, how are you going to tell that an object hasn't moved? If objects are moved because they need to be drawn somewhere else, things like that become difficult to tell.

You should offset everything, including the player (except for overlay images, such as a heads-up display). To keep the camera centered on the player, just move it whenever the player moves. Whenever you want the camera to focus on something else, you set it's position to that objects position. Every object stays at the same location, they're just rendered somewhere else.

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