由于某种原因,这些线条不会出现在屏幕上。
这是我尝试过的
class Grid(Sprite):
def __init__(self):
self.grid = pygame.Surface(size)
self.grid.set_colorkey((0,0,0))
def draw(self):
# DRAW TILE LINES ----------------------------------------------------------
grid_x = 0
grid_y = 0
for i in range(GRID_SIZE):
pygame.draw.aaline(self.grid,BLACK,[grid_x,UPPER_BOUNDARY],[grid_x,LOWER_BOUNDARY],1)
pygame.draw.aaline(self.grid,BLACK,[LEFT_BOUNDARY,y],[RIGHT_BOUNDARY,grid_y],1)
grid_x += TILE_SIZE
grid_y += TILE_SIZE
# tile test
pygame.draw.rect(screen,BLACK,(49*TILE_SIZE,34*TILE_SIZE,TILE_SIZE,TILE_SIZE))
screen.blit(self.grid,(0,0))
创建对象:
grid = Grid()
调用类:(在主程序循环中)
grid.draw()