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!
pygame camara
Started by nanopola, Jun 05 2012 02:58 PM
2 replies to this topic
Sponsor:
#2 Members - Reputation: 326
Posted 05 June 2012 - 09:32 PM
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.






