-
Notifications
You must be signed in to change notification settings - Fork 2
/
pantalla_inicio.py
34 lines (28 loc) · 935 Bytes
/
pantalla_inicio.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
import curses
import time
from curses import textpad
menu = ['Nuevo Juego', 'Scoreboard', 'Salir']
def print_menu(stdscr, selected_row_idx):
stdscr.clear()
stdscr.addstr(10, 50, "Juego de la Serpiente")
sh, sw = stdscr.getmaxyx()
box = [[3,3], [sh-3, sw-3]] # [[ul_y, ul_x], [dr_y, dr_x]]
textpad.rectangle(stdscr, box[0][0], box[0][1], box[1][0], box[1][1])
h, w = stdscr.getmaxyx()
for idx, row in enumerate(menu):
x = w//2 - len(row)//2
y = h//2 - len(menu)//2 + idx
if idx == selected_row_idx:
stdscr.attron(curses.color_pair(1))
stdscr.addstr(y, x, row)
stdscr.attroff(curses.color_pair(1))
else:
stdscr.addstr(y, x, row)
stdscr.refresh()
def print_center(stdscr, text):
stdscr.clear()
h, w = stdscr.getmaxyx()
x = w//2 - len(text)//2
y = h//2
stdscr.addstr(y, x, text)
stdscr.refresh()