News:

Welcome to RetroCoders Community

Main Menu

FreeBasic Console Game - Avishai

Started by ron77, Aug 16, 2023, 03:36 AM

Previous topic - Next topic

ron77

#include "fbgfx.bi"
'~ #include "fbcon.bi"

const SUCCESS = 1
const NEUTRAL = 2
const FAILED = 3

dim shared as integer avishai_happy = 0
dim shared as integer avishai_sad = 0
dim shared as boolean over = TRUE

sub show_results(result as integer)
    select case result
        case SUCCESS
            print "Avishai is happy."
            avishai_happy += 1
        case NEUTRAL
            print "Avishai is apathetic."
        case FAILED
            print "Avishai cries."
            avishai_sad += 1
    end select
end sub

sub game_turn()
    dim as integer choice
	cls
    print "It's a new day in 1988."
    print "Options:"
    print "1. Feed Avishai"
    print "2. Give him medications"
    print "3. Take him to the public garden"
    print "4. Play music for him"
    print "5. Put Avishai to bed"
    print "6. Exit the game"

    input choice
    cls

    select case choice
        case 1
            show_results(int(rnd * 3) + 1)
        case 2
            show_results(int(rnd * 3) + 1)
        case 3
            show_results(int(rnd * 3) + 1)
        case 4
            show_results(int(rnd * 3) + 1)
        case 5
            show_results(int(rnd * 3) + 1)
        case 6
            print "Exiting the game."
            sleep
            over = FALSE
        case else
            print "Invalid choice. Try again."
    end select
    sleep
end sub

sub main()
    '~ screenres 80, 25, 32
    randomize timer

    while over
        game_turn()
    wend

    locate 20, 1
    print "Avishai was happy "& str(avishai_happy) & " times."
    print "Avishai was sad "& str(avishai_sad) & " times."

    sleep
end sub

main()