Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
homeless - a GAME
#1
hello everyone...

here is my other game "homeless - surviving the street" a scenario text based game where you as the player have to survive being homeless on the streets and try to get off and find a job or a home...

it's an educative game to bring awareness to homelessness...

here is the code:

import os
import random


def clear(): return os.system('cls')


width = os.get_terminal_size().columns


def opening():
    story = ["YOU ARE A RUNAWAY TEENAGER FROM A BROKEN HOME YOU NEED TO LEARN HOW TO SURVIVE THE STREET AND GET OFF THEM AS SOON AS POSSIBLE",
             "YOU ARE A BROKEN PERSON WHO IS BROKE YOU NEED TO TRY AND START OVER AGAIN", "YOU HAD A LIFE AND A FAMILY BUT ADDICTION HAS TOOK EVERYTHING YOU GOT... NOW YOU ARE FIGHTING FOR GETTING BACK TO THE LIGHT"]

    print("HOMELESS - SURVIVING THE STREET!".center(width))
    print("A SAD GAME BY RONBLUE77".center(width))
    print("PLEASE HELP PUT AN END TO HOMELESSNESS".center(width))
    a = input()
    clear()
    print(random.choice(story))
    a = input()
    clear()


def game(in_game, health, money, days):
    # while in_game == True:
    senario = ["RISE AND SHINE IT'S MORNING AND YOU ARE HUNGREY",
               "YOU HAVE BEEN BEGGING FOR CHANGE ALL DAY", "IT'S NIGHT AND IT'S TIME TO FIND SOMEWHERE SAFE TO SLEEP"]

    choices = ["1. go beg for money or or look for food", "2. try to find a safe place for sleep",
               "3. call someone for help", "4. try to find work or a job", "5. fuck it! let's buy drugs or alcohol"]

    begging = ["A KIND LADY OFARED YOU A MEAL AT A DINER ON HER EXPENCE... YOU TALK FOR TWO HOURS AND YOU TELL HER YOUR LIFE STORY... SHE GIVES YOU 20 DOLLARS AND YOU SAY GOODBYE", "YOU BEG FOR MONEY ON THE STREET BUT PEOPLE PASS YOU BY LIKE YOU ARE INVISIBLE",
               "YOU TRY TO FIND FOOD IN A DUMPSTER AND GET SEVIERE FOOD POISENING YOU GET SICK AND YOU DIE ON THE STREET", "PEOPLE GIVE YOU SOME MONEY AND FOOD SO YOU GET WHAT YOU NEED FOR THE DAY"]

    shelter = ["YOU FIND SHELTER SOMEWHERE WARM AND GO TO SLEEP TILL THE NEXT DAY",
               "YOU DO TO A HOMLESS SHELTER AND EVERYTHING YOU GOT IS STOLEN", "YOU SLEEP AT THE PARK BENCH AND YOU FREEZE TO DEATH FROM THE COLD RIP"]

    phone = ["YOU CALL YOUR GRANDMA AND YOU BOTH CRY... SHE PROMISE TO TRY TO HELP YOU SOMEHOW AND SHE SENDS HER LOVE... THE CALL ENDS AND YOUR ALONE AGAIN ON THE STREETS", "YOU CALL A RELETIVE BUT THERE IS NO ANSWER", "YOU A HOT LINE FOR THE HOMELESS A CAR COMES AND THEY GIVE YOU HOT COFFEE AND A SOCHIAL WORKER GIVES YOU HER NUMBER JUST IN CASE",
             "YOU CALL A FRIEND AND SHE PICKES YOU UP AND LET HER STAY FOR THE NIGHT AT HER PLACE... WARM SHOWER HOME MADE COOKED MEAL AND A WOEM BED... BY MORNING YOU ARE BACK ON THE STREET", "YOU CALL YOUR FAMILY AND THEY COME AND TAKE YOU HOME... FINALLY YOUR OFF THE STREET"]

    job = ["YOU LOOK FOR WORK OR A JOB BUT NO ONES INTRESTED", "YOU FIND A JOB BUT THEY FAIR YOU QUICK",
           "YOU FIND A JOB! AFTER A TWO WEEKS YOU CAN PAY FOR A PLACE OF YOUR OWN! YOU ARE OFF THE STREET"]

    drugs = ["YOU GET DRUNK AND FOR A FEW HOURS FORGET ABOUT YOUR TROUBLES", "YOU GET HI AND GET OVER DOSE YOU ARE RUSHED TO THE HOSPITAL WHERE THEY SAVE YOUR LIFE NEXT DAY YOUR BACK AT THE STREETS",
             "YOU GET SICK FROM BAD ACID DRUG AND YOU OVER DOSE AND DIE ON THE STREETS RIP"]

    while in_game == True:
        print("HEALTH " + str(health) + "% MONEY: " +
              str(money) + "$ DAYS: " + str(days)+"".center(width))

        print(random.choice(senario))

        for i in choices:
            print()
            print(i)

        ans = input("select number of action 1-5: ")

        if int(ans) == 1:
            x = random.randint(0, 3)
            print(begging[x])

            if x == 2:
                in_game = False
                print("game over")
                # break
            elif x == 0 or x == 3:
                health += 30
                money += 25
        elif int(ans) == 2:
            i = random.randint(0, 2)
            print(shelter[i])
            if i == 3:
                in_game = False
                print("game over")
        elif int(ans) == 3:
            p = random.randint(0, 4)
            print(phone[p])
            if p == 4:
                in_game = False
                print("game over")
        elif int(ans) == 4:
            if health < 40:
                print("YOU ARE NOT HEALTHY ENOUGH TO WORK!")
            else:
                w = random.randint(0, 2)
                print(job[w])
                if w == 2:
                    in_game = False
                    print("game over")
        elif int(ans) == 5:
            if money < 20:
                print("YOU DON'T HAVE ENOGHT MONEY FOR THAT")
            else:
                d = random.randint(0, 2)
                print(drugs[d])
                if d == 2:
                    in_game = False
                    print("game over")
        health -= 10
        money -= 10
        days += 1
        if money <= 0:
            money = 0
        if health <= 0:
            in_game = False
            print("YOU DIED ON THE STREET FROM BAD HEALTH AND DESISESS! GAME OVER!")
        if in_game == False:
            print("YOU SURVIVED " + str(days) + " DAYS ON THE STREETS")
        a = input()
        clear()


def main():
    while True:
        health = 50
        money = 40
        days = 1
        in_game = True
        opening()
        game(in_game, health, money, days)
        play = input("play again? (y/n): ")
        if play.lower() == 'n':
            break
            # exit()


if __name__ == main():
    main()
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020