“ pygame.Surface”对象不可下标

时间:2018-11-29 01:26:17

标签: python pygame

有人可以修复我的代码吗?我不断收到错误消息:

  

'pygame.Surface'对象不可下标

第40行显示

SURF.blit(Dirt[tilemap[row][column]], (column*tilesize, row*tilesize))

我正在使用pygame,对python来说是个新手。谢谢您的帮助,深表感谢。

    import pygame, sys
    import Sprites
    import random

    pygame.init()

    from pygame.locals import *

    #DISPLAY = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)

    pygame.init()

    infoObject = pygame.display.Info()

    print(infoObject.current_w, infoObject.current_h)

    tilesize = 40

    TILESX = infoObject.current_w // 40
    TILESY = infoObject.current_h // 40

    print(TILESX, TILESY)

    WHITE = (255, 255, 255)
    BLACK = (0, 0, 0)

    Dirt = pygame.image.load('Sprites/Dirt.png')

   textures = {
       Dirt
   }
   tilemap = [[Dirt for w in range(TILESX)] for h in range(TILESY)]

   SURF = pygame.display.set_mode((TILESX * tilesize, TILESY * tilesize))

   while True:

for row in range(TILESY):
    for column in range(TILESX):
        SURF.blit(Dirt[tilemap[row][column]], (column * tilesize, row * tilesize))

pygame.display.update()
for event in pygame.event.get():
    if event.type == pygame.QUIT:
        pygame.quit()
        sys.exit()

input()

0 个答案:

没有答案