Python Forum
Two lines of code at the same time?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Two lines of code at the same time?
#1
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?
Reply
#2
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()
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Regular Expression search to comment lines of code Gman2233 5 1,593 Sep-08-2022, 06:57 AM
Last Post: ndc85430
  I want to simplify this python code into fewer lines, it's about string mandaxyz 5 2,046 Jan-15-2022, 01:28 PM
Last Post: mandaxyz
  python seems to be skipping lines of code alansandbucket 1 4,088 Jun-22-2021, 01:18 AM
Last Post: Larz60+
  More elegant way to remove time from text lines. Pedroski55 6 3,840 Apr-25-2021, 03:18 PM
Last Post: perfringo
  Running a few lines of code as soon as my timer ends nethatar 3 2,355 Feb-26-2021, 01:02 PM
Last Post: jefsummers
  Assistance with running a few lines of code at an EXACT time nethatar 5 3,166 Feb-24-2021, 10:43 PM
Last Post: nilamo
  Making new lines of code AvioxyYT 1 1,758 Jan-22-2021, 07:02 PM
Last Post: buran
  Stumped by my own code (ratio & epoch-time calculation). MvGulik 2 2,090 Dec-30-2020, 12:04 AM
Last Post: MvGulik
  Code taking too much time to process ErPipex 11 4,819 Nov-16-2020, 09:42 AM
Last Post: DeaD_EyE
  What is the run time complexity of this code and please explain? samlee916 2 2,258 Nov-06-2020, 02:37 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020