【发布时间】:2020-10-29 13:48:45
【问题描述】:
我有这个代码,但我想用其他 4 张图片来做这个?
import pygame
from pygame.locals import *
pygame.display.init()
screen = pygame.display.set_mode((1143,677 ))
img = pygame.image.load(r"C:\Users\ga-sa\Downloads\As.png")
img1 = pygame.image.load(r"C:\Users\ga-sa\Downloads\03.png")
imgPos = img.get_rect(topleft = (20, 20))
imgPos1 = img1.get_rect(topleft = (60, 20))
current_image = None
LeftButton = 0
while 1:
for e in pygame.event.get():
if e.type == QUIT:
pygame.quit()
exit(0)
if e.type == pygame.MOUSEBUTTONDOWN:
if imgPos.collidepoint(e.pos):
current_image = 0
elif imgPos1.collidepoint(e.pos):
current_image = 1
else:
current_image = None
if e.type == MOUSEMOTION:
if e.buttons[LeftButton]:
rel = e.rel
if current_image == 0:
imgPos.x += rel[0]
imgPos.y += rel[1]
elif current_image == 1:
imgPos1.x += rel[0]
imgPos1.y += rel[1]
screen.fill(0)
screen.blit(img, imgPos)
screen.blit (img1, imgPos1)
pygame.display.flip()
pygame.time.delay(30)
所以这是我的代码,我想放 4 张图片,而不是只放两张图片,我想放更多图片,但它是布尔值,所以是 0 或 1
【问题讨论】:
标签: python pygame pygame-surface