>
> Is there some case where blitting a surface on itself might be desired
> or necessary? If not, I'll add a simple check that tests the passed
> surface on equality and let blit() throw an exception, if both are the
> same.
>
> Regards
> Marcus


For scrolling (topdown RPG, in my case), I use a surface just larger than
the screen to hold all my unmoving objects, tiles, trees, chests, etc, and
keep a Rect for where to put that surface onto the screen.  Whenever I move
a tiles worth in any direction (lets say i move 32 pixels to the right), I
need to blit the rect <32, 0, width, height> to <0, 0, width, height> and
add the rightmost-visible tiles to it.  My first idea was to blit the
surface onto itself, but of course that blew up on me.

My fix was to use two surfaces and just blit from one onto the other,
switching between the two every time I need to add another row/column onto
the screen.  It's not really memory inefficient (I only keep one extra
672x512 surface and a pointer in memory), but it definitely wasn't
straightforward, and took me a while longer than I expected to implement it.
Blitting a surface onto itself would have been much simpler.

Reply via email to