Can you run two loops at the same time in python?

Asked

Viewed 1,219 times

3

I’ve been wanting to make a kind of game that you go shopping for some things that help you make a profit, and you would have a sum that you earned per second, but I don’t know if there’s any way I can run two loops(one to interact with the player and the other to add an amount of money to the player per second) in python, if anyone knows, can help me?

  • 1

    You can have a single loop and embed a state machine, in the first state you interact with the player and in the second care adds the money; making fast will give the feeling that it is simultaneous -- is how several games do.

  • 1

    It’s an interesting question because it raises some questions like - use threads? Simulate competition using other techniques?

  • 1

    You can use recursiveness, either within the other or two functions, one with each for... There are many possibilities.

1 answer

-1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.