Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


pygame camara


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 nanopola   Members   -  Reputation: 102

Like
0Likes
Like

Posted 05 June 2012 - 02:58 PM

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!

Sponsor:

#2 shadowgamesco   Members   -  Reputation: 326

Like
0Likes
Like

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.

#3 coolnamehuh   Members   -  Reputation: 104

Like
0Likes
Like

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS