Python, PyGame and Raspberry Pi Game Development by Sloan Kelly

Python, PyGame and Raspberry Pi Game Development by Sloan Kelly

Author:Sloan Kelly
Language: eng
Format: epub, mobi, pdf
Publisher: Apress, Berkeley, CA


Our stub method for testing whether the ball has hit the bat:

def draw(self, gameTime, surface):

surface.blit(self.img, (self.x, self.y))

This isn’t a stub because we know exactly how this will be achieved. We use the main surface to blit our image to the screen at the correct x- and y- coordinates. To access the object’s member field, we have to use the ‘self’ keyword. Attributes and methods belonging to the current object are accessed through self followed by a dot (‘.’) followed by the attribute or method. When calling the method, you don’t have to pass in ‘self’, Python will handle that for you. Self is only placed in the parameter list at the method declaration.

if __name__ == '__main__':



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.