/
sb.py
144 lines (123 loc) · 4.91 KB
/
sb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env python
# coding=utf-8
import time, buzzdisp, buzz, sons, pygame, camera
from pygame.locals import *
round = 0
def main():
sound=True
buzzdisp.init()
buzzdisp.headline("Spider Buzz!")
logo = buzzdisp.initLogo()
players = []
wrong = []
host = 0
playerImages=[]
scores=[]
#initialize buzz controls
devices=buzz.deviceInit()
if sound:
sons.init()
sons.play("generique.mp3")
buzz.lightRun(devices)
buzz.lightRun(devices)
buzzdisp.info("Maitre de jeu: Appuyez sur votre bouton rouge")
while 1:
click = buzz.getPress(devices)
if click%5 == 0: ## buzz button was clicked
host = click//5
buzz.light(devices,host,1)
buzzdisp.info("Maitre de jeu: Appuyez sur votre bouton orange pour confirmer")
if buzz.getPress(devices) == click+2:
buzz.blink(devices,host)
buzz.light(devices,host,1)
break
buzz.light(devices,host,0)
buzzdisp.info("Maitre de jeu: Appuyez sur votre bouton rouge")
mode=1
buzzdisp.headline("Inscriptions")
webcam = camera.init()
while len(players)<(len(devices)*4)-1:
while 1:
buzzdisp.info("Joueur " + str(len(players)+1) + ", mettez vous devant la camera et appuyez sur votre bouton rouge")
buzzdisp.bigImage(logo)
click = buzz.getPress(devices)
if click == (host*5)+4:
break
if click % 5 == 0 and click != host*5:
pNum = click // 5
if not pNum in players:
if sound:
sons.play("camera.aiff")
img = buzzdisp.camImage(webcam)
buzzdisp.info("Appuyez sur le bouton orange pour accepter ou le bouton vert pour continuer")
while 1:
confclick = buzz.getPress(devices)
if confclick == pNum*5+2:
playerImages.append(img)
players.append(pNum)
scores.append(0)
buzz.light(devices,pNum,1)
buzzdisp.addPlayer(img,len(players))
break
if confclick == pNum*5+3:
break
if confclick == pNum*5+2:
break
if click == (host*5)+4:
break
buzz.lightRun(devices)
buzzdisp.updateScores(playerImages, scores)
buzzdisp.headline("Les inscriptions sont closes")
buzzdisp.info("Maitre: Appuyez sur le bouton bleu pour demarrer le jeu")
while 1:
while buzz.getPress(devices) != host*5+1:
test=1
if sound:
sons.play("zero.mp3")
buzzdisp.headline("Nouvelle question....")
buzzdisp.info("")
buzzdisp.bigImage(logo)
buzz.lightRun(devices)
clicker = 0
wrong = []
while 1:
click = buzz.getPress(devices)
if click%5 == 0 and click != host*5: #Player buzzed in
clicker = click/5
#If Player has already answered wrong their Buzz is not accepted
if not clicker in wrong and clicker in players:
pIndex = players.index(clicker)
if sound:
sons.play("ringin.mp3")
buzz.light(devices,clicker,1)
buzzdisp.bigImage(playerImages[pIndex])
buzzdisp.headline("Joueur " + str(pIndex+1))
#Wait for right or wrong decision
while 1:
click = buzz.getPress(devices)
if click == host*5+3:
if sound:
sons.play("wrong.mp3")
buzzdisp.headline("MAUVAISE REPONSE")
wrong.append(clicker)
buzz.light(devices,clicker,0)
break
if click == host*5+2:
if sound:
sons.play("right.mp3")
buzzdisp.headline("BONNE REPONSE!")
scores[pIndex] = scores[pIndex] + 100
buzzdisp.updateScores(playerImages, scores)
buzz.light(devices,clicker,0)
break
if click == host*5+1:
break
if click == host*5+1 or click == host*5+2: #Next Question button
break
while 1:
for event in pygame.event.get():
if event.type == QUIT:
buzz.release(devices)
return
pass
if __name__ == '__main__': main()