-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLes07.py
More file actions
66 lines (47 loc) · 1.41 KB
/
Les07.py
File metadata and controls
66 lines (47 loc) · 1.41 KB
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
import math
import random
import turtle
phi = 360 / 7
r = 50
def gotoxy(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
def drew_circle(r, color):
turtle.fillcolor(color)
turtle.begin_fill()
turtle.circle(r)
turtle.end_fill()
def drew_baraban(base_x, base_y):
gotoxy(base_x, base_y)
turtle.circle(80)
gotoxy(base_x, base_y + 160)
drew_circle(5, "red")
for i in range(0, 7):
phi_rad = phi * i * math.pi / 180.0
gotoxy(base_x + math.sin(phi_rad) * r, base_y + math.cos(phi_rad) * r +
60)
drew_circle(22, "white")
def turn_baraban(base_x, base_y, start):
for i in range(start, random.randrange(7, 28)):
phi_rad = phi * i * math.pi / 180.0
gotoxy(base_x + math.sin(phi_rad) * r, base_y + math.cos(phi_rad) * r +
60)
drew_circle(22, "brown")
drew_circle(22, "white")
gotoxy(base_x +math.sin(phi_rad) * r, base_y + math.cos(phi_rad) * r + 60)
drew_circle(22, "brown")
return i % 7
turtle.speed(0)
drew_baraban(-50, 100)
start = 0
answer = ""
while answer != "n":
answer = turtle.textinput("Играем в Русскую рулетку?", "y/n")
if answer == "y":
start = turn_baraban(-50, 100, start)
if start == 0:
gotoxy(-150, 250)
turtle.write("Game over!", font=("Keystroke", 32, "normal"))
else:
pass