[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Tile Based games




--- Leonardo Santagada <retype@terra.com.br> wrote:
> I've been trying to make a tile based game for
> pygame. I'm having problens
> in how to buffer the tiles while scrolling the map.
> I just don't know how to
> do it. Now I have given up and i'm bliting the tiles
> directly to the screen
> but it doesn't seen like a good idea. Also this way
> I can't make smooth
> scrolling (in 16x16 tiles make then scroll by 2 or 4
> pixel at a time). I
> have searched a lot for this but in every tile
> tutorial they only talk about
> how to organize the map structure, not how to draw
> the tiles. Could someone
> give me a hand at this?

This is how I do it.  Create an oversized buffer
(surface) that is one or two tiles larger than what
will fit on your resolution.  Paint all your tiles -
including however many layers you have - onto this
buffer.  Each update simply paint and scroll this
buffer around.  When you have scrolled an amount equal
to it's oversize, say 16 pixels for a one tile
oversized buffer, paint your new tiles onto this
buffer and recenter it on the screen.  Now it will
give the illusion of seemless scrolling.  This way you
are only rendering the map when absolutely necassary. 
I have a little demo of this technique with 3 layers
if you want to see it.  Taking down your resolution
will also help alot, a lot of arcade games only use
640x480 resolution and limit the sprite palette to 16
colors (CvS2, MvC2...)

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org