import sys,pygame
pygame.init()
size=w,h=800,400
speed=[1,1]
color=0,0,0
fps=100
fclock=pygame.time.Clock()
screen =pygame.display.set_mode(size)
pygame.display.set_caption("pygame游戏之旅")
image=pygame.image.load(r"D:\1.0\4.png")
#image = pygame.transform.scale(image, (80, 40))
imagerect=image.get_rect()
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_LEFT:
speed[0]=speed[0]-1 if speed[0]==0 else (abs(speed[0])-1)*int(speed[0]/abs(speed[0]))
elif event.key==pygame.K_RIGHT:
speed[0] = speed[0]+1 if speed[0] == 0 else (abs(speed[0]) - 1) * int(speed[0] / abs(speed[0]))
elif event.key == pygame.K_DOWN:
speed[1] = spe
文章来源地址https://www.toymoban.com/news/detail-409408.html
文章来源:https://www.toymoban.com/news/detail-409408.html
到了这里,关于Python游戏开发入门课程(pygame)学习笔记(01)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!