[Python] 纯文本查看 复制代码 import pygame
import sys
pygame.init()
screen=pygame.display.set_mode((800,600))
bg=pygame.image.load('image\星海背景.png')
ball1 = pygame.image.load('image\红色能量球.png')
ball2 = pygame.image.load('image\绿色能量球.png')
site1=[0,0]
site2=[0,0]
while True:
for event in pygame.event.get():
if event.type==pygame.QUIT:
pygame.quit()
sys.exit()
if event.type==pygame.KEYDOWN:
if event.key==pygame.K_UP:
site1[1]-=8
if event.key == pygame.K_DOWN:
site1[1] += 8
if event.key==pygame.K_LEFT:
site1[0]-=8
if event.key == pygame.K_RIGHT:
site1[0] += 8
if event.type==pygame.MOUSEBUTTONDOWN:
print(event.pos)
site2=list=(event.pos)
print(site2)
screen.blit(bg, (0, 0))
screen.blit(ball1, site1)
screen.blit(ball2, (site2[0]-29,site2[1]-29))
pygame.display.update()
|