forked from Manish57-droid/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchess board
More file actions
60 lines (41 loc) · 1 KB
/
chess board
File metadata and controls
60 lines (41 loc) · 1 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
import turtle
sc = turtle.Screen()
cb = turtle.Turtle()
# method to draw square
def draw():
for i in range(4):
cb.forward(30)
cb.left(90)
cb.forward(30)
# Driver Code
if __name__ == "__main__":
# set screen
sc.setup(400, 600)
# set turtle object speed
cb.speed(100)
# loops for board
for i in range(8):
# not ready to draw
cb.up()
# set position for every row
cb.setpos(-100, 30 * i)
# ready to draw
cb.down()
# row
for j in range(8):
# conditions for alternative color
if (i + j) % 2 == 0:
col = 'black'
else:
col = 'white'
# fill with given color
cb.fillcolor(col)
# start filling with colour
cb.begin_fill()
# call method
draw()
# stop filling
cb.end_fill()
# hide the turtle
cb.hideturtle()
turtle.done()