Quantcast
Viewing all articles
Browse latest Browse all 14185

Python, clicker game, coding of "passive income" , problems with Threading and time.sleep functions

I am trying to code a clicker game and already have a screen, a button to increase money and a upgrade to increase the money made with clicks. The whole thing is made in Tkinter.The next function i am now wanting to code is the passive income function for upgrades, which gives x money for every y seconds

def passive_income(moneygive,seconds):    global money    if True:        money += moneygive        time.sleep(seconds)

The problem with this is that it stops/delays the mainloop of the game while the time.sleep function, which is why i tried threading it

thread = threading.Thread(passive_income(10,10))thread.start()#before mainloop 

However this doesnt change anything and the thread also doesnt repeat. When i change the if statement to a while loop, the mainloop wont start.How can i code it so that, it doesnt break the mainloop?Thanks in advance


Viewing all articles
Browse latest Browse all 14185

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>