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!
2 replies to this topic
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.
Members - Reputation: 113
Posted 08 June 2012 - 09:20 PM
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.