A MIND GAME SIMULATION (sketch)

New to FreeBASIC? Post your questions here.
Post Reply
ron77
Posts: 212
Joined: Feb 21, 2019 19:24

A MIND GAME SIMULATION (sketch)

Post by ron77 »

hello all.

here is a code of a sketch of a game originally written by me in qb (qb64)...

the game is text only no graphics the player is homeless and must find a way to survive and find a home and a job or he/she dies on the street...
i apologizes on my bad english in the game...

Code: Select all

'$lang:"qb"

'_TITLE "HOMLESSNESS - A MIND SIMULATION V2.0"
SCREEN 0
DIM SHARED senario(1 TO 3) AS STRING, name$, status(1 TO 3) AS STRING, action(1 TO 5) AS STRING, ac$, d AS INTEGER, health AS INTEGER, dollars AS INTEGER
DIM SHARED home(1 TO 6) AS STRING, shelter(1 TO 6) AS STRING, money(1 TO 5) AS STRING, job(1 TO 3) AS STRING, result AS STRING, over AS INTEGER, drug(1 TO 4) AS STRING
RANDOMIZE TIMER

FOR i = 1 TO 3
    READ r$
    senario(i) = r$
NEXT i
FOR i = 1 TO 3
    READ status(i)
NEXT i
FOR i = 1 TO 5
    READ action(i)
NEXT i
FOR i = 1 TO 6
    READ home(i)
NEXT i
FOR i = 1 TO 6
    READ shelter(i)
NEXT i
FOR i = 1 TO 5
    READ money(i)
NEXT i
FOR i = 1 TO 3
    READ job(i)
NEXT i
FOR i = 1 TO 4
    READ drug(i)
NEXT i

Sub cp (row, s$)
    LOCATE row, (80 - LEN(s$)) / 2: PRINT s$
END SUB

FUNCTION GetKey$ (keysToCatch$)
    DIM k$
    DO
        k$ = INKEY$
        WHILE LEN(k$) = 0
            k$ = INKEY$
            '_LIMIT 60
        WEND
    LOOP UNTIL INSTR(keysToCatch$, k$)
    GetKey$ = k$
END FUNCTION

SUB opening
    CLS
    cp 4, "HOMELESSNESS - SURVIVING THE STREETS"
    cp 6, "A MIND SIMULATION GAME"
    cp 8, "by ronblue77 (ron77)"
    cp 10, "IMPORTENT NOTE:"
    cp 11, "THIS GAME COMES TO BRING TO AWARENESS THE PROBLEM OF HOMLESSNESS"
    cp 12, "I DO NOT MEAN TO MOCK OR INSULT ANYONE! PLEASE HELP PUT AN END TO HOMELESSNESS"
    cp 16, "press ESC to quit or ENTER key to play"
    k$ = GetKey$(CHR$(27) + CHR$(13))
    IF k$ = CHR$(27) THEN
        cp 19, "GOODBYE!": END
        CLS
    END IF
    CLS
    LOCATE 6, 14: INPUT "enter name: ", name$
    'inputc 6, "enter name: "

    PRINT name$ + senario(INT(RND * UBOUND(senario) + 1)): PRINT
    PRINT "GOOD LUCK!"
    SLEEP
END Sub

SUB main
    CLS
    cp 1, "press ESC to quit"
    cp 2, "day: " + STR$(d) + " health (0-100%): " + STR$(health) + " money: " + STR$(dollars) + "$"
    LOCATE 4, 10: PRINT status(INT(RND * UBOUND(status) + 1))
    PRINT
    FOR i = 1 TO 5
        PRINT action(i): PRINT
    NEXT i
    second_choice:
    ac$ = GetKey$("12345" + CHR$(27))
    IF ac$ = CHR$(27) THEN over = -1: EXIT SUB
    IF ac$ = "1" THEN
        result = money(INT(RND * UBOUND(money) + 1))
        PRINT result
        IF result = money(4) THEN over = -1
        IF result = money(1) OR result = money(2) OR result = money(3) THEN dollars = dollars + 20: health = health + 25
    ELSEIF ac$ = "2" THEN
        result = shelter(INT(RND * UBOUND(shelter) + 1))
        PRINT result
        IF result = shelter(4) THEN over = -1
    ELSEIF ac$ = "3" THEN
        result = home(INT(RND * UBOUND(home) + 1))
        PRINT result
        IF result = home(5) THEN over = -1
    ELSEIF ac$ = "4" THEN
        'result = job(INT(RND * UBOUND(job) + 1))
        IF health > 20 THEN
            result = job(INT(RND * UBOUND(job) + 1))
            PRINT result
            IF result = job(2) THEN over = -1
        ELSE
            PRINT "NOBODY WILL HIYER YOU UNTIL YOUR HEALTH GETS BETTER CHOOSE OTHE OPTION": ac$ = "": GOTO second_choice
        END IF
    ELSEIF ac$ = "5" THEN
        IF dollars >= 20 THEN
            health = health - 20
            result = drug(INT(RND * UBOUND(drug) + 1))
            PRINT result
            IF result = drug(4) THEN over = -1
        ELSE
            PRINT "YOU DON'T HAVE ENOUGH MONEY CHOOSE OTHER OPTION": ac$ = "": GOTO second_choice
        END IF
    END IF
    PRINT "press any key..."
    SLEEP
    PRINT
    finish:
    IF over = -1 THEN
        IF health <= 0 OR result = drug(4) OR result = shelter(4) OR result = money(4) THEN
            PRINT "YOU DIED ON THE STREETS - GAME OVER"
        ELSE
            PRINT "YOU SURVIVED THE STREETS - GAME OVER": PRINT
        END IF
        PRINT "YOU SURVIVED ON THE STREETS FOR: " + STR$(d) + " DAYS"
        SLEEP (3)
        EXIT SUB
    ELSE
        d = d + 1
        dollars = dollars - 10
        health = health - 10
        IF health > 100 THEN health = 100
        IF dollars < 0 THEN dollars = 0
        IF health <= 0 THEN over = -1: GOTO finish
        CLS
        PRINT "press any key to continue to the nexy day"
        SLEEP
        CLS
    END IF
END Sub

DO
    d = 1
    over = 0
    health = 50
    dollars = 20
    opening
    DO
        main


    LOOP UNTIL over = -1

    PRINT "play again? y/n?:"
    k2$ = GetKey$("yn")
    IF LCASE$(k2$) = "n" THEN END
Loop

'senarios:
DATA " you are runaway teenager that run from home... you need to survive on the streets till you can find a home."
DATA " you are a middle age person who's wife filed for divorce and throwed you from your house... you live in your old car till you get a new place to live."
DATA " you are brock with no job and no family... you have been kick out of your home now you have to find a solution to your problem."

'status
DATA "it's morning rise and shine... you almost don't have any money and you are hungry"
DATA "it's noon you have been sitting and begging for change from passing people some have given you some money"
DATA "it's night you are tired and need to find a safe place to sleep"

'actions
DATA "press 1 to: go beg or look for food or money"
DATA "press 2 to: find help and/or shelter"
DATA "press 3 to: call from a street phone to a family member or a friend to ask for help"
DATA "press 4 to: try to find a job or work"
DATA "press 5 to: do drugs or drink alcohol to forget the pain suffering and loneliness"

'call home
DATA "you call your grandma and you both cry... she promises to try to get you some help... she sends you her love... you promise to keep in touch with her"
DATA "you call a friend and she gives you some money and lets you stay at her place for the night... you get to have a good shower some clean cloths and eat a good meal and your back on the streets again"
DATA "you call a number of a hot-line for aid to homeless persons... the come and pick you up give some food and shelter for the night you talk to a social worker and he gives you his number just in case you need it"
DATA "you call a relative but no one answers... you are left alone on the streets"
DATA "you call your family and they pick you up and let you stay for as long as you need... you are off the streets"
DATA "you call but there is no answer"

'help or shelter
DATA "you go to a shelter for homeless people... you are robed from you money by violent addicts... you succeed to run away from there and spend the rest of the night at a park crying"
DATA "you try to sleep at the park but you get arrested by a policeman... you spend few hours in jail where you are beaten by inmates... by morning you are on the street again"
DATA "you have enough money to rent a motel room for the night... you shower and wash you cloths and sleep in a warm bed and dream you have a home"
DATA "you sleep at the park on a bench where you freeze to death cause of the cold weather... you are now in heaven RIP"
DATA "you sleep on the street on a corner when you wake up you find a 20 dollar bill and a note that says 'may god help you this is the little i can do'"
DATA "you are arrested by the police and now instead surviving on the street you have to survive being in jail"

'beg for money
DATA "you sit for hours and people pass you by as if you are invisible then some kind lady comes and invite you to eat at a dinner on her expense... you talk with her for two hours and tell her your story... then she says 'bye'"
DATA "you sit at a corner and people give you coins and dollars you get enough money to go by for a few days"
DATA "you sit and some men offers you work for some money and a meal you accept... you go to his house and help him paint his house then he gives you 10 dollars and a home cocked meal"
DATA "no one gives you nothing! your hungry and you have no choice but to look for food in the garbage... you get sick... very sick and you die on the streets from food poison... RIP"
DATA "you sit all day for nothing nobody gives you anything"

'job
DATA "you try to find work but nobody is interested"
DATA "you find work as a dishwasher at a dinner after a week you can afford a place to call home. you are off the street!"
DATA "you find work but you are fired really quick"

'drugs and alcohol
DATA "you get drunk and stone from cheep alcohol and for a few hours you forget about all your problems"
DATA "you do cheep street drugs and you get sick and collapse on the street... you wake up at the hospital and when you are better you are out on the street again"
DATA "you get stones and passed out when you wake in the morning everything you had is gone - you gut mugged"
DATA "you do drugs and over dose and die on the streets RIP"
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: A MIND GAME SIMULATION (sketch)

Post by badidea »

It is quite funny, I died 3 times after the first day and made it once to the 4th day.
ron77
Posts: 212
Joined: Feb 21, 2019 19:24

Re: A MIND GAME SIMULATION (sketch)

Post by ron77 »

hello i'm trying to convert my "homeless mind game simulation" from qb mode to fb mode and it works but not as i expected it has bugs in it which i don't understand... if anyone would be kind enough to check my fb code and tell me why it's not working as it should... (where and what are the bugs)
thank you...

Code: Select all

#Lang "fb"

'_TITLE "HOMLESSNESS - A MIND SIMULATION V2.0"

Sub cp (row As integer, s As String)
    LOCATE (row, (80 - LEN(s)) / 2): PRINT s
END SUB

FUNCTION GetKey2 (keysToCatch As String)As String
    DIM k As String
    Do
        k = InKey
        WHILE LEN(k) = 0
            k = INKEY
            Sleep 1
        Wend
    LOOP UNTIL INSTR(keysToCatch, k)
    GetKey2 = k
END FUNCTION

SUB opening(senario() As String)
    Dim k As String, nam As String
    CLS
    cp 4, "HOMELESSNESS - SURVIVING THE STREETS"
    cp 6, "A MIND SIMULATION GAME"
    cp 8, "by ronblue77 (ron77)"
    cp 10, "IMPORTENT NOTE:"
    cp 11, "THIS GAME COMES TO BRING TO AWARENESS THE PROBLEM OF HOMLESSNESS"
    cp 12, "I DO NOT MEAN TO MOCK OR INSULT ANYONE! PLEASE HELP PUT AN END TO HOMELESSNESS"
    cp 16, "press ESC to quit or ENTER key to play"
    k = GetKey2(CHR(27) + CHR(13))
    IF k = Chr(27) THEN
        cp 19, "GOODBYE!": END
        CLS
    END IF
    CLS
    LOCATE (6, 14): INPUT "enter name: ", nam
    'inputc 6, "enter nam: "

    PRINT nam + senario(INT(RND * UBOUND(senario) + 1)): PRINT
    PRINT "GOOD LUCK!"
    SLEEP
END Sub

SUB main (d2 As Integer, health2 As Integer, dollars2 As Integer, over2 As Integer,senario() AS String,status() AS String,action() AS String,home() AS STRING, shelter() AS STRING, money() AS STRING, job() AS String,drug() AS String)
    Dim As Integer i , x
    Dim As String ac, result
    Cls
    cp 1, "press ESC to quit"
    cp 2, "day: " + STR(d2) + " health (0-100%): " + STR(health2) + "%  money: " + Str(dollars2) + "$"
    LOCATE (4, 10):x = Int(Rnd*UBound(status)+1): Print status(x)' PRINT status(INT(RND * UBOUND(status) + 1))
    PRINT
    FOR i = 1 TO 5
        PRINT action(i): PRINT
    NEXT i
    second_choice:
    ac = GetKey2("12345" + CHR(27))
    IF ac = CHR(27) THEN over2 = -1: EXIT SUB
    IF ac = "1" THEN
        x = INT(RND * UBOUND(money)+1)
        result = money(x)
        'result = money(INT(RND * UBOUND(money) + 1))
        PRINT result
        IF result = money(4) THEN over2 = -1
        IF result = money(1) OR result = money(2) OR result = money(3) THEN dollars2 =+ 20: health2 =+ 25
    ELSEIF ac = "2" THEN
        x = INT(RND * UBOUND(shelter)+1)
        result = shelter(x)
        'result = shelter(INT(RND * UBOUND(shelter) + 1))
        PRINT result
        IF result = shelter(4) THEN over2 = -1
    ELSEIF ac = "3" THEN
        x = Int(Rnd* UBound(home)+1)
        result = home(x)
        'result = home(INT(RND * UBOUND(home) + 1))
        PRINT result
        IF result = home(5) THEN over2 = -1
    ELSEIF ac = "4" THEN
        If health2 > 20 THEN
            x = Int(Rnd* UBound(job)+1)
            result = job(x)
            'result = job(INT(RND * UBOUND(job) + 1))
            PRINT result
            IF result = job(2) THEN over2 = -1
        ELSE
            PRINT "NOBODY WILL HIYER YOU UNTIL YOUR HEALTH GETS BETTER CHOOSE OTHE OPTION": ac = "": GOTO second_choice
        END IF
    ELSEIF ac = "5" THEN
        IF dollars2 >= 20 THEN
            health2 =- 20
            x = Int(Rnd* UBound(drug)+1)
            result = drug(x)
            'result = drug(INT(RND * UBOUND(drug) + 1))
            PRINT result
            IF result = drug(4) THEN over2 = -1
        ELSE
            PRINT "YOU DON'T HAVE ENOUGH MONEY CHOOSE OTHER OPTION": ac = "": GOTO second_choice
        END IF
    END IF
    PRINT "press any key..."
    SLEEP
    PRINT
    finish:
    IF over2 = -1 THEN
        IF health2 <= 0 OR result = drug(4) OR result = shelter(4) OR result = money(4) THEN
            PRINT "YOU DIED ON THE STREETS - GAME OVER"
        ELSE
            PRINT "YOU SURVIVED THE STREETS - GAME OVER": PRINT
        END IF
        PRINT "YOU SURVIVED ON THE STREETS FOR: " + Str(d2) + " DAYS"
        SLEEP (3000)
        EXIT SUB
    ELSE
        d2 =+ 1
        dollars2 =- 10
        health2 =- 10
        IF health2 > 100 THEN health2 = 100
        IF dollars2 < 0 THEN dollars2 = 0
        IF health2 <= 0 THEN over2 = -1: GOTO finish
        CLS
        PRINT "press any key to continue to the nexy day"
        SLEEP
        CLS
    END IF
END Sub

SCREEN 0
Randomize Timer 
Dim Shared As String senario(1 TO 3),status(1 TO 3),action(1 TO 5),home(1 TO 6)
Dim Shared As String shelter(1 TO 6), money(1 TO 5), job(1 TO 3),drug(1 TO 4)
Dim Shared i As Integer, k2 As String
Dim Shared As Integer d,over,dollars,health
FOR i = 1 TO 3
    READ senario(i)
NEXT i
FOR i = 1 TO 3
    READ status(i)
NEXT i
FOR i = 1 TO 5
    READ action(i)
NEXT i
FOR i = 1 TO 6
    READ home(i)
NEXT i
FOR i = 1 TO 6
    READ shelter(i)
NEXT i
FOR i = 1 TO 5
    READ money(i)
NEXT i
FOR i = 1 TO 3
    READ job(i)
NEXT i
FOR i = 1 TO 4
    READ drug(i)
NEXT i


DO
    d = 1
    over = 0
    health = 50
    dollars = 20
    opening(senario())
    DO
        main (d,health, dollars,over,senario(),status(),action(),home(),shelter(), money(), job(),drug())


    LOOP UNTIL over = -1

    PRINT "play again? y/n?:"
    k2 = GetKey2("yn")
    IF LCASE(k2) = "n" THEN END
Loop

'senarios:
DATA " you are runaway teenager that run from home... you need to survive on the streets till you can find a home."
DATA " you are a middle age person who's wife filed for divorce and throwed you from your house... you live in your old car till you get a new place to live."
DATA " you are brock with no job and no family... you have been kick out of your home now you have to find a solution to your problem."

'status
DATA "it's morning rise and shine... you almost don't have any money and you are hungry"
DATA "it's noon you have been sitting and begging for change from passing people some have given you some money"
DATA "it's night you are tired and need to find a safe place to sleep"

'actions
DATA "press 1 to: go beg or look for food or money"
DATA "press 2 to: find help and/or shelter"
DATA "press 3 to: call from a street phone to a family member or a friend to ask for help"
DATA "press 4 to: try to find a job or work"
DATA "press 5 to: do drugs or drink alcohol to forget the pain suffering and loneliness"

'call home
DATA "you call your grandma and you both cry... she promises to try to get you some help... she sends you her love... you promise to keep in touch with her"
DATA "you call a friend and she gives you some money and lets you stay at her place for the night... you get to have a good shower some clean cloths and eat a good meal and your back on the streets again"
DATA "you call a number of a hot-line for aid to homeless persons... the come and pick you up give some food and shelter for the night you talk to a social worker and he gives you his number just in case you need it"
DATA "you call a relative but no one answers... you are left alone on the streets"
DATA "you call your family and they pick you up and let you stay for as long as you need... you are off the streets"
DATA "you call but there is no answer"

'help or shelter
DATA "you go to a shelter for homeless people... you are robed from you money by violent addicts... you succeed to run away from there and spend the rest of the night at a park crying"
DATA "you try to sleep at the park but you get arrested by a policeman... you spend few hours in jail where you are beaten by inmates... by morning you are on the street again"
DATA "you have enough money to rent a motel room for the night... you shower and wash you cloths and sleep in a warm bed and dream you have a home"
DATA "you sleep at the park on a bench where you freeze to death cause of the cold weather... you are now in heaven RIP"
DATA "you sleep on the street on a corner when you wake up you find a 20 dollar bill and a note that says 'may god help you this is the little i can do'"
DATA "you are arrested by the police and now instead surviving on the street you have to survive being in jail"

'beg for money
DATA "you sit for hours and people pass you by as if you are invisible then some kind lady comes and invite you to eat at a dinner on her expense... you talk with her for two hours and tell her your story... then she says 'bye'"
DATA "you sit at a corner and people give you coins and dollars you get enough money to go by for a few days"
DATA "you sit and some men offers you work for some money and a meal you accept... you go to his house and help him paint his house then he gives you 10 dollars and a home cocked meal"
DATA "no one gives you nothing! your hungry and you have no choice but to look for food in the garbage... you get sick... very sick and you die on the streets from food poison... RIP"
DATA "you sit all day for nothing nobody gives you anything"

'job
DATA "you try to find work but nobody is interested"
DATA "you find work as a dishwasher at a dinner after a week you can afford a place to call home. you are off the street!"
DATA "you find work but you are fired really quick"

'drugs and alcohol
DATA "you get drunk and stone from cheep alcohol and for a few hours you forget about all your problems"
DATA "you do cheep street drugs and you get sick and collapse on the street... you wake up at the hospital and when you are better you are out on the street again"
DATA "you get stones and passed out when you wake in the morning everything you had is gone - you gut mugged"
DATA "you do drugs and over dose and die on the streets RIP"
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: A MIND GAME SIMULATION (sketch)

Post by badidea »

If you change "k2" to "k2_" (or something else), it will probably work.

There seems to be a problem with the 32-bit assembler:

Code: Select all

hello.asm: Assembler messages:
hello.asm:50: Error: invalid use of register
Compilation failed.
I consider it a bug in the compiler. This code triggers it:

Code: Select all

Dim Shared k2 As String
k2 = "test"
(here: fbc 1.05.0 32-bit, fbc 1.05.0 64-bit ok, I should update, 2 releases behind)
ron77
Posts: 212
Joined: Feb 21, 2019 19:24

Re: A MIND GAME SIMULATION (sketch)

Post by ron77 »

hi everyone...

i tried making a change to the code - the thing is the program works and run i was able to compile and run it but there is something funny going on - the games end right away and before the bugs were that the days health and money stayed the same as day one and not changed in this code that i give the game ends immediately after day 1 regardless of the role of the game... something with the logic of the code isn't correct...

Code: Select all

#Lang "fb"

'_TITLE "HOMLESSNESS - A MIND SIMULATION V2.0"

Sub cp (row As integer, s As String)
	LOCATE (row, (80 - LEN(s)) / 2): PRINT s
END SUB

FUNCTION GetKey2 (keysToCatch As String)As String
	DIM k As String
	Do
		k = InKey
		WHILE LEN(k) = 0
			k = INKEY
			Sleep 1
		Wend
	LOOP UNTIL INSTR(keysToCatch, k)
	GetKey2 = k
END FUNCTION

SUB opening(senario() As String)
	Dim k As String, nam As String
	CLS
	cp 4, "HOMELESSNESS - SURVIVING THE STREETS"
	cp 6, "A MIND SIMULATION GAME"
	cp 8, "by ronblue77 (ron77)"
	cp 10, "IMPORTENT NOTE:"
	cp 11, "THIS GAME COMES TO BRING TO AWARENESS THE PROBLEM OF HOMLESSNESS"
	cp 12, "I DO NOT MEAN TO MOCK OR INSULT ANYONE! PLEASE HELP PUT AN END TO HOMELESSNESS"
	cp 16, "press ESC to quit or ENTER key to play"
	k = GetKey2(CHR(27) + CHR(13))
	IF k = Chr(27) THEN
		cp 19, "GOODBYE!": END
		CLS
	END IF
	CLS
	LOCATE (6, 14): INPUT "enter name: ", nam
	'inputc 6, "enter nam: "

	PRINT nam + senario(INT(RND * UBOUND(senario) + 1)): PRINT
	PRINT "GOOD LUCK!"
	SLEEP
END Sub

SUB main (senario() AS String,status() AS String,action() AS String,home() AS STRING, shelter() AS STRING, money() AS STRING, job() AS String,drug() AS String)
	Dim As Integer d2 = 1, health2 = 50, dollars2 = 20, over2 = 0
	Dim As Integer i , x
	Dim As String ac, result
	Do
		Cls
		cp 1, "press ESC to quit"
		cp 2, "day: " + STR(d2) + " health (0-100%): " + STR(health2) + "%  money: " + Str(dollars2) + "$"
		LOCATE (4, 10):x = Int(Rnd*UBound(status)+1): Print status(x)' PRINT status(INT(RND * UBOUND(status) + 1))
		PRINT
		FOR i = 1 TO 5
			PRINT action(i): PRINT
		NEXT i
		second_choice:
		ac = GetKey2("12345" + CHR(27))
		IF ac = CHR(27) THEN over2 = -1: EXIT SUB
		IF ac = "1" THEN
			x = INT(RND * UBOUND(money)+1)
			result = money(x)
			'result = money(INT(RND * UBOUND(money) + 1))
			PRINT result
			If result = money(4) THEN over2 = -1
			If result = money(1) OR result = money(2) OR result = money(3) THEN dollars2 =+ 20: health2 =+ 25
		
		ElseIf ac = "2" THEN
			x = INT(RND * UBOUND(shelter)+1)
			result = shelter(x)
			'result = shelter(INT(RND * UBOUND(shelter) + 1))
			PRINT result
			If result = shelter(4) THEN over2 = -1
		
		ElseIf ac = "3" THEN
			x = Int(Rnd* UBound(home)+1)
			result = home(x)
			'result = home(INT(RND * UBOUND(home) + 1))
			PRINT result
			If result = home(5) THEN over2 = -1
		ELSEIF ac = "4" THEN
			If health2 > 20 THEN
				x = Int(Rnd* UBound(job)+1)
				result = job(x)
				'result = job(INT(RND * UBOUND(job) + 1))
				PRINT result
				If result = job(2) THEN over2 = -1
			ELSE
				PRINT "NOBODY WILL HIYER YOU UNTIL YOUR HEALTH GETS BETTER CHOOSE OTHE OPTION": ac = "": GOTO second_choice
			END IF
		ELSEIF ac = "5" THEN
			IF dollars2 >= 20 THEN
				health2 =- 20
				x = Int(Rnd* UBound(drug)+1)
				result = drug(x)
				'result = drug(INT(RND * UBOUND(drug) + 1))
				PRINT result
				If result = drug(4) THEN over2 = -1
			ELSE
				PRINT "YOU DON'T HAVE ENOUGH MONEY CHOOSE OTHER OPTION": ac = "": GOTO second_choice
			END IF
		END IF
		PRINT "press any key..."
		SLEEP
		PRINT
		finish:
		IF over2 = -1 THEN
			IF health2 <= 0 OR result = drug(4) OR result = shelter(4) OR result = money(4) THEN
				PRINT "YOU DIED ON THE STREETS - GAME OVER"
			ELSE
				PRINT "YOU SURVIVED THE STREETS - GAME OVER": PRINT
			END IF
			PRINT "YOU SURVIVED ON THE STREETS FOR: " + Str(d2) + " DAYS"
			SLEEP (3000)
			EXIT SUB
		ELSE
			d2 =+ 1
			dollars2 =- 10
			health2 =- 10
			IF health2 > 100 THEN health2 = 100
			IF dollars2 < 0 THEN dollars2 = 0
			IF health2 <= 0 THEN over2 = -1: GOTO finish
			CLS
			PRINT "press any key to continue to the nexy day"
			SLEEP
			CLS
		END If
	Loop Until over2 = -1
END Sub

SCREEN 0
Randomize Timer
Dim Shared As String senario(1 TO 3),status(1 TO 3),action(1 TO 5),home(1 TO 6)
Dim Shared As String shelter(1 TO 6), money(1 TO 5), job(1 TO 3),drug(1 TO 4)
Dim Shared i As Integer, ky2 As String
'Dim Shared As Integer d,over,dollars,health
FOR i = 1 TO 3
	READ senario(i)
NEXT i
FOR i = 1 TO 3
	READ status(i)
NEXT i
FOR i = 1 TO 5
	READ action(i)
NEXT i
FOR i = 1 TO 6
	READ home(i)
NEXT i
FOR i = 1 TO 6
	READ shelter(i)
NEXT i
FOR i = 1 TO 5
	READ money(i)
NEXT i
FOR i = 1 TO 3
	READ job(i)
NEXT i
FOR i = 1 TO 4
	READ drug(i)
NEXT i


DO
	'd = 1
	'over = 0
	'health = 50
	'dollars = 20
	opening(senario())
	'DO
	main (senario(),status(),action(),home(),shelter(), money(), job(),drug())


	'LOOP UNTIL over = -1

	PRINT "play again? y/n?:"
	ky2 = GetKey2("yn")
	IF LCASE(ky2) = "n" THEN END
Loop

'senarios:
DATA " you are runaway teenager that run from home... you need to survive on the streets till you can find a home."
DATA " you are a middle age person who's wife filed for divorce and throwed you from your house... you live in your old car till you get a new place to live."
DATA " you are brock with no job and no family... you have been kick out of your home now you have to find a solution to your problem."

'status
DATA "it's morning rise and shine... you almost don't have any money and you are hungry"
DATA "it's noon you have been sitting and begging for change from passing people some have given you some money"
DATA "it's night you are tired and need to find a safe place to sleep"

'actions
DATA "press 1 to: go beg or look for food or money"
DATA "press 2 to: find help and/or shelter"
DATA "press 3 to: call from a street phone to a family member or a friend to ask for help"
DATA "press 4 to: try to find a job or work"
DATA "press 5 to: do drugs or drink alcohol to forget the pain suffering and loneliness"

'call home
DATA "you call your grandma and you both cry... she promises to try to get you some help... she sends you her love... you promise to keep in touch with her"
DATA "you call a friend and she gives you some money and lets you stay at her place for the night... you get to have a good shower some clean cloths and eat a good meal and your back on the streets again"
DATA "you call a number of a hot-line for aid to homeless persons... the come and pick you up give some food and shelter for the night you talk to a social worker and he gives you his number just in case you need it"
DATA "you call a relative but no one answers... you are left alone on the streets"
DATA "you call your family and they pick you up and let you stay for as long as you need... you are off the streets"
DATA "you call but there is no answer"

'help or shelter
DATA "you go to a shelter for homeless people... you are robed from you money by violent addicts... you succeed to run away from there and spend the rest of the night at a park crying"
DATA "you try to sleep at the park but you get arrested by a policeman... you spend few hours in jail where you are beaten by inmates... by morning you are on the street again"
DATA "you have enough money to rent a motel room for the night... you shower and wash you cloths and sleep in a warm bed and dream you have a home"
DATA "you sleep at the park on a bench where you freeze to death cause of the cold weather... you are now in heaven RIP"
DATA "you sleep on the street on a corner when you wake up you find a 20 dollar bill and a note that says 'may god help you this is the little i can do'"
DATA "you are arrested by the police and now instead surviving on the street you have to survive being in jail"

'beg for money
DATA "you sit for hours and people pass you by as if you are invisible then some kind lady comes and invite you to eat at a dinner on her expense... you talk with her for two hours and tell her your story... then she says 'bye'"
DATA "you sit at a corner and people give you coins and dollars you get enough money to go by for a few days"
DATA "you sit and some men offers you work for some money and a meal you accept... you go to his house and help him paint his house then he gives you 10 dollars and a home cocked meal"
DATA "no one gives you nothing! your hungry and you have no choice but to look for food in the garbage... you get sick... very sick and you die on the streets from food poison... RIP"
DATA "you sit all day for nothing nobody gives you anything"

'job
DATA "you try to find work but nobody is interested"
DATA "you find work as a dishwasher at a dinner after a week you can afford a place to call home. you are off the street!"
DATA "you find work but you are fired really quick"

'drugs and alcohol
DATA "you get drunk and stone from cheep alcohol and for a few hours you forget about all your problems"
DATA "you do cheep street drugs and you get sick and collapse on the street... you wake up at the hospital and when you are better you are out on the street again"
DATA "you get stones and passed out when you wake in the morning everything you had is gone - you gut mugged"
DATA "you do drugs and over dose and die on the streets RIP"
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: A MIND GAME SIMULATION (sketch)

Post by badidea »

=- -> -= & =+ -> += :-)
ron77
Posts: 212
Joined: Feb 21, 2019 19:24

Re: A MIND GAME SIMULATION (sketch)

Post by ron77 »

badidea!!! you were right! it should be += and -= and not =+ or =-!!!

thank you so much!!! now the game works as intended!!!

Code: Select all

#Lang "fb"

'_TITLE "HOMLESSNESS - A MIND SIMULATION V2.0"

Sub cp (row As integer, s As String)
	LOCATE (row, (80 - LEN(s)) / 2): PRINT s
END SUB

FUNCTION GetKey2 (keysToCatch As String)As String
	DIM k As String
	Do
		k = InKey
		WHILE LEN(k) = 0
			k = INKEY
			Sleep 1
		Wend
	LOOP UNTIL INSTR(keysToCatch, k)
	GetKey2 = k
END FUNCTION

SUB opening(senario() As String)
	Dim k As String, nam As String
	CLS
	cp 4, "HOMELESSNESS - SURVIVING THE STREETS"
	cp 6, "A MIND SIMULATION GAME"
	cp 8, "by ronblue77 (ron77)"
	cp 10, "IMPORTENT NOTE:"
	cp 11, "THIS GAME COMES TO BRING TO AWARENESS THE PROBLEM OF HOMLESSNESS"
	cp 12, "I DO NOT MEAN TO MOCK OR INSULT ANYONE! PLEASE HELP PUT AN END TO HOMELESSNESS"
	cp 16, "press ESC to quit or ENTER key to play"
	k = GetKey2(CHR(27) + CHR(13))
	IF k = Chr(27) THEN
		cp 19, "GOODBYE!": END
		CLS
	END IF
	CLS
	LOCATE (6, 14): INPUT "enter name: ", nam
	'inputc 6, "enter nam: "

	PRINT nam + senario(INT(RND * UBOUND(senario) + 1)): PRINT
	PRINT "GOOD LUCK!"
	SLEEP
END Sub

SUB main (senario() AS String,status() AS String,action() AS String,home() AS STRING, shelter() AS STRING, money() AS STRING, job() AS String,drug() AS String)
	Dim As Integer d2 = 1, health2 = 50, dollars2 = 20, over2 = 0
	Dim As Integer i , x
	Dim As String ac, result
	Do
		Cls
		cp 1, "press ESC to quit"
		cp 2, "day: " + STR(d2) + " health (0-100%): " + STR(health2) + "%  money: " + Str(dollars2) + "$"
		LOCATE (4, 10):x = Int(Rnd*UBound(status)+1): Print status(x)' PRINT status(INT(RND * UBOUND(status) + 1))
		PRINT
		FOR i = 1 TO 5
			PRINT action(i): PRINT
		NEXT i
		second_choice:
		ac = GetKey2("12345" + CHR(27))
		IF ac = CHR(27) THEN over2 = -1: EXIT SUB
		IF ac = "1" THEN
			x = INT(RND * UBOUND(money)+1)
			result = money(x)
			'result = money(INT(RND * UBOUND(money) + 1))
			PRINT result
			If result = money(4) THEN over2 = -1
			If result = money(1) OR result = money(2) OR result = money(3) THEN dollars2 += 20: health2 += 25
		
		ElseIf ac = "2" THEN
			x = INT(RND * UBOUND(shelter)+1)
			result = shelter(x)
			'result = shelter(INT(RND * UBOUND(shelter) + 1))
			PRINT result
			If result = shelter(4) THEN over2 = -1
		
		ElseIf ac = "3" THEN
			x = Int(Rnd* UBound(home)+1)
			result = home(x)
			'result = home(INT(RND * UBOUND(home) + 1))
			PRINT result
			If result = home(5) THEN over2 = -1
		ELSEIF ac = "4" THEN
			If health2 > 20 THEN
				x = Int(Rnd* UBound(job)+1)
				result = job(x)
				'result = job(INT(RND * UBOUND(job) + 1))
				PRINT result
				If result = job(2) THEN over2 = -1
			ELSE
				PRINT "NOBODY WILL HIYER YOU UNTIL YOUR HEALTH GETS BETTER CHOOSE OTHE OPTION": ac = "": GOTO second_choice
			END IF
		ELSEIF ac = "5" THEN
			IF dollars2 >= 20 THEN
				health2 -= 20
				x = Int(Rnd* UBound(drug)+1)
				result = drug(x)
				'result = drug(INT(RND * UBOUND(drug) + 1))
				PRINT result
				If result = drug(4) THEN over2 = -1
			ELSE
				PRINT "YOU DON'T HAVE ENOUGH MONEY CHOOSE OTHER OPTION": ac = "": GOTO second_choice
			END IF
		END IF
		PRINT "press any key..."
		SLEEP
		PRINT
		finish:
		IF over2 = -1 THEN
			IF health2 <= 0 OR result = drug(4) OR result = shelter(4) OR result = money(4) THEN
				PRINT "YOU DIED ON THE STREETS - GAME OVER"
			ELSE
				PRINT "YOU SURVIVED THE STREETS - GAME OVER": PRINT
			END IF
			PRINT "YOU SURVIVED ON THE STREETS FOR: " + Str(d2) + " DAYS"
			SLEEP (3000)
			EXIT SUB
		ELSE
			d2 += 1
			dollars2 -= 10
			health2 -= 10
			IF health2 > 100 THEN health2 = 100
			IF dollars2 < 0 THEN dollars2 = 0
			IF health2 <= 0 THEN over2 = -1: GOTO finish
			CLS
			PRINT "press any key to continue to the nexy day"
			SLEEP
			CLS
		END If
	Loop Until over2 = -1
END Sub

SCREEN 0
Randomize Timer
Dim Shared As String senario(1 TO 3),status(1 TO 3),action(1 TO 5),home(1 TO 6)
Dim Shared As String shelter(1 TO 6), money(1 TO 5), job(1 TO 3),drug(1 TO 4)
Dim Shared i As Integer, ky2 As String
'Dim Shared As Integer d,over,dollars,health
FOR i = 1 TO 3
	READ senario(i)
NEXT i
FOR i = 1 TO 3
	READ status(i)
NEXT i
FOR i = 1 TO 5
	READ action(i)
NEXT i
FOR i = 1 TO 6
	READ home(i)
NEXT i
FOR i = 1 TO 6
	READ shelter(i)
NEXT i
FOR i = 1 TO 5
	READ money(i)
NEXT i
FOR i = 1 TO 3
	READ job(i)
NEXT i
FOR i = 1 TO 4
	READ drug(i)
NEXT i


DO
	'd = 1
	'over = 0
	'health = 50
	'dollars = 20
	opening(senario())
	'DO
	main (senario(),status(),action(),home(),shelter(), money(), job(),drug())


	'LOOP UNTIL over = -1

	PRINT "play again? y/n?:"
	ky2 = GetKey2("yn")
	IF LCASE(ky2) = "n" THEN END
Loop

'senarios:
DATA " you are runaway teenager that run from home... you need to survive on the streets till you can find a home."
DATA " you are a middle age person who's wife filed for divorce and throwed you from your house... you live in your old car till you get a new place to live."
DATA " you are brock with no job and no family... you have been kick out of your home now you have to find a solution to your problem."

'status
DATA "it's morning rise and shine... you almost don't have any money and you are hungry"
DATA "it's noon you have been sitting and begging for change from passing people some have given you some money"
DATA "it's night you are tired and need to find a safe place to sleep"

'actions
DATA "press 1 to: go beg or look for food or money"
DATA "press 2 to: find help and/or shelter"
DATA "press 3 to: call from a street phone to a family member or a friend to ask for help"
DATA "press 4 to: try to find a job or work"
DATA "press 5 to: do drugs or drink alcohol to forget the pain suffering and loneliness"

'call home
DATA "you call your grandma and you both cry... she promises to try to get you some help... she sends you her love... you promise to keep in touch with her"
DATA "you call a friend and she gives you some money and lets you stay at her place for the night... you get to have a good shower some clean cloths and eat a good meal and your back on the streets again"
DATA "you call a number of a hot-line for aid to homeless persons... the come and pick you up give some food and shelter for the night you talk to a social worker and he gives you his number just in case you need it"
DATA "you call a relative but no one answers... you are left alone on the streets"
DATA "you call your family and they pick you up and let you stay for as long as you need... you are off the streets"
DATA "you call but there is no answer"

'help or shelter
DATA "you go to a shelter for homeless people... you are robed from you money by violent addicts... you succeed to run away from there and spend the rest of the night at a park crying"
DATA "you try to sleep at the park but you get arrested by a policeman... you spend few hours in jail where you are beaten by inmates... by morning you are on the street again"
DATA "you have enough money to rent a motel room for the night... you shower and wash you cloths and sleep in a warm bed and dream you have a home"
DATA "you sleep at the park on a bench where you freeze to death cause of the cold weather... you are now in heaven RIP"
DATA "you sleep on the street on a corner when you wake up you find a 20 dollar bill and a note that says 'may god help you this is the little i can do'"
DATA "you are arrested by the police and now instead surviving on the street you have to survive being in jail"

'beg for money
DATA "you sit for hours and people pass you by as if you are invisible then some kind lady comes and invite you to eat at a dinner on her expense... you talk with her for two hours and tell her your story... then she says 'bye'"
DATA "you sit at a corner and people give you coins and dollars you get enough money to go by for a few days"
DATA "you sit and some men offers you work for some money and a meal you accept... you go to his house and help him paint his house then he gives you 10 dollars and a home cocked meal"
DATA "no one gives you nothing! your hungry and you have no choice but to look for food in the garbage... you get sick... very sick and you die on the streets from food poison... RIP"
DATA "you sit all day for nothing nobody gives you anything"

'job
DATA "you try to find work but nobody is interested"
DATA "you find work as a dishwasher at a dinner after a week you can afford a place to call home. you are off the street!"
DATA "you find work but you are fired really quick"

'drugs and alcohol
DATA "you get drunk and stone from cheep alcohol and for a few hours you forget about all your problems"
DATA "you do cheep street drugs and you get sick and collapse on the street... you wake up at the hospital and when you are better you are out on the street again"
DATA "you get stones and passed out when you wake in the morning everything you had is gone - you gut mugged"
DATA "you do drugs and over dose and die on the streets RIP"
Post Reply