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

Re: [pygame]



> I am trying to start coding to make games. How do you get the
> background pic to scroll? please give example. Also how would I
> incorporate 360 degree movement of a BMP on the background.
> The srolling is left, right, up, or down

hello paula. scrolling is a pretty intensive ordeal without
hardware acceleration. i haven't tried it yet myself, but
i've read through several long threads on the SDL mailing list.

the biggest problem is that SDL has a small design problem
that does a double-copy of the entire screen when doing stuff
like scrolling.

at some point i do want to try building my own scrolling example,
just so i know where everything sits exactly. the "good" news
is here the python code will perform nearly identical to C code
using SDL. the bottleneck is memory bandwidth.

nonetheless, here's a few tips that might help get things going.


* first, stick with the absolute lowest resolution possible. the
one thing that will effect speed most is the resolution.

* also, stick with the lowest color depth you can. go with 8-bit
if at all possible, if not 16bit would be the maximum, but not
recommended.

* the best way to scroll is by blitting the display Surface onto
itself. therefore, to move the screen 10 pixels to the right,
"screen.blit(screen, (10, 0))". there may be some limitations as
to what you can do to blit here, but it should work for the most
part. then the only thing to draw is the newly revealed 10 pixels
on the left edge of the screen.

* note, that above scrolling method only works for flat scrolling,
paralax scrolling requires fully redrawing each frame every time.

* no need to bother with update area rectangles for each sprite.
whenever the whole screen is changing just call flip() each frame
and get the whole thing done at once.


on the other hand, once you have hardware acceleration (like you
get with fullscreen directx on windows) the updates become no problem
because the hardware can do all the blitting very fast.


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