repl.it
@VesterDE/

FinalProjectEdits3

Python (with Turtle)

No description

fork
loading
main.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
import turtle


t = turtle

t.speed(0)

def drawGrid():
  x  = 4

  while x > 0:
    t.forward(300)
    t.left(90)
    x = x - 1

  t.forward(100)
  t.left(90)
  t.forward(300)
  t.right(90)
  t.forward(100)
  t.right(90)
  t.forward(300)

  t.left(90)
  t.forward(100)
  t.left(90)
  t.forward(100)
  t.left(90)

  t.forward(300)
  t.right(90)
  t.forward(100)
  t.right(90)
  t.forward(300)

  t.penup()
  t.goto(0,0)
  t.pendown()

drawGrid()
emptyspots = [1,2,3,4,5,6,7,8,9]

coordinates = [
  [50,50], 
  [150,50],
  [250,50],
  [50,150],
  [150,150],
  [250,150],
  [50,250],
  [150,250],
  [250,250]
]

def cross(x,y):
  size = 40
  t.penup()
  t.goto(x,y)
  t.pendown()
  t.right(45)
  t.forward(size)
  t.backward(size * 2)
  t.forward(size)
  t.left(90)
  t.forward(size)
  t.backward(size * 2)
  t.forward(40)
  t.right(45)

def circle(x,y):
  size = 25
  t.penup()
  t.goto(x,y)
  t.right(90)
  t.forward(25)
  t.left(90)
  t.pendown()
  t.circle(size)

print("Are you ready to play? YES/NO")
answer = input("Enter yes or no: ")
if answer == "yes":
  print("Choose a square? (Round 1)")
  answer2 = int(input(emptyspots))
  emptyspots.remove(answer2)
  cross(coordinates[answer2 - 1])

  print("Player 2's turn, chose a square? (Round 2)")
  answer3 = int(input(emptyspots))
  emptyspots.remove(answer3)
  circle(coordinates[answer3 - 1])

  print("Player 1's turn, chose a square? (Round 3)")
  answer2 = int(input(emptyspots))
  emptyspots.remove(answer2)
  cross(coordinates[answer2 - 1])

  print("Player 2's turn, chose a square? (Round 4)")
  answer3 = int(input(emptyspots))
  emptyspots.remove(answer3)
  circle(coordinates[answer3 - 1])

  print("Player 1's turn, chose a square? (Round 5)")
  answer2 = int(input(emptyspots))
  emptyspots.remove(answer2)
  cross(coordinates[answer2 - 1])

  print("Player 2's turn, chose a square? (Round 6)")
  answer3 = int(input(emptyspots))
  emptyspots.remove(answer3)
  circle(coordinates[answer3 - 1])

  print("Player 1's turn, chose a square? (Round 7)")
  answer2 = int(input(emptyspots))
  emptyspots.remove(answer2)
  cross(coordinates[answer2 - 1])

  print("Player 2's turn, chose a square? (Round 8)")
  answer3 = int(input(emptyspots))
  emptyspots.remove(answer3)
  circle(coordinates[answer3 - 1])

  print("Player 1's turn, chose a square? (Round 9)")
  answer2 = int(input(emptyspots))
  emptyspots.remove(answer2)
  cross(coordinates[answer2 - 1])
elif answer == "no":
  print("Have a nice day")

result
console
?