pygame程序实现的是一个用图像模拟的3D效果地图

"""本pygame程序实现的是一个用图像模拟的3D效果地图"""

import pygame
from pygame.locals import *

width,height = 480,360

screen = pygame.display.set_mode((width,height))
pygame.display.set_caption("可移动3D背景 www.lixingqiu.com")

backgrounds = [pygame.image.load(f"frames/i-{index+1}.png") for index in range(36)]
amounts = len(backgrounds)
loc_x = 0
loc_y = 0

clock = pygame.time.Clock()
running = True

while running:
    for event in pygame.event.get():
        if event.type == QUIT:running = False
        if event.type == KEYDOWN:
            if event.key == K_a : loc_x = loc_x - 1
            if event.key == K_d : loc_x = loc_x + 1
            if event.key == K_w : loc_y = loc_y + 1
            if event.key == K_s : loc_y = loc_y - 1
    index = loc_x % 6  + loc_y*6
    index = index % amounts
    bg = backgrounds[index]
    screen.blit(bg,(0,0))
    pygame.display.update()
    clock.tick(30)
pygame.quit()



 

pygame程序实现的是一个用图像模拟的3D效果地图"""