User manual

66
pygame.display.set_caption(“Dicel")
BlUE = (0, 0, 255); WHITE = (255, 255, 255)
P1 = ((160, 160)); P2 = ((60, 60)); P3 = ((160, 60));
P4 = ((260, 60))
P5 = ((60, 260)); P6 = ((160, 260)); P7 = ((260, 260))
mainloop = True
print “Press any key to roll the dice, [Esc]
exits the game”
while mainloop:
for event in pygame.event.get():
if event.type == QUIT or (event.type == KEYUP
and event.key == K_ESCAPE):
mainloop = False
if event.type == KEYDOWN:
FELD.fill(BUE)
NUMBER = random.randrange (1, 7); print NUMBER
if NUMBER == 1:
pygame.draw.circle(FIELD, WHITE, P1, 40)
if NUMBER == 2:
pygame.draw.circle(FIELD, WHITE, P2, 40)
pygame.draw.circle(FIELD, WHITE, P7, 40)
if NUMBER == 3:
pygame.draw.circle(FIELD, WHITE, P1, 40)
pygame.draw.circle(FIELD, WHITE, P4, 40)
pygame.draw.circle(FIELD, WHITE, P5, 40)
if NUMBER == 4:
pygame.draw.circle(FIELD, WHITE, P2, 40)
pygame.draw.circle(FIELD, WHITE, P4, 40)
pygame.draw.circle(FIELD, WHITE, P5, 40)
pygame.draw.circle(FIELD, WHITE, P7, 40)
if NUMBER == 5:
pygame.draw.circle(FIELD, WHITE, P1, 40)
pygame.draw.circle(FIELD, WHITE, P2, 40)
pygame.draw.circle(FIELD, WHITE, P4, 40)
pygame.draw.circle(FIELD, WHITE, P5, 40)
pygame.draw.circle(FIELD, WHITE, P7, 40)
if NUMBER == 6:
pygame.draw.circle(FIELD, WHITE, P2, 40)
pygame.draw.circle(FIELD, WHITE, P3, 40)
pygame.draw.circle(FIELD, WHITE, P4, 40)
pygame.draw.circle(FIELD, WHITE, P5, 40)
pygame.draw.circle(FIELD, WHITE, P6, 40)
pygame.draw.circle(FIELD, WHITE, P7, 40)
pygame.display.update()
pygame.quit()
Runs without sudo
This programme does not require any GPIO ports, and also works without superuser privileges. You can
simply start the Python IDE using the desktop icon
IDLE
.