Hi
You probably could use the pygame.sprite.LayeredDirty and use the y axis
as for the layer (smaller y means behind).
If I remember correctly, the dirty flag should handle the rest (it
redraws the parts that are affected by a dirty sprite).
Make sure you use convert or convert_alpha and maybe the RLEACCEL flag
for blitting (this might give you a performance boost).
~DR0ID
On 16.06.2013 13:44, Radomir Dopieralski wrote:
Let me clarify.
Looking from the side, you have something like this:
a..
Ab.
.Bc
..C
where small letter is the top part of a tile, and capital letter is a
bottom part and horizontal axis is time. Now, what you are doing right
now is:
1. blit the bottom tile:
a..a
Ab.A
.Bc.
..C.
2. blit your current tile:
a..a.
Ab.Ab
.Bc.B
..C..
3. blit the top tile:
a..a..
Ab.Ab.
.Bc.Bc
..C..C
As you pointed out, this damages the tiles that are further down or up
in that column. Now, what you need to do is to modify your top and
bottom tile blitting like so:
1. blit just the bottom half of the bottom tile:
a...
Ab.A
.Bc.
..C.
2. blit your current tile whole:
a....
Ab.Ab
.Bc.B
..C..
3. blit the top part of your top tile:
a.....
Ab.Ab.
.Bc.Bc
..C...
This way you don't damage the other neighboring tiles.
I hope that helps.
On Sun, Jun 16, 2013 at 1:36 PM, Andrew Barlow
<andrew.bar...@gmail.com <mailto:andrew.bar...@gmail.com>> wrote:
Hello,
Thank-you for your quick response.
Unfortunately, because a unit is "taller" than a tile, their head
pokes over the top of the tile above (the overlap causing the
depth) - which is where the feet of the unit in the tile above are.
So, erasing the first tile, means you lose the feet of the tile
above. If you run the code provided, you'll see what I mean.
The code simply draws a wall on the grid. Then at random
intervals, it draws a unit in either the tile above the wall, or
the tile just above that. If a unit is already in the randomly
chosen tile, it attempts to remove it. The "remaning" head problem
can be seen clearly from just running this for a few seconds.
Any code change advice is hugely welcomed here!
On 16 June 2013 12:30, Radomir Dopieralski <pyg...@sheep.art.pl
<mailto:pyg...@sheep.art.pl>> wrote:
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.bar...@gmail.com <mailto:andrew.bar...@gmail.com>> 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
--
Radomir Dopieralski, http://sheep.art.pl