Skip to content

Dikhya016/Typing_master

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This Python script appears to be a typing game where users are presented with a random paragraph to type as quickly as possible. The code has features like tracking the number of words typed, calculating typing speed in words per minute (WPM), and maintaining a leaderboard of players.

Here's an overview of the code:

1)Libraries Used:

-->keyboard: Used for handling keyboard inputs.

-->random: Used for choosing a random paragraph.

-->json: Used for reading and writing JSON data.

-->time and sleep: Used for tracking time and introducing delays.

-->threading: Used for creating and managing threads.

-->colorama: Used for adding color to console output.

2)Classes:

-->Player: Represents a player with attributes like name, words typed, start time, end time, and WPM.

3)Functions:

-->showLeaderBoard(): Displays the leaderboard with player statistics such as name, words, time, and WPM.

-->monitorForQuit(p1): Monitors for the 'Ctrl+Q' key press to end the game, calculates player stats, and updates the leaderboard.

-->getUserInput(p1): Main function where users type the displayed paragraph. The typing session is timed, and words are counted.

4)Main Loop:

-->The main loop allows players to enter their name, play the game, and then choose to play another game or quit.

-->The game data is saved in a JSON file ('scorecard.json') after each session.

5)File Operations:

-->Reads a paragraph from 'paragraph.txt'.

-->Reads and writes player data to a JSON file ('scorecard.json').

6)Color Coding:

-->Uses colorama to add color to console output for better visual representation.

7)Multi-Threading:

-->Uses threading to handle user input and monitor for game termination simultaneously.

8)Data Persistence:

-->Reads existing player data from 'scorecard.json' and updates it after each game.

9)Game Flow:

-->Players are prompted to enter their name.

-->A random paragraph is displayed, and players type it.

-->Typing session stats (words, time, WPM) are calculated and displayed.

-->Players can choose to play another game or quit.

10)Data Saving:

-->The final player data is saved to 'scorecard.json' after the game loop.

  • Error Handling:

-->The code includes basic error handling for file reading/writing.

  • User Interface:

-->Provides a simple console-based interface.

About

To develop a terminal-based typing test application. The application tests the user's typing speed by presenting a list of random words from a selected category and measures metrics like words per minute (WPM).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages