How to make a text detective game | python tutorial #1

Veröffentlicht am: 02 November 2025
auf dem Kanal: Trying to learn...
268
4

Basically the goal is to make a small game where users can move around, find clues, talk to the suspects, and in the end make the final choice of who is the murderer.


Starter scripts:

main.py

#simple, dialogue, items, people (randomized), rooms

print("\n\nDetective Game\n\n")

#libraries:
import random
import delayed_write as delay
import names

#testing
delay.log("hello world")
player_input = delay.inp("say hello")
delay.log(f"{player_input} was the input")

#classes:
class NPC:
def __init__(self, name, role="bystander", possessions=[]):
self.name = name
self.possessions = possessions
self.role = role

class Object:
def __init__(self, name, desc=""):
self.name = name
self.desc = desc


names.py

npc_names = ["Henry", "alex", "bob", "bill", "jones",
"mark", "phill", "Emily", "Logan", "tod",
"Peter", "nick"]

object_names = ["stone", "paper", "suitcase", "box",
"stick", "phone", "comb", "lipstick",
"glasses", "tape"]

delayed_write.py

import time
import threading

DELAY = 0.05

#timed print
def log(txt, delay=DELAY):
for t in txt:
print(t, end = "")
time.sleep(delay / 1)
if(t == "."):
time.sleep(delay * 2)
print()

#input with timeout
def inp(prompt, timeout = 5, delay=DELAY):
user_input = [None]

def input_thread():
log(prompt, delay)
user_input[0] = input()

input_thread = threading.Thread(target=input_thread)
input_thread.start()
input_thread.join(timeout)

if input_thread.is_alive():
return ""
else:
return user_input[0]


Auf dieser Seite können Sie das Online-Video How to make a text detective game | python tutorial #1 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Trying to learn... 02 November 2025 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 268 Mal angesehen und es wurde von 4 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!