Skip to content

Commit

Permalink
Merge pull request #2666 from Matiiss/matiiss-remove-deprecated-groups
Browse files Browse the repository at this point in the history
Further deprecation of deprecated sprite groups
  • Loading branch information
Starbuck5 authored Jan 30, 2024
2 parents 099488f + a3d8d73 commit ec5e6f8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 41 deletions.
5 changes: 2 additions & 3 deletions docs/reST/ref/sprite.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ The basic Group class can draw the Sprites it contains to a Surface. The
``Group.draw()`` method requires that each Sprite have a ``Sprite.image``
attribute and a ``Sprite.rect``. The ``Group.clear()`` method requires these
same attributes, and can be used to erase all the Sprites with background.
There are also more advanced Groups: ``pygame.sprite.RenderUpdates()`` and
``pygame.sprite.OrderedUpdates()``.
There are also more advanced Groups: ``pygame.sprite.RenderUpdates()``.

Lastly, this module contains several collision functions. These help find
sprites inside multiple groups that have intersecting bounding rectangles. To
Expand Down Expand Up @@ -366,7 +365,7 @@ Sprites are not thread safe. So lock them yourself if using threads.
.. class:: LayeredUpdates

| :sl:`LayeredUpdates is a sprite group that handles layers and draws like OrderedUpdates.`
| :sl:`LayeredUpdates is a sprite group that handles layers and draws like RenderUpdates.`
| :sg:`LayeredUpdates(*sprites, **kwargs) -> LayeredUpdates`
This group is fully compatible with :class:`pygame.sprite.Sprite`.
Expand Down
25 changes: 5 additions & 20 deletions docs/reST/tutorials/en/intro-to-sprites.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,24 +203,9 @@ sprite module.
it "forgets" about any previous sprites it had. Therefore it always contains
only one or zero sprites.

:class:`RenderPlain <pygame.sprite.RenderPlain>`

This is a standard group derived from ``Group``. It has a draw() method
that draws all the sprites it contains to the screen (or any ``Surface``). For
this to work, it requires all sprites it contains to have a "image" and "rect"
attributes. It uses these to know what to blit, and where to blit it.

:class:`RenderClear <pygame.sprite.RenderClear>`

This is derived from the ``RenderPlain`` group, and adds a method named
``clear()``. This will erase the previous position of all drawn sprites. It
uses a background image to fill in the areas where the sprite were. It is smart
enough to handle deleted sprites and properly clear them from the screen when
the ``clear()`` method is called.

:class:`RenderUpdates <pygame.sprite.RenderUpdates>`

This group is inherited from ``RenderClear``, but changes the
This group is inherited from ``Group``, but changes the
``draw()`` method to also return a list of pygame ``Rects``,
which represent all the areas on screen that have been changed.
Generally you don't need to use this group, but it is included for
Expand All @@ -242,8 +227,8 @@ The Rendering Groups
--------------------

From above we can see there are three different rendering groups. We could
probably just get away with the ``RenderPlain`` one. For a scrolling or stationary
type game, you should probably go with the ``RenderPlain`` group here to manage
probably just get away with the ``Group`` one. For a scrolling or stationary
type game, you should probably go with the ``Group`` group here to manage
your rendering.

Also note that there's nothing stopping you from mixing and matching these
Expand Down Expand Up @@ -342,11 +327,11 @@ Looking at the current ``Sprite`` groups should be enough example on how to
create your own.

For example, here is the source code for a rendering ``Group`` that calls a
``render()`` method for each sprite, instead of just blitting an "image"
``draw()`` method for each sprite, instead of just blitting an "image"
variable from it. Since we want it to also handle updated areas, we will start
with a copy of the original ``RenderUpdates`` group, here is the code::

class RenderUpdatesDraw(RenderClear):
class RenderUpdatesDraw(Group):
"""call sprite.draw(screen) to render sprites"""
def draw(self, surface):
dirty = self.lostsprites
Expand Down
4 changes: 2 additions & 2 deletions docs/reST/tutorials/en/tom-games6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ like this::
ball = Ball((0,0),(0.47,speed))

# Initialise sprites
playersprites = pygame.sprite.RenderPlain((player1, player2))
ballsprite = pygame.sprite.RenderPlain(ball)
playersprites = pygame.sprite.Group((player1, player2))
ballsprite = pygame.sprite.Group(ball)

# Blit everything to the screen
screen.blit(background, (0, 0))
Expand Down
9 changes: 2 additions & 7 deletions docs/reST/tutorials/es/ChimpanceLineaporLinea.rst
Original file line number Diff line number Diff line change
Expand Up @@ -448,20 +448,15 @@ En este caso crearemos todos los objetos que el juego va a necesitar.
punch_sound = load_sound("punch.wav")
chimp = Chimp()
fist = Fist()
allsprites = pg.sprite.RenderPlain((chimp, fist))
allsprites = pg.sprite.Group((chimp, fist))
clock = pg.time.Clock()

Primero cargamos dos efectos de sonido usando la función `load_sound`, que se
encuentra definida en código arriba. Luego, creamos una instancia para cada
uno de los sprites de la clase. Por último, creamos el sprite
:class:`Group <pygame.sprite.Group>` que va a contener todos nuestros sprites.

En realidad, nosotros usamos un grupo especial de sprites llamado
:class:`RenderPlain<pygame.sprite.RenderPlain>`.
Este grupo de sprites puede dibujar en la pantalla todos los sprites que contiene.
Es llamado `RenderPlain` porque en realidad hay grupos Render más avanzados, pero
para nuestro juego nosotros solo necesitamos un dibujo simple. Nosotros creamos
el grupo llamado "allsprites" al pasar una lista con todos los sprites que deberían
Nosotros creamos el grupo llamado "allsprites" al pasar una lista con todos los sprites que deberían
pertenecer al grupo. Exise la posibilidad, si más adelante quisieramos, de agregar
o sacar sprites de este grupo, pero para este juego no sería necesario.

Expand Down
2 changes: 1 addition & 1 deletion src_c/doc/sprite_doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define DOC_SPRITE_GROUP_EMPTY "empty() -> None\nremove all Sprites"
#define DOC_SPRITE_RENDERUPDATES "RenderUpdates(*sprites) -> RenderUpdates\nGroup sub-class that tracks dirty updates."
#define DOC_SPRITE_RENDERUPDATES_DRAW "draw(surface) -> Rect_list\nblit the Sprite images and track changed areas"
#define DOC_SPRITE_LAYEREDUPDATES "LayeredUpdates(*sprites, **kwargs) -> LayeredUpdates\nLayeredUpdates is a sprite group that handles layers and draws like OrderedUpdates."
#define DOC_SPRITE_LAYEREDUPDATES "LayeredUpdates(*sprites, **kwargs) -> LayeredUpdates\nLayeredUpdates is a sprite group that handles layers and draws like RenderUpdates."
#define DOC_SPRITE_LAYEREDUPDATES_ADD "add(*sprites, **kwargs) -> None\nadd a sprite or sequence of sprites to a group"
#define DOC_SPRITE_LAYEREDUPDATES_SPRITES "sprites() -> sprites\nreturns a ordered list of sprites (first back, last top)."
#define DOC_SPRITE_LAYEREDUPDATES_DRAW "draw(surface) -> Rect_list\ndraw all sprites in the right order onto the passed surface."
Expand Down
11 changes: 5 additions & 6 deletions src_py/sprite.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
Group.draw() method requires that each Sprite have a Surface.image attribute
and a Surface.rect. The Group.clear() method requires these same attributes
and can be used to erase all the Sprites with background. There are also
more advanced Groups: pygame.sprite.RenderUpdates() and
pygame.sprite.OrderedUpdates().
more advanced Groups: pygame.sprite.RenderUpdates().
Lastly, this module contains several collision functions. These help find
sprites inside multiple groups that have intersecting bounding rectangles.
Expand Down Expand Up @@ -659,7 +658,7 @@ class RenderPlain(Group):
def __init__(self, *sprites):
super().__init__(*sprites)
warn(
"This class will be removed in version 2.4.0",
"This class is deprecated and will be removed in a future version.",
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -669,7 +668,7 @@ class RenderClear(Group):
def __init__(self, *sprites):
super().__init__(*sprites)
warn(
"This class will be removed in version 2.4.0",
"This class is deprecated and will be removed in a future version.",
DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -711,14 +710,14 @@ def __init__(self, *sprites):
warn(
"OrderedUpdates is now just an alias to RenderUpdates, order of "
"sprites is now maintained in all sprite Group classes. This "
"class will be removed in version 2.4.0",
"class is deprecated and will be removed in a future version.",
DeprecationWarning,
stacklevel=2,
)


class LayeredUpdates(AbstractGroup):
"""LayeredUpdates Group handles layers, which are drawn like OrderedUpdates
"""LayeredUpdates Group handles layers, which are drawn like RenderUpdates
pygame.sprite.LayeredUpdates(*sprites, **kwargs): return LayeredUpdates
Expand Down
2 changes: 0 additions & 2 deletions test/sprite_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,6 @@ class SpriteTypeTest(SpriteBase, unittest.TestCase):
sprite.Group,
sprite.LayeredUpdates,
sprite.RenderUpdates,
sprite.OrderedUpdates,
]


Expand All @@ -1351,7 +1350,6 @@ class DirtySpriteTypeTest(SpriteBase, unittest.TestCase):
sprite.Group,
sprite.LayeredUpdates,
sprite.RenderUpdates,
sprite.OrderedUpdates,
sprite.LayeredDirty,
]

Expand Down

0 comments on commit ec5e6f8

Please sign in to comment.