Blit coordinates for sprite.Group.draw() limited to 8 bits

Issue #57 resolved
René Dudfield created an issue

== , 2010-12-01 02:49:44 -0800

{{{ So a sprite with rect.topleft coordinates (70000, 200) will appear at (70000-28, 200). Becomes a problem in a scrolling game where player figure is immobile and sprites coordinates are updated by 'in-world' player coordinates. (I e a sprite far away from the player at (-70000, 200) appears as a 'ghost' at (70000-28, 200).

My particular fix involves setting sprite.images to an empty instance of Surface if the sprite is offscreen. I would have expected the sprite.Group.draw to be able to handle full span of int type, and Group.draw() of a sprite with an offscreen position to simply do nothing. }}}

Comments (4)

  1. René Dudfield reporter

    This code shows the rect is able to use large numbers - not just 8 bit.

    >>> import pygame
    >>> r = pygame.Rect((888888, 66666666, 70000000, 200))
    >>> r.topleft
    (888888, 66666666)
    >>> r.topleft = (70000, 200)
    >>> r
    <rect(70000, 200, 70000000, 200)>
    >>> r.topleft
    (70000, 200)

    Surfaces are limited to 14bit sizes though.

    >>> pygame.Surface((pow(2,14) -1, 1))
    <Surface(16383x1x32 SW)>

    So you have to translate the coordinates into something that fits the surfaces.

    Closing as resolved, because this is expected behaviour for surfaces. If rects did do that in the past, now they do not.

  2. Log in to comment