HelloLearnerC
HelloLearnerC

Reputation: 1

Can I do multiple processes using Threading in python to achieve a "Idle game" kind of code?

So I kind of want to create an idle game, but I can't figure out how to get the system of "Money per second" to work.

The idea is to have a main function that takes input from the user and another function that gives you money per second.

I tried using the Python threading module to achieve results in a seperate code, but unfortunatly it did not work as expected.

import time
import threading

def testing_main():
  print("Wait for meeee")
  wait = input()
  if wait == "True":
    print("wait")

def testing_side():
  print("Hi")

while True:
  t1 = threading.Thread(target=testing_main)
  t2 = threading.Thread(target=testing_side)
  if t1.is_alive() == False:
    t1.start()
    print("Thread is alive")
  t2.start()
  t2.join()

The idea is to have the side program running in the background while the main program waits for user input to do something.

Upvotes: 0

Views: 25

Answers (0)

Related Questions