Camera for 2-d side-scroller

Started by
9 comments, last by My_Mind_Is_Going 16 years, 10 months ago
I've been reading "Beginning Game Programming" by Michael Morrison. He does not touch upon how to create a side-scroller where the camera flows with the character in the center. He only describes how to have a character reach the end of the screen and then "shift" to the next scene. Much like the way Zelda 3 (SNES) plays. Can anyone refer me to a resource where I can find out how to make the camera behave similar to a game like Mega Man for instance? (Where there is no shifting, just a smooth flow throughout the level) Thanks
Advertisement
what language are you using?
The general idea is that you store the position of the camera. You'd set that position to be above the player every frame. And you'd 'shift' all the drawing over and up by that amount.

If you need more help, maybe you should ask a more specific question.

.

.

Quote:Original post by Kada2k6


Hey maybe you're aware and don't care of have decided for other reasons to do things that way, but that code seems like it has a lot of unnecessary multiplications and divisions that could be replaced by shifts and stored values... just a thought.
just a generalization, the code is for you to figure out, in my oppinion.

by try thinking of it this way, was you see on the screen is determined by the camera, and the cameras position is determined by the player.

// real basic idea of the cameraclass CCamera{private:     float m_map_x;     float m_map_y;     float m_width; // in tiles     float m_hieght; // in tilespublic:    // various functions for retrieving and changing data};


now the game would use the cameras data to determined what parts of the map need to be displayed. but its up to you to figure out how you want the game or the players position to effect the cameras' position.
-----------------------------------------------The ZoloProject
Thanks Speedie and Kada, that's what I was looking for.

I'm guessing the length of a level would depend on how wide the bitmap is or something?

**To the above poster... I'm coding this in C++
Quote:Original post by Programmierer
Thanks Speedie and Kada, that's what I was looking for.

I'm guessing the length of a level would depend on how wide the bitmap is or something?

**To the above poster... I'm coding this in C++


are you using one bitmap(or image) for the entire bacground of your map? You should look into using tile maps. they're the most basic and most used way of storing and displaying map data.

-----------------------------------------------The ZoloProject

.

This topic is closed to new replies.

Advertisement