A modern incremental clicker game that demonstrates how to build interactive desktop applications using Python and JavaScript. This project serves as a practical example of combining PyQt6's native capabilities with web technologies to create rich, responsive applications.
The game showcases:
- Python backend for system operations and data persistence
- JavaScript frontend for dynamic UI and game logic
- Bidirectional communication between Python and JavaScript
- Modern web technologies in a desktop environment
- Real-time updates and state management
Click to generate bytes and unlock various generators to automate your byte production!
This project demonstrates several key concepts for hybrid Python-JavaScript applications:
-
Frontend-Backend Separation
- JavaScript handles UI updates and game logic
- Python manages system operations and data persistence
- Clean separation of concerns for maintainability
-
Bridge Communication
- Bidirectional Python-JavaScript communication via QWebChannel
- Asynchronous operations with promises
- Type-safe method calls between languages
-
Modern Development Practices
- Event-driven architecture
- Real-time state management
- Responsive UI design
- Error handling across language boundaries
- Interactive clicking mechanism
- Multiple generators with increasing production rates
- Auto-save functionality
- Performance metrics and statistics
- Modern, responsive UI
- Progress-based generator unlocking system
- Click the green circle to generate bytes
- Purchase generators to automate byte production
- Unlock new generators by purchasing 5 of the previous generator
- Save your progress using the "Save Game" button
- Start fresh with the "New Game" button
- Auto Clicker - Basic automation
- Byte Compiler - Improved byte generation
- Data Miner - Efficient byte production
- Quantum Computer - Advanced computation
- AI Cluster - Massive parallel processing
- Quantum Network - Network-enhanced production
- Digital Dimension - Ultimate byte generation
- Auto-save every minute
- Real-time statistics tracking
- Performance metrics
- Progression system
- Modern UI with visual feedback
The game includes both automatic and manual save features to ensure your progress is never lost:
- Automatically saves your game progress every 60 seconds
- Saves are stored in
clicker_save.json
in the game directory - Auto-save runs silently in the background without interrupting gameplay
- Click the "Save Game" button at any time to manually save your progress
- Visual feedback confirms successful saves with a temporary "Saved!" message
- Recommended to manually save before exiting the game
- Save data is stored in JSON format
- Includes all game state:
- Current and total bytes
- Generator counts and states
- Game statistics
- Timestamps
- Location:
clicker_save.json
in the game directory
The game is built using:
- PyQt6 for the application framework
- JavaScript for game logic
- HTML/CSS for the user interface
- QWebChannel for Python-JavaScript communication
The game uses a Python-JavaScript bridge (via QWebChannel) to enable communication between the UI layer and the system layer:
-
save_game(game_state: str) -> str
- Saves the current game state to
clicker_save.json
- Parameter: JSON string containing complete game state
- Returns: Success/error message
- Saves the current game state to
-
load_game() -> str
- Loads game state from
clicker_save.json
- Returns: JSON string of saved game state or empty object if no save exists
- Loads game state from
-
show_about()
- Displays the About dialog with game version and information
- Shows native system dialog with game details
-
exit_app()
- Handles application exit with confirmation
- Shows confirmation dialog before quitting
- Prompts user to save if needed
// Initialize bridge connection
new QWebChannel(qt.webChannelTransport, function(channel) {
window.bridge = channel.objects.bridge;
// Bridge is ready to use
});
// Example: Save game
bridge.save_game(JSON.stringify(game_state))
.then(response => {
console.log(response); // "Game saved successfully"
});
// Example: Load game
bridge.load_game().then(saved_state => {
const game_state = JSON.parse(saved_state);
// Process loaded state
});
// Example: Show about dialog
bridge.show_about();
// Example: Exit application
bridge.exit_app();
- Bridge class:
WebBridge
inmain.py
- Communication protocol: QWebChannel
- Data format: JSON for state transfer
- Error handling: Try-catch blocks with error messages
- Thread safety: All methods are synchronous and thread-safe
- Python 3.8 or higher
- PyQt6
- PyQtWebEngine
- Clone this repository:
git clone https://github.com/non-npc/Byte-Clicker-Incremental-Game.git
cd Byte-Clicker-Incremental-Game
- Create a virtual environment (recommended):
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
To start the game, run:
python main.py
CC0 License - Feel free to modify and distribute this code as you like!