1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282# Event-Driven Programming - Build a Typing Game
```mermaid
journey
title Your Typing Game Development Journey
section Foundation
Plan game structure: 3: Student
Design user interface: 4: Student
Setup HTML elements: 4: Student
section Functionality
Handle user input: 4: Student
Track timing: 5: Student
Calculate accuracy: 5: Student
section Features
Add visual feedback: 5: Student
Implement game logic: 5: Student
Polish experience: 5: Student
```
## Introduction
Here's something every developer knows but rarely talks about: typing fast is a superpower! ๐ Think about it - the faster you can get your ideas from your brain to your code editor, the more your creativity can flow. It's like having a direct pipeline between your thoughts and the screen.
```mermaid
pie title Game Features
"Real-time Feedback" : 25
"Performance Tracking" : 20
"Interactive UI" : 20
"Timer System" : 15
"Quote Management" : 10
"Results Display" : 10
```
Want to know one of the best ways to level up this skill? You guessed it - we're going to build a game!
```mermaid
flowchart LR
A[Player starts game] --> B[Random quote displayed]
B --> C[Player types characters]
C --> D{Character correct?}
D -->|Yes| E[Green highlight]
D -->|No| F[Red highlight]
E --> G[Update accuracy]
F --> G
G --> H{Quote complete?}
H -->|No| C
H -->|Yes| I[Calculate WPM]
I --> J[Display results]
J --> K[Play again?]
K -->|Yes| B
K -->|No| L[Game over]
style A fill:#e1f5fe
style D fill:#fff3e0
style E fill:#e8f5e8
style F fill:#ffebee
style I fill:#f3e5f5
```
> Let's create an awesome typing game together!
Ready to put all those JavaScript, HTML, and CSS skills you've been learning to work? We're going to build a typing game that'll challenge you with random quotes from the legendary detective [Sherlock Holmes](https://en.wikipedia.org/wiki/Sherlock_Holmes). The game will track how fast and accurately you can type - and trust me, it's more addictive than you might think!
```mermaid
mindmap
root((Typing Game Development))
User Interface
Input Elements
Visual Feedback
Responsive Design
Accessibility
Game Logic
Quote Selection
Timer Management
Accuracy Tracking
Score Calculation
Event Handling
Keyboard Input
Button Clicks
Real-time Updates
Game State Changes
Performance Metrics
Words Per Minute
Character Accuracy
Error Tracking
Progress Display
User Experience
Immediate Feedback
Clear Instructions
Engaging Content
Achievement System
```

## What You'll Need to Know
```mermaid
flowchart TD
A[User Action] --> B{Event Type?}
B -->|Key Press| C[Keyboard Event]
B -->|Button Click| D[Mouse Event]
B -->|Timer| E[Time Event]
C --> F[Check Character]
D --> G[Start/Reset Game]
E --> H[Update Timer]
F --> I{Correct?}
I -->|Yes| J[Highlight Green]
I -->|No| K[Highlight Red]
J --> L[Update Score]
K --> L
L --> M[Check Game State]
G --> N[Generate New Quote]
H --> O[Display Time]
M --> P{Game Complete?}
P -->|Yes| Q[Show Results]
P -->|No| R[Continue Game]
style A fill:#e1f5fe
style F fill:#e8f5e8
style I fill:#fff3e0
style Q fill:#f3e5f5
```
Before we dive in, make sure you're comfortable with these concepts (don't worry if you need a quick refresher - we've all been there!):
- Creating text input and button controls
- CSS and setting styles using classes
- JavaScript basics
- Creating an array
- Creating a random number
- Getting the current time
If any of these feel a bit rusty, that's totally fine! Sometimes the best way to solidify your knowledge is by jumping into a project and figuring things out as you go.
### ๐ **Pedagogical Check-in**
**Foundation Assessment**: Before starting development, ensure you understand:
- โ
How HTML forms and input elements work
- โ
CSS classes and dynamic styling
- โ
JavaScript event listeners and handlers
- โ
Array manipulation and random selection
- โ
Time measurement and calculations
**Quick Self-Test**: Can you explain how these concepts work together in an interactive game?
- **Events** trigger when users interact with elements
- **Handlers** process those events and update game state
- **CSS** provides visual feedback for user actions
- **Timing** enables performance measurement and game progression
```mermaid
quadrantChart
title Typing Game Skills Development
x-axis Beginner --> Expert
y-axis Static --> Interactive
quadrant-1 Advanced Games
quadrant-2 Real-time Apps
quadrant-3 Basic Pages
quadrant-4 Interactive Sites
HTML Forms: [0.3, 0.2]
CSS Styling: [0.4, 0.3]
Event Handling: [0.7, 0.8]
Game Logic: [0.8, 0.9]
Performance Tracking: [0.9, 0.7]
```
## Let's Build This Thing!
[Creating a typing game by using event driven programming](./typing-game/README.md)
### โก **What You Can Do in the Next 5 Minutes**
- [ ] Open your browser console and try listening for keyboard events with `addEventListener`
- [ ] Create a simple HTML page with an input field and test typing detection
- [ ] Practice string manipulation by comparing typed text with target text
- [ ] Experiment with `setTimeout` to understand timing functions
### ๐ฏ **What You Can Accomplish This Hour**
- [ ] Complete the post-lesson quiz and understand event-driven programming
- [ ] Build a basic version of the typing game with word validation
- [ ] Add visual feedback for correct and incorrect typing
- [ ] Implement a simple scoring system based on speed and accuracy
- [ ] Style your game with CSS to make it visually appealing
### ๐
**Your Week-Long Game Development**
- [ ] Complete the full typing game with all features and polish
- [ ] Add difficulty levels with varying word complexity
- [ ] Implement user statistics tracking (WPM, accuracy over time)
- [ ] Create sound effects and animations for better user experience
- [ ] Make your game mobile-responsive for touch devices
- [ ] Share your game online and gather feedback from users
### ๐ **Your Month-Long Interactive Development**
- [ ] Build multiple games exploring different interaction patterns
- [ ] Learn about game loops, state management, and performance optimization
- [ ] Contribute to open source game development projects
- [ ] Master advanced timing concepts and smooth animations
- [ ] Create a portfolio showcasing various interactive applications
- [ ] Mentor others interested in game development and user interaction
## ๐ฏ Your Typing Game Mastery Timeline
```mermaid
timeline
title Game Development Learning Progression
section Setup (10 minutes)
Project Structure: HTML foundation
: CSS styling setup
: JavaScript file creation
section User Interface (20 minutes)
Interactive Elements: Input fields
: Button controls
: Display areas
: Responsive layout
section Event Handling (25 minutes)
User Interaction: Keyboard events
: Mouse events
: Real-time feedback
: State management
section Game Logic (30 minutes)
Core Functionality: Quote generation
: Character comparison
: Accuracy calculation
: Timer implementation
section Performance Tracking (35 minutes)
Metrics & Analytics: WPM calculation
: Error tracking
: Progress visualization
: Results display
section Polish & Enhancement (45 minutes)
User Experience: Visual feedback
: Sound effects
: Animations
: Accessibility features
section Advanced Features (1 week)
Extended Functionality: Difficulty levels
: Leaderboards
: Custom quotes
: Multiplayer options
section Professional Skills (1 month)
Game Development: Performance optimization
: Code architecture
: Testing strategies
: Deployment patterns
```
### ๐ ๏ธ Your Game Development Toolkit Summary
After completing this project, you'll have mastered:
- **Event-Driven Programming**: Responsive user interfaces that react to input
- **Real-Time Feedback**: Instant visual and performance updates
- **Performance Measurement**: Accurate timing and scoring systems
- **Game State Management**: Controlling application flow and user experience
- **Interactive Design**: Creating engaging, addictive user experiences
- **Modern Web APIs**: Utilizing browser capabilities for rich interactions
- **Accessibility Patterns**: Inclusive design for all users
**Real-World Applications**: These skills directly apply to:
- **Web Applications**: Any interactive interface or dashboard
- **Educational Software**: Learning platforms and skill assessment tools
- **Productivity Tools**: Text editors, IDEs, and collaboration software
- **Gaming Industry**: Browser games and interactive entertainment
- **Mobile Development**: Touch-based interfaces and gesture handling
**Next Level**: You're ready to explore advanced game frameworks, real-time multiplayer systems, or complex interactive applications!
## Credits
Written with โฅ๏ธ by [Christopher Harrison](http://www.twitter.com/geektrainer)