• Advertisement
Sign in to follow this  

pygame camara

This topic is 2053 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, about 3 months ago I started learning pygame, and I have made great progress since then, but I'm doing a Mario Bros copy, and I need help with the camera. I'm pretty much sure everyone has played Mario more than once, so I ask, anyone has any idea of how to get the background to scroll when the player moves far away from the center or default position.


Any ideas or suggestions are welcomed, Thanks!

Share this post


Link to post
Share on other sites
Advertisement
A simple way to do it would be to create a pygame.rect and name it camera. Set it's x and y to 0, 0, and the width and height to the size of the area you want to scroll. Then when the player moves left/right, also move the camera's x axis left/right. Then when you are rendering everything on the screen, eg. a tiled background, render each tile at its current position minus the camera's position. Sorry I kind of suck at explaining this, but scrolling is actually really easy, just don't over think it.

Share this post


Link to post
Share on other sites
I would create a scrolling background, and make my character semi static (i.e jumping and twisting, bust always center). Load an image as background that is very long, and change the location of the background when moving left, and right.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement