from PicoGameBoy import PicoGameBoy
import time
import tetris
def display_menu(pgb, items):
selected = 0
while True:
pgb.fill(PicoGameBoy.color(0, 0, 0)) # Limpa a tela
for i, item in enumerate(items):
color = PicoGameBoy.color(255, 255, 255) if i == selected else PicoGameBoy.color(100, 100, 100)
pgb.text("-> " + item if i == selected else " " + item, 10, 10 + i * 10, color)
pgb.show()
if pgb.button_up():
selected = (selected - 1) % len(items)
time.sleep(0.2) # Debounce
elif pgb.button_down():
selected = (selected + 1) % len(items)
time.sleep(0.2) # Debounce
elif pgb.button_A():
time.sleep(0.2) # Debounce
return items[selected]
def main():
pgb = PicoGameBoy()
# Cores (RGB)
BLACK = PicoGameBoy.color(0, 0, 0)
WHITE = PicoGameBoy.color(255, 255, 255)
# Limpa a tela
pgb.fill(BLACK)
pgb.show()
# Opções do menu
menu_items = ["Tetris", "Snake", "Settings", "Exit"]
while True:
selected_option = display_menu(pgb, menu_items)
if selected_option == "Tetris":
# Chama a função principal do Tetris
tetris.tetris_main()
elif selected_option == "Settings":
# Configurações do jogo
pgb.fill(BLACK)
pgb.center_text("Settings menu coming soon!", WHITE)
pgb.show()
time.sleep(2)
elif selected_option == "Exit":
pgb.fill(BLACK)
pgb.center_text("Exiting...", WHITE)
pgb.show()
time.sleep(2)
# Desligar o jogo ou resetar
pgb.enter_low_power()
if __name__ == "__main__":
main()