0
有沒有人可以把這個程序寫在非常少的一行?或者應該被寫作就是這樣的,我還挺新的,並想知道如果我用太多的代碼爲這個這可以寫在更少的行,以做它做什麼?
#!/usr/bin/python
import pygame
pygame.init()
window=pygame.display.set_mode([500,500])
pygame.display.set_caption("Drop")
clock = pygame.time.Clock()
game_running=True
y=0;yy=1
accy = [0,0,0,0,0,0,0,0]
while game_running:
for event in pygame.event.get():
if event.type==pygame.QUIT:
game_running=False
window.fill((0,0,0))
x=0
pygame.draw.rect(window, (101,201,200), [15+x,0+y+accy[0],50,50],0)
x+=60
if not accy[0]==450:
accy[0]+=1
pygame.draw.rect(window, (101,201,200), [15+x,0+y+accy[1],50,50],0)
x+=60
if accy[0] >= 50 and not accy[1] == 450:
accy[1]+=1
pygame.draw.rect(window, (101,201,200), [15+x,0+y+accy[2],50,50],0)
x+=60
if accy[1] >= 50 and not accy[2] == 450:
accy[2]+=1
pygame.draw.rect(window, (101,201,200), [15+x,0+y+accy[3],50,50],0)
x+=60
if accy[2] >= 50 and not accy[3] == 450:
accy[3]+=1
pygame.draw.rect(window, (101,201,200), [15+x,0+y+accy[4],50,50],0)
x+=60
if accy[3] >= 50 and not accy[4] == 450:
accy[4]+=1
pygame.draw.rect(window, (101,201,200), [15+x,0+y+accy[5],50,50],0)
x+=60
if accy[4] >= 50 and not accy[5] == 450:
accy[5]+=1
pygame.draw.rect(window, (101,201,200), [15+x,0+y+accy[6],50,50],0)
x+=60
if accy[5] >= 50 and not accy[6] == 450:
accy[6]+=1
pygame.draw.rect(window, (101,201,200), [15+x,0+y+accy[7],50,50],0)
if accy[6] >= 50 and not accy[7] == 450:
accy[7]+=1
clock.tick(60)
pygame.display.flip()
是這樣過多或這可能是短?