Game Title: Typing Speed Game
Team Members:
Team Members:
Roles:
- Sai Raju: HTML Structure
- Abinaya: CSS Styling & Visual Design
- Reshman Nagendra: JavaScript Game Logic & Programming Concepts
Typing Speed Game is an interactive browser-based typing speed game that tests players' typing accuracy and speed. Players are challenged to type displayed words as quickly and accurately as possible within a 60-second time limit. The game features three difficulty levels (Easy, Medium, Hard), real-time statistics tracking, and a local leaderboard system.
- Type displayed words correctly within 60 seconds
- Achieve the highest WPM (Words Per Minute) score
- Maintain high accuracy throughout the game
- Compete for top positions on the leaderboard
-
Select Difficulty:
- Choose from Easy, Medium, or Hard difficulty levels
- Each level features different word complexities
-
Start the Game:
- Click the "Start Game" button
- A 60-second timer begins counting down
-
Type the Words:
- Type the displayed words in the typing input field
- Words turn green when typed correctly, red when incorrect
- Press Space to continue to next word
-
Track Your Progress:
- Monitor your real-time WPM, accuracy, and score
- Watch the timer countdown at the top
-
Game Over:
- Review your final statistics
- Save your score to the leaderboard
- Choose to play again or return to menu
- Three Difficulty Levels: Easy (short words), Medium (moderate words), Hard (complex words)
- 60-Second Timed Gameplay: Countdown timer with visual progress bar
- Real-Time Statistics:
- WPM (Words Per Minute) calculation
- Accuracy percentage tracking
- Score system with difficulty-based points
- Time remaining display
- Visual Feedback: Color-coded word display (green for correct, red for incorrect)
- Menu System: Start screen with difficulty selection and instructions
- Game Over Screen: Detailed statistics and replay options
- Leaderboard System: Local storage-based score tracking and display
- Player Name Saving: Dialog for saving scores with player names
- Responsive Design: Works on desktop and mobile devices
- Easy Mode: 10 points per correct word
- Medium Mode: 15 points per correct word
- Hard Mode: 25 points per correct word
- Numbers:
wpm,accuracy,score,timeLeft,currentWordIndex - Strings:
difficulty,playerName,typedText,gameState - Booleans: Used in conditional logic for game state checks
- Arrays:
words[], word lists for each difficulty level - Objects: Score objects stored in leaderboard with multiple properties
- Arithmetic:
wpm = Math.round(correctWords / timeElapsed),score += points,timeLeft-- - Logical:
&&(AND),||(OR) in conditional statements - Relational:
>,<,===,!==for comparisons - Assignment:
=,+=,-=
- if/else: Game state management, word validation, score calculation
- Switch-case equivalent: Difficulty-based point assignment
- Ternary operators: Color class assignment based on conditions
- For loops:
- Array iteration in
renderWords()function - Character-by-character word comparison
- Fisher-Yates shuffle algorithm for word randomization
- Array iteration in
- While loops: Conceptually used in timer interval
- forEach loops: Leaderboard rendering, DOM manipulation
- Character validation: Nested loop structure comparing typed characters with target word
for (let i = 0; i < typed.length; i++) { if (typed[i] !== word[i]) { isCorrectSoFar = false; break; } }
- Word shuffling algorithm: Nested randomization logic
init()- Initialize game on page loadloadWords()- Load and shuffle word listsselectDifficulty()- Change difficulty levelstartGame()- Start new game sessionhandleTyping()- Process user inputrenderWords()- Display words dynamicallyupdateStats()- Calculate and update statisticsendGame()- End game and show resultssaveScore()- Save player score to localStorageloadLeaderboard()- Retrieve and display leaderboardshowScreen()- Manage screen transitions
- Arrays:
words[]- Stores current game word listwordLists.easy[],wordLists.medium[],wordLists.hard[]- Word librariesscores[]- Leaderboard data
- Objects:
wordLists{}- Object containing difficulty-based word arrays- Score objects with properties:
id,player_name,wpm,accuracy,score,difficulty,timestamp
- Creating elements:
document.createElement('span'),document.createElement('div') - Modifying elements:
element.textContent,element.innerHTML,element.style.width - Adding/removing classes:
classList.add(),classList.remove() - Attribute manipulation:
setAttribute('data-testid', value) - Dynamic rendering: Words display, leaderboard entries
- Input events:
inputevent on typing field - Click events: Button clicks for navigation and actions
- Keyboard events:
keypressfor Enter key detection - Page load events:
DOMContentLoadedfor initialization
- Intervals & Timers:
setInterval(),clearInterval()for countdown - Local Storage:
localStorage.setItem(),localStorage.getItem()for persistence - JSON:
JSON.parse(),JSON.stringify()for data storage - Array Methods:
filter(),sort(),slice(),forEach(),map() - String Methods:
trim(),charAt(),toUpperCase(),slice() - Math Operations:
Math.round(),Math.floor(),Math.random() - Date/Time:
Date.now(),new Date().toISOString()
Problem: Calculating accurate WPM while the game is in progress without causing performance issues.
Solution: Implemented time-based calculation using Date.now() to track elapsed time in milliseconds, converting to minutes, and dividing correct words by elapsed time. Used Math.round() to display whole numbers.
Problem: Needed to track accuracy at the character level, even for incorrectly typed words.
Solution: Created nested loop logic that compares each character of the typed word against the target word, incrementing correctCharacters for matches even in overall incorrect words.
Problem: Providing real-time visual feedback as users type, showing if they're on the right track.
Solution: Implemented color-coding system in renderWords() function that:
- Shows grey for upcoming words
- Shows green when typing matches correctly
- Shows red when typing has errors
- Shows light grey for completed words
Problem: Smoothly transitioning between menu, playing, and game over states without bugs.
Solution: Created showScreen() function that hides all screens first, then displays only the target screen. Used gameState variable to track current state and prevent conflicts.
Problem: Storing and retrieving leaderboard data that persists across browser sessions.
Solution: Used localStorage API with JSON serialization. Implemented sorting and filtering logic to display top 10 scores per difficulty level.
Problem: Ensuring timer stops properly when game ends and doesn't continue in background.
Solution: Stored interval reference in timerInterval variable and used clearInterval() when ending game. Added checks to prevent multiple timers running simultaneously.
TypeSpeed_Game/
├── index.html # Main HTML structure
├── style.css # Complete styling and animations
├── script.js # All game logic and functionality
├── README.md # This documentation file
├── Flowchart.md #
- Download all files (index.html, style.css, script.js)
- Place all files in the same folder
- Open index.html in any modern web browser (Chrome, Firefox, Safari, Edge)
- No server required - Game runs entirely in the browser
- Internet connection needed only for loading Google Fonts
- HTML5 - Semantic structure and markup
- CSS3 - Modern styling with gradients, animations, and responsive design
- JavaScript (ES6+) - Game logic, DOM manipulation, and event handling
- LocalStorage API - Data persistence for leaderboard
- Google Fonts - Space Grotesk and Inter font families
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
- Multiplayer mode with real-time competition
- More difficulty levels and custom word lists
- Sound effects and background music
- Achievements and badges system
- Practice mode without time limit
- Statistics graphs and progress tracking over time
- Dark mode theme option
- Social sharing of scores
Fonts: Google Fonts (Space Grotesk, Inter)
Design Inspiration: Modern typing test applications
Color Palette: Teal/Cyan gradient theme for calm, focused typing experience
you can view the game live at