Jackpot

Целью данной игры разгадывание числа с определенного кол-ва попыток. Компьютерный оппонент сообщает результаты сравнения вашего числа с загаданным ( больше или меньше). Игра написана на DEV-CPP и переписана на FreeBasic

Платформа: Windows, Linux
Автор: неизвестно
Адаптация под Freebasic: electrik

Jackpot.png 

Declare Sub Start ()
Declare Sub GetResults ()
Dim Shared As Integer  i, j, life, maxrand
Dim Shared As Byte c
' program start
Print "** Jackpot game **"
Print "The goal of this game is to guess a number. You will be ask to type"
Print "a number (you have 5 guess)"
Print "Jackpot will then tell you if this number is too big of too small compared to the secret number to find"
Print
Start()
End
Sub Start ()
    i = 0
    j = 0
    life = 0
    maxrand = 6
    Print "Select difficulty mode:" ' the user has to select a difficulty level
    Print "1 : Easy (0-15)"
    Print "2 : Medium (0-30)"
    Print "3 : Difficult (0-50)"
    Print "or type another key to quit"
    c = 30
    Input ">",c                   ' read the user's choice
    Print
    Select Case c
        Case 1 : maxrand = 15  ' the random number will be between 0 and maxrand
        Case 2 : maxrand = 30
        Case 3 : maxrand = 50
        Case Else: End 0
    End Select
    life = 5         ' number of lifes of the player
    Randomize Timer
    j = Rnd * maxrand ' j get a random value between 0 and maxrand
    GetResults()
End Sub

Sub GetResults ()
    If (life <= 0) Then
        ' if player has no more life then he lose
        Print "You lose !"
        Print
        Start()
    End If
    Print "Type a number:"
    Input ">",i          ' read user's number
    If ((i>maxrand) OrElse (i<0)) Then ' if the user number isn't correct, restart
        Print "Error : Number not between 0 and ";maxrand
        GetResults()
    End If
    If (i = j) Then
        Print "YOU WIN !" ' the user found the secret number
        Print
        Start()
    Elseif (i>j) Then
        Print "Too BIG"
        life = life - 1    ' -1 to the user's "life"
        Print "Number of remaining life: ";life
        Print
        GetResults()
    Elseif (i<j) Then
        Print "Too SMALL"
        life = life - 1
        Print "Number of remaining life: "; life
        Print
        GetResults()
    End If
End Sub