Hardware Reference
In-Depth Information
while countToMatch !=0 : ;
# do this until you get a match
countToMatch -= 1
if countToMatch != 0 : ;
#don't generate a new colour on last turn
c = newColour(lc);
tickSound.play()
time.sleep(0.5)
pfio.write_output(c) # turn on the colour
checkInput(0.8, c, lc)
pfio.write_output(0) # turn off the light
checkInput(0.9, c, lc)
lc = c # record the last colour
print “End of the game”
if blueScore == redScore:
print”It is a DRAW!!! “
else:
win = 2
if blueScore > redScore:
win = 1
print”The winner is “,playerName[win]
p1Score += blueScore
set_table(playerName[1], p1Score);
p2Score += redScore
set_table(playerName[2], p2Score);
print”Updating high score table”
show_table()
# end of main function
def newColour(lastColour):
nc = lastColour
if level == 2 : # hardest
nc ^= 1 << random.randint(0,5) ;
# change by only a single bit
else:
while nc == lastColour : ;
# repeat until you find a new colour
nc = colours[level][random.randint;
(0,len(colours[level])-1)]
return nc
def checkInput(delay, c, lc) : # has someone pressed a button
continued
Search WWH ::




Custom Search