I had a look at your code. What's happening is you are only moving map tiles
on the screen jump update that _will appear_ on the new screen. This snippet
of code here:
for x in range(startX, endX + 1):
yPixels = 0
for y in range(startY, endY + 1):
if x == self.playerX and y == self.playerY:
self.player.set_position(xPixels, yPixels)
self.map[x][y].set_position(xPixels, yPixels)
yPixels += 33
xPixels += 33
only loops over tiles that will be appearing in the new screen. But what
about tiles that _were_ there in the previous screen but aren't included in
this startX->endX, startY->endY block?
These old excluded tiles _stay on the screen_ in their old positions and
muck up your display. You will need to move the new tiles into position AND
the old tiles out of position. I got the bogus tiles to disappear in a hacky
way to show this is the problem by firstly, storing the map width and height
in a class variable:
class Map:
....def __init__(self, width=300, height=300):
........self._width = width
........self._height = height
and then before this update block, just moving *every* tile offscreen...
like...
........# lets try moving everything out of the way
........for x in range(self._width):
............for y in range(self._height):
................self.map[x][y].set_position(-100,-100)
........for x in range(startX, endX + 1):
...
And that cleared up the stale tiles that were hanging around.
Note this is not the right way to do this, as tiles are touched twice, and
many times are set to -100,-100 that never need to be. The better solution
is to expand your startX,startY,endX,endY to include the rectangle of the
new screen unioned with the rectangle from the old screen so both new tiles
appear, and old tiles get removed somehow.
Good luck
Crispin
On Thu, Oct 7, 2010 at 9:23 AM, kunwon1 <[email protected]> wrote:
> On Wed, Oct 6, 2010 at 9:00 AM, kunwon1 <[email protected]> wrote:
> > Hello, I am relatively new to pyglet, and I am trying to make a fairly
>
>
> I realize two things: I forgot to include image files for the sprites
> and my code is getting mangled.
>
> I am attaching my code and graphics as a tarball, for easier testing
> by potential helpers.
>
> Also, I have tested this code on two platforms now, Win7 64bit with
> nvidia and Debian 5.0 32 bit with intel, the problem is the same on
> both. I have included the output of pyglet.info for both platforms in
> the tarball.
>
> --
> You received this message because you are subscribed to the Google Groups
> "pyglet-users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<pyglet-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/pyglet-users?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en.