import os import time import sys import pygame import msvcrt # Windows specific module for detecting keypresses pygame.init() pygame.mixer.init() RED = "\033[31m" GREEN = "\033[32m" YELLOW = "\033[33m" BLUE = "\033[34m" MAGENTA = "\033[35m" CYAN = "\033[36m" RESET = "\033[0m" knife = 1 gun = 1 ammo = 6 health = 100 hunger = 80 thirst = 60 gun_sound = pygame.mixer.Sound("gun.mp3") beep_sound = pygame.mixer.Sound("bleep010.wav") explo_sound = pygame.mixer.Sound("explo.mp3") fireball_sound = pygame.mixer.Sound("fireball.mp3") scream_sound = pygame.mixer.Sound("scream.mp3") blip_sound = pygame.mixer.Sound("blip.wav") def wait_for_enter(): input("\nPress enter to continue") def is_key_pressed(): """Check if a key is pressed (works only on Windows).""" return msvcrt.kbhit() and msvcrt.getch() == b'\\' def typewriter(text, speed=0.05): for char in text: if char != '\n': sys.stdout.write(char) sys.stdout.flush() beep_sound.play() time.sleep(speed) if is_key_pressed(): # Check for skip key press print("\nSkipping text...") return # Skip the rest of the dialogue print() # Ensure to print a newline after the typewriter effect finishes. def clear_console(): os.system('cls' if os.name == 'nt' else 'clear') clear_console() name = input(f"{RESET}ENTER A NAME: ") clear_console() typewriter(f"Hello, {name}!", 0.05) wait_for_enter() clear_console() typewriter(f"Welcome to LOST") wait_for_enter() clear_console() typewriter(f"I am the narrator and your friend in this world, but we need to lay some ground rules") wait_for_enter() clear_console() typewriter(f"First of all, you need to think about your actions, they can affect your relationships with others.") wait_for_enter() clear_console() typewriter(f"Second, you need to be aware of your CIGARETTES, they are your currency, your money of sorts. More CIGARETTES = more upgrades") wait_for_enter() clear_console() typewriter(f"Finally, the most important rule") wait_for_enter() clear_console() print(f"{RED}DONT") explo_sound.play() wait_for_enter() clear_console() print("TRUST") explo_sound.play() wait_for_enter() clear_console() print("ANYONE") fireball_sound.play() wait_for_enter() clear_console() typewriter(f"{BLUE}In the year 2145, the world as we knew it ceased to exist. The sky was torn apart by massive explosions, and the Earth trembled under the weight of humanity's mistakes. The great war, fueled by greed and the thirst for power, sparked the cataclysm that led to the downfall of civilization. Cities that once shone bright with progress now lay in ruins, their skeletons of steel and stone crumbling into the barren wasteland.", 0.01) wait_for_enter() clear_console() typewriter(f"The survivors? Few and far between. The vast majority of humanity was wiped out in the chaos, and those that remained became hardened, scarred by the relentless environment. The air is thick with the remnants of radiation, and toxic winds sweep across the land. Once-thriving landscapes have now turned to dust, and what remains of nature struggles to grow amidst the ruins.", 0.01) wait_for_enter() clear_console() typewriter(f"In the aftermath of the war, strange creatures roam the wastelands—mutants twisted by the radiation, and beasts born from the nightmares of a broken world. But the monsters are not the only threat. Survivors, once kind and hopeful, now fight for every scrap of food, water, and shelter. Bandits and raiders have formed brutal factions, each one claiming territory and preying on the weak. Trust is a luxury few can afford.", 0.01) wait_for_enter() clear_console() typewriter(f"You, {name}, awaken in the aftermath of the world's greatest tragedy. Your past is a blur, and the world around you is nothing but hostile terrain filled with the echoes of what was once a thriving civilization. Your journey begins in a desert. The survivors here are desperate, struggling to fend off constant monster attacks and fend for themselves in the harsh landscape.", 0.01) wait_for_enter() clear_console() typewriter(f"Blood is on your hands, and some sort of mutant is trying to munch on your skin. There is minimal time left before you are cut open.", 0.05) while True: try: decide = int(input(f"{GREEN}Grab your handgun (1), Grab your pocket knife (2), Kick away (3): ")) except ValueError: print("Invalid choice. Please enter a number.") continue # Restart the loop if the user doesn't enter a valid number if decide == 1: typewriter(f"You grab your handgun next to you") print("BANG") gun_sound.play() typewriter(f"...") wait_for_enter() clear_console() typewriter(f"Every mutant close by heard it") typewriter(f"You are mauled by all beings") wait_for_enter() clear_console() health = 0 pygame.mixer.music.load("scream.mp3") pygame.mixer.music.set_volume(0.5) print(f"{YELLOW}Thirst is:", thirst) print("Hunger is:", hunger) print("Health is:", health) print(f"{RED}GAME") time.sleep(0.5) print("OVER") pygame.mixer.music.play(1) time.sleep(2) pygame.mixer.music.stop() pygame.mixer.music.set_volume(1) break elif decide == 2: typewriter(f"You grab your trusty pocket knife, slashing at this mutant. you kill it but your knife dulls, you cant use it until you fix it.") knife = 0 print(f"{YELLOW}Thirst is:", thirst) print("Hunger is:", hunger) print("Health is:", health) time.sleep(1) print(f"{BLUE}-1 knife, +1 broken knife") blip_sound.play() time.sleep(1) break elif decide == 3: typewriter(f"You kick away the mutant, and start running. Luckily you outrun it, you find your way towards a gas station") stationfind = 1 print(f"{YELLOW}Thirst is:", thirst) print("Hunger is:", hunger) print("Health is:", health) wait_for_enter() clear_console() break else: print("Invalid choice. Please enter 1, 2, or 3.") if health < 1: print("Try again") elif decide == 2: typewriter(f"You cant wait here any longer, I advise you look for shelter") while True: try: decide = int(input("Find shelter? (1) stay put? (2) ")) except ValueError: print("Please enter a number") continue if decide == 1: typewriter(f"You find an old abandoned gas station, the door is unlocked! you eat and drink water.") hunger = 100 health = 100 thirst = 100 print(f"{YELLOW}Thirst is:", thirst) print("Hunger is:", hunger) print("Health is:", health) while True: try: decide = input("Look around the store? Y/N") except ValueError: print("Please enter a number") continue if decide == "y": ciggarettes = 8 typewriter(f"You find 8 CIGGARETTES on the counter!") print("Plus 8 CIGGARETTES") print("Your total is now:", ciggarettes) if decide == 2: typewriter(f"You decide to wait for someone to rescue you,") thirst = thirst - 20 hunger = hunger - 20 print(f"{YELLOW}Thirst is:", thirst) print("Hunger is:", hunger) print("Health is:", health) while True: try: decide = int(input(f"{GREEN}Shout out for help (1) stay put (2) ")) except ValueError: print("Please enter a number") continue if decide == 1: typewriter(f"All of the mutants in the valley hear you, you get mauled to death") health = 0 pygame.mixer.music.load("scream.mp3") pygame.mixer.music.set_volume(0.5) print(f"{YELLOW}Thirst is:", thirst) print("Hunger is:", hunger) print("Health is:", health) print(f"{RED}GAME") time.sleep(0.5) print("OVER") pygame.mixer.music.play(1) time.sleep(2) pygame.mixer.music.stop() pygame.mixer.music.set_volume(1) break if decide == 2: typewriter(f"Your body is cooking under the desert heat, but you stay still, waiting for rescue.") wait_for_enter() clear_console() thirst = 0 pygame.mixer.music.load("scream.mp3") pygame.mixer.music.set_volume(0.5) print(f"{YELLOW}Thirst is:", thirst) print("Hunger is:", hunger) print("Health is:", health) print(f"{RED}GAME") time.sleep(0.5) print("OVER") pygame.mixer.music.play(1) time.sleep(2) pygame.mixer.music.stop() pygame.mixer.music.set_volume(1) time.sleep(999)