Skip to main content
GameDev.net gamedev.net
🔒 Locked

Scrolling the camera with a side-scrolling video game

Started by darkawakenings Jan 28, 2005 at 2:30 PM 1 replies 1.5k views
Original Post
darkawakenings
darkawakenings
Right now I am scrolling the camera so that the character always stays perfectly in the center, (horizontally). It looks rather unreal, and I was wondering how I should go about making this look more realistic. I seem to remember the camera rather sliding around in the old Mario type games, but i can't seem to emulate that effect very well, and I don't know how I would go about doing it. Math maybe? ;)
gr0undz3r0
gr0undz3r0
My suggestion would be to only scroll the camera when the character gets a pre-determined distance to the sides of the screen then scroll the camera with the character.

So you have your character, he starts running to the right say he's 100 pixels from the right side of the screen, start scrolling the camera. He does a quick turn around and runs at the left side of the screen, wait until the character is 100 pixels(or whatever you chose) from the left side of the screen and start scrolling it that way. That gives the character time to react to any enemies that may appear.
jflanglois
jflanglois
Or you could make the camera speed vary based on the position of the character from the center of the screen. So if he's 1 logical unit away from the center, the camera goes slowly, but if he's 10 away, it goes fast. You might do something like if he's 3/8ths from the right of the screen, make the camera as fast as the character.

[edit] To give the player visibility, you might change that based on which direction the character is facing. So if he is facing right, the "center" of the screen is 1/4th from the left. I hope I'm not being too incomprehensible...


HTH

Regards,
jflanglois

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.