python显示图片不连续_在线等待 求帮忙如何实现图片的连续移动!下面代码为什么不行...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

import pygame

import syspygame.init()size = width,height = 800,600

bg_color = (230,230,230)screen = pygame.display.set_mode(size)

pygame.display.set_caption("haha")images = pygame.image.load(r"D:\alien_invasion\images\ship.bmp")

image_rect = images.get_rect()

screen_image = screen.get_rect()image_rect.centerx = screen_image.centerx

image_rect.centery = screen_image.centery

while True:

for event in pygame.event.get():

if event.type == pygame.QUIT:

sys.exit()

elif event.type == pygame.KEYDOWN:

if event.key == pygame.K_UP and image_rect.top > screen_image.top:

image_rect.centery -= 10

screen.fill(bg_color)

screen.blit(images,image_rect)

pygame.display.flip()

elif event.type == pygame.KEYUP:

screen.fill(bg_color)

screen.blit(images,image_rect)

pygame.display.flip()

elif event.key == pygame.K_DOWN and image_rect.bottom < screen_image.bottom:

image_rect.centery += 10

elif event.key == pygame.K_RIGHT and image_rect.right < screen_image.right:

image_rect.centerx += 10

elif event.key == pygame.K_LEFT and image_rect.left > screen_image.left:

image_rect.centerx -= 10

screen.fill(bg_color)

screen.blit(images,image_rect)

pygame.display.flip()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值