Set a 2d camera's position so that a building is under the players feet

Posted by Potato on Game Development See other posts from Game Development or by Potato
Published on 2013-03-25T19:53:47Z Indexed on 2013/06/27 4:32 UTC
Read the original article Hit count: 239

Filed under:
|
|

My issue is this: i am making a scrolling game in XNA, and the camera updates based on the players velocity, but the player never actually moves, he is always in the center of the screen. When he hits the top of the building though i want him to always be on top and sink through the texture in a way like this:

enter image description here

what i am doing to make this happen is i am just setting his velocity to 0, so its not moving, but the more velocity he hits a building with the more he sinks through it.

I also tried setting the buildings position to the plays Bounding Box's bottom, and this achieved the look i wanted but this also resulted in the other buildings rising in the air, because the velocity was still moving (even if i set it to 0).

enter image description here

if it was not a scrolling game, this would be not a problem, because you just set the players position to the top of the building, but because the player never actually moves, i actually need to move the camera to the point where the building is under the players feet without the other buildings rising. (Take note this is note a real camera, it is just a class that moves the objects in the world based on the players velocity). All questions are welcome.

© Game Development or respective owner

Related posts about XNA

Related posts about c#