pygame中如何把图片放在界面左下角
这是源代码,想请问一下各位大佬,我想把new_man这张图片放到界面的左下角,我该如何设定,尝试过更改site[x,y]的初值,但是任何值都会让new_man不显示再界面范围,希望各位大佬解答一下PS:backdrop的像素尺寸是958*605
import pygameimport sys
pygame.init()
stauta = 1
flag = pygame.RESIZABLE # 窗口可以调整大小
pygame.display.set_caption("My First Pygame Game") # 设置标题
size = X, Y = 958, 605
windows = pygame.display.set_mode(size) # 窗口大小
icon = pygame.image.load("new.jpg")
pygame.display.set_icon(icon) # 设置程序的图标
backdrop = pygame.image.load("backdrop.jpg").convert()
windows.blit(backdrop, (0, 0))
pygame.display.update() # 设置背景图片
#t = pygame.time.get_ticks()
#t1 = pygame.time.wait(3000) # 暂停游戏3秒
man = pygame.image.load("freeman.jpg")
new_man = pygame.transform.scale(man, (100, 100)) # 设置人物的像素大小
position = new_man.get_rect()
while True:
site = [0, 0]
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit() # 程序退出
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
#if stauta:
site[1] -= 20
#stauta = 0
print(site[1])
if event.key == pygame.K_DOWN:
#if not stauta :
site[1] += 20
# stauta = 1
print(site[1])
if event.key == pygame.K_LEFT:
site[0] -= 20
print(site[0])
if event.key == pygame.K_RIGHT:
site[0] += 20
print(site[0])
elif event.key == pygame.K_ESCAPE:
sys.exit()
position = position.move(site)
windows.blit(new_man, position)
pygame.display.update()
windows.blit(backdrop, (0, 0))
以上是 pygame中如何把图片放在界面左下角 的全部内容, 来源链接: utcz.com/p/938422.html