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

[pygame] Complicated Blitting Order Issue



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