Two lines of code at the same time? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Two lines of code at the same time? (/thread-16543.html) |
Two lines of code at the same time? - OTO1012 - Mar-04-2019 I'm making a small game I want the player to press A quickly. I print this and was thinking of a timer going up and when 'A' is pressed the timer will stop if it is fast enough then they'll pass. Another idea was a timers set or a variable adds +1 and when at 10 they lose. But you can have simultaneous lines of code at a time? RE: Two lines of code at the same time? - ichabod801 - Mar-04-2019 You don't need to have simultaneous code. When the button is pressed, you just record how long it took them. Then you have a conditional (if statement) to see if the time was short enough for a pass, and then in the body of the conditional you can execute however many lines of code you want. if time_taken < maximum_time: do_something() do_another_thing() |