Instructions
57
#
-*- coding: utf-8 -*
-
i
mport pygame, sys, ran
d
o
m
from
p
ygame.
l
oca
l
s im
p
ort
*
pygame.init(
)
F
ELD
= pygame.
d
isp
l
ay.set_mo
d
e((320, 320)
)
p
ygame.
d
is
pl
ay.set_ca
p
tion("Wuerfe
l
"
)
B
LAU
= (0, 0, 255
)
W
EISS
= (255, 255, 255
)
P
1 = ((160, 160)
)
P
2 = ((60, 60)
)
P
3 = ((160, 60));
P
4 = ((260, 60)
)
P
5 = ((60, 260)
)
P
6 = ((160, 260)
)
P
7 = ((260, 260)
)
main
l
oo
p
=
T
ru
e
print "Be
l
ie
b
ige
T
aste
d
rüc
k
en, um zu würfe
l
n, [
E
sc]
b
een
d
et
d
as
S
pie
l
"
wh
i
l
e main
l
oop
:
for event in pygame.event.get()
:
if event.type == Q
UIT
or (event.type == K
EYU
P and event.key == K_
ESCA
P
E
)
:
main
l
oop = Fa
l
s
e
if event.type == K
EYDO
W
N:
F
ELD
.fi
ll(
B
LAU)
ZA
H
L
= random.randrange (1, 7
)
print
ZA
H
L
if
ZA
H
L
== 1
:
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P1, 40
)
if
ZA
H
L
== 2
:
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P2, 40
)
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P7, 40
)
if
ZA
H
L
==
3:
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P1, 40
)
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P4, 40
)
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P5, 40
)
if
ZA
H
L
== 4
:
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P2, 40
)
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P4, 40
)
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P5, 40
)
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P7, 40
)
if
ZA
H
L
==
5:
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P1, 40
)
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P2, 40
)
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P4, 40
)
pygame.
d
raw.circ
l
e(F
ELD
, W
EISS
, P5, 40
)
10145-5 Raspberry Pi verstehen und anwenden_01.indd 5710145-5 Raspberry Pi verstehen und anwenden_01.indd 57 30.06.2017 10:09:3530.06.2017 10:09:35