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

Re: [pygame] Scrolling Background



For What It's Worth... (as it really needs a rewrite stime soon), Pyplace has a scrolling background which
is tiled isometrically.


Peter

Fredrik wrote:

> Den 22 Maj 2002 skrev Pete Shinners:
>
> > Neil Broers wrote:
> > > 1 > Possible with Pygame
> > > 2 > If it is, how to actually get the background to scroll
> > > 3 > If Pygame would achieve a high enough FPS rate
> >
> > i'm guessing it won't be too long before something starts to arrive.
>
> Well here comes something :-)
>
> > a couple things to keep in mind. for a lot of games, 30fps is fine.
> > creating your game to run in software ends up being a lot more flexible and
> > forgiving. if you want the speed of hardware, go for it. but i recommend
> > using an all-or-nothing approach. supporting both hardware and software
> > modes requires almost building 2 games. things you do to make software mode
> > quicker end up really slowing down the hardware stuff.
> >
> Hi, as I have some experience programming scrolling in pygame I found your answer somewhat puzzling. As I've always been able to use both software and hardware in surfaces with the same code without any problem. As I'm not an pygame/SDL guru I'm wondering if you are referring to some kind of hardware scroll?
> Also IMO even if the game is quite playable in 30fps it's when you reach >50 that an action scrolling game gets the right feeling.
>
> As I have not used solid backgrounds but instead used tiled based approach(ability to use really big maps) the biggest problem was getting the routines that calculates the tiles to draw and where to draw them fast enough, 24x24pixel in 640x480 just doing it the C way using for loops you end up with 540 calculation loops every frame. This has a hefty speed penalty in python and rendered my game useless on older hardware. I solved this by recalculating all source and dest rects in a Numeric array and slicing them out using Numeric array 2d slicing.
> This way the python 540 loops could be replaced with this:
>         self.tiles2render = filter(None,reshape(self.rects[map_y:map_max_y,map_x:map_max_x],(1,-1))[0])
> Also this is only recalculated once for every new tile you enter.
>
> I've planned on cleaning up the scroll code and release it on the repository but until I get the time you could check the out scroll code in the game I'm working on (most of it is in the tiledLayer class) keep in mind that it's in development and not cleaned up.
> Get it at:
> http://www.algonet.se/~tomten/turb/turb72.zip
>
> I've only got the hw accel to work on windows, see the readme file for instructions.
>
> Cheers
> Fredrik C.
>
> ____________________________________
> pygame mailing list
> pygame-users@seul.org
> http://pygame.seul.org

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org