嗨,我正在制作一个侧面滚动的背景以放入我的游戏中,这是我目前得到的:
import pygame
import sys
import pygame.sprite as sprite
theClock = pygame.time.Clock()
background = pygame.image.load('space.jpg')
background_size = background.get_size()
background_rect = background.get_rect()
screen = pygame.display.set_mode(background_size)
w,h = background_size
x = 0
y = 0
x1 = 0
y1 = -h
running = True
while running:
screen.blit(background,background_rect)
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
y1 += 5
y += 5
screen.blit(background,(y,x))
screen.blit(background,(y1,1))
if y > h:
y = -h
if y1 > h:
y1 = -h
pygame.display.update()
theClock.tick(25)
pygame.quit()
目前我得到一个闪烁的屏幕,运动图像向右移动,原始图像在其上闪烁,任何帮助将不胜感激 - 因为它适用于我的 a-level 计算课程 a 并试图实现一个功能 liket他进入游戏很久了....再次感谢您的帮助