Hardware Reference
In-Depth Information
Listing 8-3 continued
tickSound = pygame.mixer.Sound(“sounds/tick.ogg”)
applauseSound = pygame.mixer.Sound(“sounds/applause.ogg”)
dohSound = pygame.mixer.Sound(“sounds/doh.ogg”)
easyCols = [ 0x3, 0xC, 0xF, 0x30, 0x33, 0x3C, 0x3F ]
intCols = [ 0x3, 0xC, 0xF, 0x30, 0x33, 0x3C, 0x3F,
0x1, 0x4, 0x5, 0x10, 0x11, 0x14, 0x15]
colours = [ easyCols, intCols ]
level = 2 # 0 = easest level 2 = hardset
playerName = [“no player”, “Blue player”,”Red Player”]
countToMatch = 0
roundToPlay = 1 # current round number
maxRound = 5 # number of rounds to play
redScore = 0
blueScore = 0
def main():
global level
print”Colour Snap, ctrl C to quit”
show_table()
playerName[1] = raw_input(“Enter the name ;
of the player using the blue button “)
p1Score = set_table(playerName[1], 0); ;
#make sure player is in database
print “The score for”,playerName[1],”so far is “,p1Score
playerName[2] = raw_input(“Enter the name of the ;
player using the red button “)
p2Score = set_table(playerName[2], 0); ;
#make sure player is in database
print “The score for”,playerName[2],”so far is “,p2Score
il = raw_input (“Enter a difficulty level 1 Easy ;
to 3 Hard “)
level = int(il)-1
#make sure the level is within range
if level>2:
level=2
if level < 0:
level = 0
lc = random.randint(0,63) # the last colour shown
while roundToPlay <= maxRound :
print “Round “,roundToPlay, “ of “,maxRound
countToMatch = random.randint(3, 10)
Search WWH ::




Custom Search