|
100鱼币
- import pygame
- import linecache
- import sys
- from pygame.locals import *
- size_a = 1
- size_c = 2
- size_b = 6
- color = (255,255,255)
- pygame.init()
- screen = pygame.display.set_mode((600,400))
- font = pygame.font.Font('yh.ttf',35)
- sizea = linecache.getline('app.txt',size_a).strip()
- sizec = linecache.getline('app.txt',size_c).strip()
- font = pygame.font.Font('yh.ttf',30)
-
- fonta = font.render(sizea,True,color)
- fontc = font.render(sizec,True,color)
- while 1:
-
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit()
- sys.exit()
-
- if event.type == KEYDOWN:
- if event.key == K_RETURN:
- if size_c < size_b:
- size_a += 2
- sizea = linecache.getline('app.txt',size_a).strip()
- fonta = font.render(sizea,True,color)
- size_c += 2
- sizec = linecache.getline('app.txt',size_c).strip()
- fontc = font.render(sizec,True,color)
-
- screen.fill((100,0,85))
- screen.blit(fonta,(0,100))
- screen.blit(fontc,(0,300))
- pygame.display.flip()
复制代码
就这个代码,第一次运行不会出错,第二次运行就会报错打不开。如果把Spyder关闭重新打开用回成功运行,这咋回事啊。。。。。。。。app.txt 里面6行,随便打点啥都行。。。。。
|
|