How to make scrolling camera in my racing game

Started by
3 comments, last by Captain P 16 years, 1 month ago
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?
Advertisement
If it's in 2D, just make an offset for the whole world.

Its hard to explain so before anybody explains, visit Google.

Type in something like 2D Scrolling
I think I understand, you want me to offset every object in the game that;s not the player? Won't that be inefficient?
Ok, well I have implemented an offset system but I'm not sure how effective that will be when I add many game objects. I guess I'll just have to trust you. :)
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.
Create-ivity - a game development blog Mouseover for more information.

This topic is closed to new replies.

Advertisement