-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJOGO_COMPLETO.py
170 lines (145 loc) · 3.76 KB
/
JOGO_COMPLETO.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 24 15:40:38 2015
@author: Gabriel
"""
import turtle
import random
turtle.setup(1200,500)
def forca():
forca = turtle.Turtle()
forca.hideturtle()
forca.penup()
forca.setpos(-200,-100)
forca.pendown()
forca.pensize(5)
forca.left(90)
forca.forward(200)
forca.right(90)
forca.forward(60)
forca.right(90)
forca.forward(20)
def cabeca():
forca = turtle.Turtle()
forca.speed(10)
forca.hideturtle()
forca.pensize(5)
forca.penup()
forca.setpos(-140,80)
forca.left(180)
forca.pendown()
forca.circle(20)
def corpo():
forca = turtle.Turtle()
forca.hideturtle()
forca.pensize(5)
forca.penup()
forca.setpos(-140,40)
forca.pendown()
forca.right(90)
forca.forward(60)
def bracoe():
forca = turtle.Turtle()
forca.hideturtle()
forca.pensize(5)
forca.penup()
forca.setpos(-140,35)
forca.pendown()
forca.right(30)
forca.forward(20)
def bracod():
forca = turtle.Turtle()
forca.hideturtle()
forca.pensize(5)
forca.penup()
forca.setpos(-140,35)
forca.pendown()
forca.right(150)
forca.forward(20)
def pernae():
forca = turtle.Turtle()
forca.hideturtle()
forca.pensize(5)
forca.penup()
forca.setpos(-140,-20)
forca.pendown()
forca.right(30)
forca.forward(25)
def pernad():
forca = turtle.Turtle()
forca.hideturtle()
forca.pensize(5)
forca.penup()
forca.setpos(-140,-20)
forca.pendown()
forca.right(150)
forca.forward(25)
janela = turtle.Screen()
janela.bgcolor('blue')
forca()
escolha = 0
erros = 0
acertos = []
tentativas = []
digitadas = []
arquivo=open('entrada.csv','r')
leitura=arquivo.read(1000)
l=leitura.split(',')
palavra=random.choice(l).lower()
print(palavra)
numletras = len(palavra)
print (numletras)
while erros<6:
forca = turtle.Turtle()
forca.clear()
senha = ""
for letra in palavra:
senha += letra if letra in acertos else " " if letra == (" ") else "_ "
forca.hideturtle()
forca.penup()
forca.setpos(-500,-200)
forca.write(senha, move=False, align="left", font=("Arial", 45, "normal"))
if senha == palavra:
forca.clear()
ganhou = turtle.Turtle()
ganhou.hideturtle()
ganhou.penup()
ganhou.setpos(-200,-200)
ganhou.write('Voce ganhou!', move=False, align="left", font=("Arial", 45, "normal"))
break
tentativa= janela.textinput('','Digite uma letra ').lower().strip()
if tentativa == ('exit'):
break
if tentativas in digitadas:
forca.clear()
forca.write('Letra ja digitada', move=False, align="left", font=("Arial", 30, "normal"))
continue
else:
digitadas += tentativa
forca.clear()
if tentativa in palavra:
acertos += tentativa
forca.clear()
else:
erros = erros + 1
if erros == 1:
cabeca()
elif erros == 2:
corpo()
elif erros == 3:
bracod()
elif erros == 4:
bracoe()
elif erros == 5:
pernad()
elif erros == 6:
perdeu = turtle.Turtle()
pernae()
forca.clear()
perdeu.hideturtle()
perdeu.penup()
perdeu.setpos(-200,-200)
perdeu.write(palavra, move=False, align="left", font=("Arial", 45, "normal"))
perdeu.setpos(-70,0)
perdeu.write('voce perdeu', move=False, align="left", font=("Arial", 45, "normal"))
janela.exitonclick()