[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Complicated Blitting Order Issue



The trick is no not redraw the neighboring tiles in whole, but just
the parts that overlap with your current tile. Then they won't mess
*their* neighboring tiles.


On Sun, Jun 16, 2013 at 1:19 PM, Andrew Barlow <andrew.barlow@xxxxxxxxx> wrote:
> Hello,
>
> I have a fairly frustrating problem I am trying to solve. It's pretty
> complicated to explain, so I'll do my best.
>
> I am trying to use the depth effect of StarPusher
> (http://inventwithpython.com/blog/2011/06/13/new-game-source-code-star-pusher-sokoban-clone/)
> to make my own game. I'm not using their code exactly, just the method of
> blitting images in a grid, where the images are taller than the grid to
> create depth. However, I wish to use large maps (60x60 tiles) which means
> that iterating over the entire dict of tiles each frame takes a long time to
> blit.
>
> Of course, I could only redraw the map when I need to, but this means that I
> couldn't have units of tiles animated as I'd have to draw the whole map each
> frame of animation (which is SLOW). I'd like to be able to simply pick a
> tile from the dict and call a render method on it, and it only blit that
> tile (or nesc. area). The problems come when trying to render just a single
> tile due to a unit moving onto it (or appearing and disappearing in my
> case).
>
> One solution may just be to blit the entire column if anything in that
> column has changed, but if I have a unit in every column animating, I may as
> well just redraw the entire map each frame, which takes AGES.
>
> At the moment I'm trying:
>
> Draw the originally rendered map with unit onto the tile and the tile below
> Draw the unit onto the tile
> Draw any unit onto the tile below
>
> However, this doesn't work as the first tile's head gets left behind. If I
> then extend the first erase to cover the head, I lose the feet of any unit
> standing in the tile above!
>
> I know all this sounds a bit weird, but its very hard to explain without
> seeing it in action.
>
> The code is fairly big (about 5 files of python, 500 lines max) of
> unfinished code. It can be downloaded from here;
> https://dl.dropboxusercontent.com/u/8301679/BlttingIssue.zip
>
> I hope I've vaguely explained it - maybe its simply not possible trying to
> do what i'm trying to do - but some advise would be hugely welcome!
>
> Cheers,
>
> Andy



-- 
Radomir Dopieralski, http://sheep.art.pl