[Python] 纯文本查看 复制代码 import pygame
import sys
pygame.init()
screen = pygame.display.set_mode((800,600))
bg=pygame.image.load('image\星海背景.png')
tg=pygame.image.load('image\炮台_红色珠子.png')
og=pygame.image.load('image\炮台_蓝色珠子.png')
qg=pygame.image.load('image\红色能量球.png')
ball=pygame.image.load('image\蓝色能量球.png')
site = [300,300]
site2 = [500,300]
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:
site[1] -= 8
if event.key == pygame.K_DOWN:
site[1] += 8
if event.key == pygame.K_LEFT:
site[0] -= 8
if event.key == pygame.K_RIGHT:
site[0] += 8
print(site)
if event.type == pygame.MOUSEBUTTONDOWN:
print(event.pos)
site2=list(event.pos)
print(site2)
screen.blit(bg,(0,0))
screen.blit(tg,(0,0))
screen.blit(og,(0,300))
screen.blit(qg,site)
screen.blit(ball,(site2[0]-29,site2[1]-29))
pygame.display.update()
|