小编hen*_*rco的帖子

Pygame:如何正确使用get_rect()

我正在尝试了解其get_rect()工作原理。在这个简单的示例中,我有两个图像,并且想要获取第二个图像的位置并将第一个图像移动到第二个图像。

我在网上查看了各种各样的示例,但无法正常工作。我究竟做错了什么?

import pygame, sys
from pygame.locals import *
import time

pygame.init()
FPS = 10 # frames per second setting
fpsClock = pygame.time.Clock()

# Set up the window
DISPLAYSURF = pygame.display.set_mode((600, 400), 0, 32)
pygame.display.set_caption('Test program for get_rect()')

WHITE = (255, 255, 255)

# Load two images
baseImg = pygame.image.load('image1.jpg')
spaceshipImg = pygame.image.load('image2.jpg')

DISPLAYSURF.fill(WHITE)

# Place one image at the bottom of the screen
DISPLAYSURF.blit(baseImg, (300, 300))
pygame.display.update()

# Place the second image at the top of the …
Run Code Online (Sandbox Code Playgroud)

python pygame

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

pygame ×1

python ×1