Game written in Python Computer Language

Hi, fellow programmers today i will be showing you Fast Draw Game written in Python Computer Language. This project is very useful for mid-level programmers, CBSE Computer science and Engineering students. Python is the most sought after skill in the IT job market and it is very necessary to read and understand it.

Theory : Game written in Python Computer Language

This game named Fast Draw check reflexes as the press is shown on the screen we have to press ENTER Button as soon as possible. When you see “PRESS”, you have 0.3 seconds to press Enter. But you lose if you press Enter before “Press” appears.

Step by Step Guide: Game written in Python Computer Language

1. Basic Instructions of game is published.
2.It returns when enter is pressed.
3.If the player pressed Enter before Press! appeared it show error message given in the program.
4.Quit is written to quit the game.

Source code :

"""Game,Fast Press, by Archit
 This game check reflexes as the press is shown on the screen we have to press
 ENTER Button. 
  Tags: tiny, beginner, game"""
 
import random, sys, time
 
print('Game Fast Press, by Archit')
print()
print('Time to test your reflexes and Find if you are the fastest')
print('Press in the west!')
print('When you see "PRESS", you have 0.3 seconds to press Enter.')
print('But you lose if you press Enter before "Press" appears.')
print()
input('Press Enter to begin...')

while True:
    print()
    print('It is high noon...')
    time.sleep(random.randint(20, 50) / 20.0)
    print('Press!')
    PressTime = time.time()
    input() # This function call doesnot return until Enter is Pressed.
    timeElapsed = time.time() - PressTime
    if timeElapsed < 0.01:
        # If the player pressed Enter before Press! appeared, the input()
        # call returns almost instantly
        print('You drew before "Press" appeared! You lose.')
    elif timeElapsed > 0.3:
        timeElapsed = round(timeElapsed, 4)
        print('You took', timeElapsed, 'seconds to Press. Too slow!')
    else:
        timeElapsed = round(timeElapsed, 4)
        print('You took', timeElapsed, 'seconds to Press.')
        print('You are the fastest Press in the west! You win!')
    print('If you want to quit the game then Enter QUIT to stop, or press Enter to play again.')
    response = input('> ').upper()
    if response == 'QUIT':
        print('Thanks for playing!')
        sys.exit()

Output:

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license()” for more information.

RESTART: C:/Users/ARCHIT/AppData/Local/Programs/Python/Python37-32/Game25fastdraw.py
Game Fast Press, by Archit

Time to test your reflexes and Find if you are the fastest
Press in the west!
When you see “PRESS”, you have 0.3 seconds to press Enter.
But you lose if you press Enter before “Press” appears.

Press Enter to begin…

It is high noon…
Press!

You took 0.3881 seconds to Press. Too slow!
If you want to quit the game then Enter QUIT to stop, or press Enter to play again.

It is high noon…
Press!
You drew before “Press” appeared! You lose.
If you want to quit the game then Enter QUIT to stop, or press Enter to play again.

It is high noon…
Press!

You took 0.3624 seconds to Press. Too slow!
If you want to quit the game then Enter QUIT to stop, or press Enter to play again.

Conclusion:

This program is running fine.

Thank you for reading and copying from the project . For more programs like this click below link.
Python Programs Archives – CS Study

Leave a Comment

Your email address will not be published.