-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
53 lines (41 loc) · 1.73 KB
/
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
import gamelib
from logica_chess import *
def main():
gamelib.title("Shape Shifter Chess")
gamelib.resize(ANCHO_VENTANA, ALTO_VENTANA)
nivel = 0
while True:
respuesta = gamelib.input('¿Desea cargar la última partida? (si/no)')
if not respuesta or respuesta == 'no':
nivel = 1
juego = crear_juego(nivel)
guardar_partida(juego)
break
if respuesta == 'si':
try:
juego = cargar_partida(ARCHIVO_GUARDADO)
except:
gamelib.say('No hay ninguna partida guardada. ¡Crearemos una nueva!')
nivel = 1
juego = crear_juego(nivel)
guardar_partida(juego)
break
tablero, pos_ultima_pieza, ultima_pieza, nivel, cantidad_fichas = juego
while gamelib.is_alive():
if cantidad_fichas == 1:
nivel += 1
juego = crear_juego(nivel)
tablero, pos_ultima_pieza, ultima_pieza, nivel, cantidad_fichas = juego
guardar_partida(juego)
juego_mostrar(tablero, nivel, pos_ultima_pieza, ultima_pieza)
ev = gamelib.wait()
if not ev:
break
if ev.type == gamelib.EventType.KeyPress and ev.key == 'Escape':
break
if ev.type == gamelib.EventType.KeyPress and ev.key.lower() == 'z':
juego = cargar_partida(ARCHIVO_GUARDADO)
tablero, pos_ultima_pieza, ultima_pieza, nivel, cantidad_fichas = juego
if ev.type == gamelib.EventType.ButtonPress and ev.mouse_button == 1:
pos_ultima_pieza, ultima_pieza, cantidad_fichas = juego_actualizar(tablero, pos_ultima_pieza, ultima_pieza, ev.x, ev.y, cantidad_fichas)
gamelib.init(main)