|
楼主 |
发表于 2022-9-11 15:40:43
|
显示全部楼层
import pygame
import sys
pygame.init()
screen = pygame.display.set_mode((800,600))
bg=pygame.image.load('image\星海背景.png')
bg=pygame.image.load('image\炮台_红色珠子.png')
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.type == pygame.KEYDOWN:
if event.key == pygame.K_DOWN:
site[1] +=8
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEL:
site[0] -=8
if event.type == pygame.KEYDOWN:
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(ball,site)
screen.blit(ball,(site2[0]-29,site2[1]-29))
pygame.display.update()
|
|