from pygame import * from pygame.sprite import * from random import * # Your sprite classes go here class Beach_Ball(Sprite): def __init__(self, screen): Sprite.__init__(self) self.image = image.load("beach_ball.png").convert() self.rect = self.image.get_rect() self.rect.center = screen.get_rect().center def move_up(self): self.rect.center = (self.rect.center[0], self.rect.center[1] - 10) # The game init() # Initialize screen screen = display.set_mode((640, 480)) display.set_caption('Window name!') # Your game sprite initializations go here square = Surface((50,50)) square.fill(Color("purple")) ball = Beach_Ball(screen) sprites = RenderPlain(ball) #mouse.set_visible(False) while True: e = event.poll() if e.type == QUIT: quit() break elif e.type == MOUSEBUTTONDOWN: if ball.rect.collidepoint(mouse.get_pos()): ball.move_up() screen.fill(Color("white")) randx = randint(0, 640) randy = randint(0, 480) screen.blit(square, (randx, randy)) sprites.update() sprites.draw(screen) display.update()