A multilingual interactive game for learning Chinese 4-character idioms (四字成语 sìzìchéngyǔ) in CLI and Pygame GUI versions.
Note
Curious about the entire building process? Read my blog post for the full story! 👾
The Chinese 4-Character Idiom Game offers an engaging way to learn and practice Chinese idioms through an interactive fill-in-the-blank format. Players are presented with Chinese 4-character idioms where 2 characters are hidden, and they must select the characters in correct order from a list of options.
The CLI version offers a text-based interface with color-coded feedback, multiple-choice options, and language selection. Players fill in the blanks for Chinese idioms using keyboard input and receive instant validation of their answers.
🕹️ Video Demo
cn-idiom-cli.mp4
The GUI version features a retro 8-bit style interface with colorful visuals, sound effects, and smooth animations. Players can select answers by clicking buttons and receive immediate feedback on their answers.
🕹️ Video Demo (🔊Sound ON!)
cn-idiom-cli-pygame-en.mp4
Tip
The demo videos showcase only three sample questions for illustration purposes. Download the game to explore the full question set!
- Amazon Q CLI: Autonomous AI agent for dynamic coding
- Python 3.6+: Core programming language
- Pygame: For the graphical user interface and game rendering
- JSON: For storing idioms, translations, and game data
- Termios/Fcntl: For terminal control in the CLI version
- Noto Sans Fonts: For multilingual text rendering (Chinese, Japanese, Korean)
- WAV Audio: For game sound effects
-
Multilingual Support:
- English (EN)
- Japanese (JP)
- Korean (KR)
- Language selection via arrow key navigation in CLI version, and using click button in GUI version
-
Two Game Modes:
- CLI (Command Line Interface) for terminal enthusiasts
- GUI with Pygame for a more visual experience
-
Educational Content:
- Learn Chinese idioms with proper context
- Understand individual character meanings
- Practice character recognition and pinyin (Chinese Phonetic Alphabet)
-
Game Elements:
- Lives system (3 hearts)
- Score tracking
- Randomized blank positions
- Sound effects for actions (GUI version)
- Retro 8-bit visual style (GUI version)
-
Clone the repository:
git clone https://github.com/karenwky/cn-idiom-game cd cn-idiom-game
-
Install dependencies:
pip install -r requirements.txt
CLI Version:
python cn_idiom_game_cli.py
- Use arrow keys to navigate the language selection menu
- Press Enter to select your preferred language
- Follow on-screen instructions to play
GUI Version:
python cn_idiom_game_pygame.py
- Click on language button to change languages
- Click on character options to fill in the blanks
- Click Submit when you've selected your answers
- You start with 3 lives (❤️❤️❤️)
- Each idiom has 2 blanks that need to be filled
- Select the characters in correct order from the options provided
- Correct answers increase your score
- Incorrect answers cost you a life
- Game ends when you run out of lives or complete all idioms
cn-idiom-game/
├── assets/
│ ├── font/
│ │ ├── NotoSansSC-Bold.ttf # Chinese font
│ │ ├── NotoSansJP-Bold.ttf # Japanese font
│ │ └── NotoSansKR-Bold.ttf # Korean font
│ └── sounds/
│ ├── correct.wav # Sound for correct answers
│ ├── wrong.wav # Sound for wrong answers
│ ├── game_over.wav # Sound for game over
│ └── end_game.wav # Sound for completing all idioms
├── cn_idiom_game_cli.py # CLI version of the game
├── cn_idiom_game_pygame.py # GUI version with Pygame
├── idioms.json # Data source of Chinese idioms
├── translations.json # Multilingual text translations
├── requirements.txt # Project dependencies
└── prompts.md # Prompts archive for Amazon Q CLI
Place WAV files in assets/sounds/
:
- correct.wav
- wrong.wav
- game_over.wav
- end_game.wav
Required fonts in assets/font/
:
- NotoSansSC-Bold.ttf (Chinese)
- NotoSansJP-Bold.ttf (Japanese)
- NotoSansKR-Bold.ttf (Korean)
Edit idioms.json
following this format:
{
"idiom": "四字成语",
"pinyin": "sì zì chéng yǔ",
"meaning": {
"en": "English meaning",
"ja": "Japanese meaning",
"ko": "Korean meaning"
},
"words": [
{
"word": "四",
"meaning": {
"en": "four",
"ja": "四",
"ko": "넷"
}
}
]
}
- UI Optimization: Resolve text alignment issues and prevent button overlap
- Database Integration: Use database instead of JSON for large datasets
- Real-time LLM-generated Questions: Generate more varied questions
- Timer Limit: Set varying time limits based on difficulty levels
- Keyboard Control: Use keyboard to play the game in GUI version
- Leaderboard: For showing score ranking
- Additional Languages: Support for more languages
AWS Cloud Community
- Build Games with Amazon Q CLI and score a T shirt 🏆👕
- Vibe Coding in Practice: Building a Classic Platform Jumping Game with Amazon Q CLI
AWS Blog / AWS Documentation
- Amazon Q Developer CLI supports image inputs in your terminal
- Using Amazon Q Developer on the command line - Amazon Q Developer
Fonts
Sound Effects
This project is licensed under the MIT License - see the LICENSE file for details.
Created with ❤️ for Chinese language learners everywhere