制作一个跳跃的小球游戏
import pygame import sys pygame.init() screen = pygame.display.set_mode((640,480)) ball = pygame.image.load('small ball.jpg') ballrect = ball.get_rect() print(ballrect) speed = [5,5] clock = pygame.time.Clock() while True: clock.tick(60) for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() ballrect = ballrect.move(speed) if ballrect.left < 0 or ballrect.right > 640: speed[0] = -speed[0] if ballrect.top < 0 or ballrect.bottom > 480: speed[1] = -speed[1] screen.fill((0,0,0)) screen.blit(ball,ballrect) pygame.display.flip() pygame.quit()
标签:基本,ball,ballrect,screen,Pygame,应用,speed,event,pygame From: https://www.cnblogs.com/xiaoyouya/p/16944341.html