Package: ucc-sprite
UCC Sprite ClassThis module provides theSpriteclass.  It is a convenience class that implements many desireable features for Pygame sprites.Install the modulepip3 install ucc-spriteGetting Startedfrom ucc_sprite import Sprite
...
image = pygame.image.load("image.png")
my_sprite = Sprite(image)You can use themy_spriteobject as a Pygame sprite.Table of Contentsucc_spriteSprite__init__imagerectsizewidthheightpositiontopleftbottomlefttoprightbottomrightmidleftmidrightmidtopmidbottomcenterxyleftrightcenterxtopbottomcenterymove_forwardmove_backwarddirectionturn_leftturn_rightrotatesspeedlayercontains_pointmask_contains_pointupdatedrawucc_spriteSprite ObjectsclassSprite(pygame.sprite.DirtySprite)A Sprite represents an image that moves around the screen in a game.Sprite objects store the following information necessary for drawing these
images on the screen:The position of the sprite on the screen using coordinatesThe direction that the sprite is pointing using an angle measured
counterclockwise from the positive x-axis.Attributes and methods are provided for the following:Moving and turning the spriteAnimating the sprite__init__def__init__(image,position=(0,0),direction=0,speed=0,rotates=True)Create a Sprite object with the provided file as its imageimage@propertydefimage()The Surface that the sprite represents.  This Surface is
used when blitting the sprite.rect@propertydefrect()The Rect containing the size and position of the sprite.
This Rect is used when blitting the sprite.This property is readonly.size@propertydefsize()The size (width, height) of the sprite's image.This property is readonly.width@propertydefwidth()The width of the sprite's image.This property is readonly.height@propertydefheight()The height of the sprite's image.This property is readonly.position@propertydefposition()The current the position of the sprite on the screen.topleft@propertydeftopleft()The coordinates of the top left corner of the sprite.bottomleft@propertydefbottomleft()The coordinates of the bottom left corner of the sprite.topright@propertydeftopright()The coordinates of the top right corner of the sprite.bottomright@propertydefbottomright()The coordinates of the bottom right corner of the sprite.midleft@propertydefmidleft()The coordinates of the middle of the left edge of the sprite.midright@propertydefmidright()The coordinates of the middle of the right edge of the sprite.midtop@propertydefmidtop()The coordinates of the middle of the top edge of the sprite.midbottom@propertydefmidbottom()The coordinates of the middle of the bottom edge of the sprite.center@propertydefcenter()The coordinates of the center of the sprite.x@propertydefx()The x-coordinate of the sprite on the screen.y@propertydefy()The y-coordinate of the sprite on the screen.left@propertydefleft()The x-coordinate of the left side of the sprite.right@propertydefright()The x-coordinate of the right side of the sprite.centerx@propertydefcenterx()The x-coordinate of the center of the sprite.top@propertydeftop()The y-coordinate of the top of the sprite.bottom@propertydefbottom()The y-coordinate of the bottom of the sprite.centery@propertydefcentery()The y-coordinate of the center of the sprite.move_forwarddefmove_forward(distance)Move the sprite by the givendistancein the direction it is
currently pointing.move_backwarddefmove_backward(distance)Move the sprite by the givendistancein the opposite of the
direction it is currently pointing.direction@propertydefdirection()The current direction that the sprite is pointing.The direction is an angle (in degrees) counterclockwise from the
positive x-axis.  Here are some important directions:0 degrees is directly to the right90 degrees is directly up180 degrees is directly to the left270 degrees is directly downturn_leftdefturn_left(angle)Turn the sprite left (counterclockwise) by the givenangle.turn_rightdefturn_right(angle)Turn the sprite right (clockwise) by the givenangle.rotates@propertydefrotates()Whether or not the image rotates when the sprite changes direction.speed@propertydefspeed()The distance that the sprite moves forward by on each update.layer@propertydeflayer()The layer number to draw the sprite on.  Higher layers are drawn on top.contains_pointdefcontains_point(x,y=None)Determine whether or not a point is contained within this sprite's
rectangle.mask_contains_pointdefmask_contains_point(x,y=None)Determine whether or not a point is contained within this sprite's
mask.updatedefupdate()Update the sprite in preparation to draw the next frame.This method should generally not be called explicitly, but will be called
by the event loop if the sprite is on the active screen.drawdefdraw(surface)Draw the sprite on the given Surface object.