破解它:)
#Add text fields to a dictionary.
text_dict = {}
for kind in ['score','instructions','time' ]:
text = viz.addText('', viz.SCREEN )
text.setScale( .5,.5)
text.alignment( viz.TEXT_CENTER_BASE )
text.alpha( 1 )
text_dict[ kind ] = text
text_dict['score'].setPosition( .1,.9 )
text_dict['instructions'].setPosition( .5,.5 )
text_dict['time'].setPosition( .1,.85 )
def game_timer_task():
#Grab the text field for
#time.
text = text_dict[ 'time' ]
time = 0
text.message( 'Time: 0' )
#Loop through as long as time
#is under a certain number of
#seconds.
while time < 10:
yield viztask.waitTime( 1 )
time += 1
text.message( 'Time: ' + str( time ) )
def game():
time_passing = viztask.waitTask( game_timer_task() )
data = viz.Data()
yield viztask.waitAny( [time_passing], data )
if data.condition == time_passing:
game_over = text.message( 'Game Over!' )
game_over.setPosition( .1,.85 )
def main_sequence():
yield game()
viztask.schedule( main_sequence() )