|
10鱼币
- import pygame
- import sys
- import linecache
- from pygame.locals import *
- a = 1
- b = []
- c = 0
- pygame.init()
- screen = pygame.display.set_mode((1600,900))
- qiu = pygame.image.load('qiu.png')
- size = linecache.getline('shi.txt',a).strip()
- d = int(size)
- for i in range(d):
- a += 1
- s = linecache.getline('shi.txt',a).strip()
- b.append(s)
- print(d)
- print(b)
- while 1:
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit()
- sys.exit()
-
- screen.fill((255,255,255))
-
- for i in range(int(d/2)):
- screen.blit(qiu,(int(b[c]),int(b[c+1])))
- c += 2
- print(i)
- pygame.display.flip()
复制代码
shi.txt 里面是五行,分别是4,200,200,600,600.
但是运行时会说我‘screen.blit(qiu,(int(b[c]),int(b[c+1])))’这一行IndexError: list index out of range,咋回事啊,大佬们
|
|