Ana Itzel Hernández García A01737526
Paola Rojas Domínguez A01737136
Dibuja líneas y formas en la pantalla. Haga clic para marcar el inicio de una forma y haga clic nuevamente para marcar su final. Se pueden seleccionar diferentes formas y colores mediante el teclado. Se añadió el color rosa
onkey(lambda: color('pink'), 'P')Se completo la función para diujar un círculo
def circle(start, end):
"""Draw circle from start to end."""
up()
goto(start.x, start.y)
down()
begin_fill()
radius = abs(end - start) / 2
circ = 2 * math.pi * radius
step = circ / 360
angle = 360
while angle > 0:
forward(step)
left(1)
angle -= 1
end_fill()Se completó la función para dibujar un rectángulo
def rectangle(start, end):
"""Draw rectangle from start to end."""
up()
goto(start.x, start.y)
down()
begin_fill()
for count in range(2):
forward(end.x - start.x)
left(90)
forward(end.y - start.y)
left(90)
end_fill()Se completó la función para dibujar un triángulo
def triangle(start, end):
"""Draw triangle from start to end."""
up()
goto(start.x, start.y)
down()
begin_fill()
# Length of the line segment between start and end
length = math.sqrt((end.x - start.x)**2 + (end.y - start.y)**2)
# Angle of the line segment
angle = math.atan2(end.y - start.y, end.x - start.x)
# Coordinates of the third vertex (assuming equilateral triangle)
third_x = end.x + length * math.cos(angle + (2 * math.pi / 3))
third_y = end.y + length * math.sin(angle + (2 * math.pi / 3))
# Draw the triangle
goto(end.x, end.y)
goto(third_x, third_y)
goto(start.x, start.y)
end_fill()def change(x, y):
"""Change snake direction."""
aim.x = x
aim.y = y
food.x = max(min(food.x + randrange(-1, 2) * 10, 190), -200)
food.y = max(min(food.y + randrange(-1, 2) * 10, 190), -200)La serpiente y la comida cambian de color cada vez que se inicia el juego
snake_color = choice(colors)
food_color = choice([color for color in colors if color!= snake_color])dist = abs(pacman - point)
if dist < 100:
course.x = aim.x
course.y = aim.yEl tablero fue modificado
tiles = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]Los fantasmas son más rápidos
for point, course in ghosts:
if valid(point + course):
point.move(course)
else:
options = [
vector(10, 0),
vector(-10, 0),
vector(0, 10),
vector(0, -10),
]
plan = choice(options)
course.x = plan.x
course.y = plan.ydef tap(x, y):
"""Respond to screen tap."""
if not inside(ball):
ball.x = -199
ball.y = -199
speed.x = (x + 200) / 5
speed.y = (y + 200) / 5Los globos se mueven más rápido
def move():
"""Move ball and targets."""
if randrange(40) == 0:
y = randrange(-150, 150)
target = vector(200, y)
targets.append(target)
for target in targets:
target.x -= 5El juego no tiene fin, los globos siguen apareciendo
Juego de rompecabezas de pares de números. Haga clic en un mosaico para revelar un número. Haga coincidir dos números y las fichas desaparecerán para revelar una imagen. Se añadió con contador de tapsdef tap(x, y):
"""Update mark and hidden tiles based on tap."""
global counter
counter += 1
spot = index(x, y)
mark = state['mark']
if mark is None or mark == spot or letters[mark] != letters[spot]:
state['mark'] = spot
else:
hide[spot] = False
hide[mark] = False
state['mark'] = NoneLos dígitos están centrados
if mark is not None and hide[mark]:
x, y = xy(mark)
up()
goto(x + 10, y + 10)
color('black')
write(letters[mark], font=('Arial', 30, 'normal'))Se notifica cuando se desbloquearon todos los cuadros
if not any(hide) and not state['won']:
up()
goto(-200, 100)
color('red')
write("Congratulations! You have found all the pairs", font=('Arial', 15, 'normal'))
#state['won'] = TrueSe usan letras en lugar de números
letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'Ñ', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'aa', 'bb', 'cc', 'dd', 'ee'] * 2