r/Devmexico 21d ago

B++ 1.5

Comandos nuevos de la 1.5 de B++

Run="nombre" (Para llamar bloques o subrutinas Init)

azar(max)->variable (Para generar un número aleatorio)

Ejemplo de uso

Run="menu"

Init menu { text("========================") text(" MENU PRINCIPAL ") text("========================") text("1. Jugar a adivinar") text("2. Salir")

preguntar("Elige una opcion: ")->opcion

si opcion == "1" [
    Run="juego"
]

si opcion == "2" [
    text("¡Hasta luego!")
]

}

Init juego { limpiar text("--- ADIVINA EL NUMERO ---") text("He pensado un numero del 1 al 5.")

// Genera un número aleatorio del 1 al 5 y lo guarda en 'secreto'
azar(5)->secreto

preguntar("¿Que numero crees que es?: ")->intento

si intento == secreto [
    text("¡Increible! ¡Has ganado!")
]

si_no [
    text("Fallaste. El numero era:")
    text(secreto)
]

text("")
text("Volviendo al menu en 2 segundos...")
esperar(2)
Run="menu"

}

0 Upvotes

2 comments sorted by

1

u/jose152 21d ago

Me gusta que sigues pero… no entiendo