- ๐ฎ Overview
- โจ Features
- ๐ Getting Started
- ๐ฏ How to Play
- ๐๏ธ Project Structure
- ๐ง Technical Details
- ๐ Game States
- ๐พ Data Management
- ๐จ Customization
- ๐ค Contributing
- ๐ License
- ๐ค Authors
Sudoku Game is a comprehensive, cross-platform Sudoku implementation built entirely in C using the Raylib graphics library. This project demonstrates advanced C programming concepts including object-oriented programming patterns, file I/O, data persistence, and real-time user input validation.
The game features a complete user authentication system, multiple difficulty levels, game state persistence, and an intuitive graphical interface that provides an engaging puzzle-solving experience.
- Sign Up: Create new player accounts with validation
- Log In: Secure authentication for existing players
- Player Management: CSV-based player data storage
- Input Validation: Real-time validation for usernames and passwords
- Three Difficulty Levels: Easy (20 cells removed), Medium (40 cells removed), Hard (60 cells removed)
- Smart Puzzle Generation: Uses backtracking algorithm for valid Sudoku generation
- Real-time Validation: Instant feedback on correct/incorrect moves
- Game State Persistence: Save and resume games at any time
- Timer System: Track solving time with pause/resume functionality
- Mistake Tracking: Monitor incorrect attempts
- Modern GUI: Clean, intuitive interface built with Raylib
- Responsive Design: 600x600 window with scalable elements
- Visual Feedback: Color-coded cells and validation indicators
- Loading Animations: Smooth transitions with spinner effects
- Tutorial System: Built-in help and game rules
- Player Profiles: Persistent user accounts with statistics
- Game Saves: Individual save files per player
- Solution Storage: Pre-generated valid Sudoku solutions
- CSV Integration: Structured data storage and retrieval
Before building and running the Sudoku Game, ensure you have the following installed:
- C Compiler: GCC (GNU Compiler Collection)
- Raylib Library: Graphics library for rendering
- Make: Build automation tool
- Git: Version control (for cloning the repository)
On Ubuntu/Debian:
sudo apt update
sudo apt install libraylib-devOn Windows (MSYS2/MinGW):
pacman -S mingw-w64-x86_64-raylibOn macOS:
brew install raylib-
Clone the repository:
git clone https://github.com/yourusername/Sudoku_Game.git cd Sudoku_Game -
Verify the project structure:
ls -la
You should see directories:
assets/,data/,include/,source/,libraries/
The project uses a cross-platform Makefile that automatically detects your operating system:
# Build the project
make
# Or build and run in one command
make runBuild Output:
- Linux:
build/main - Windows:
build/main.exe
After building, you can run the game:
# Run the built executable
make run
# Or run directly
cd build && ./main- Launch the game and you'll see the sign-up screen
- Create an account or log in if you already have one
- Choose your difficulty from the main menu:
- Easy: 20 cells removed (beginner-friendly)
- Medium: 40 cells removed (intermediate)
- Hard: 60 cells removed (expert level)
- Click on empty cells to select them
- Type numbers 1-9 to fill the selected cell
- Use the pause button to save progress or return to menu
- Complete the puzzle by filling all cells correctly
- Each row must contain numbers 1-9 without repetition
- Each column must contain numbers 1-9 without repetition
- Each 3x3 sub-grid must contain numbers 1-9 without repetition
- The game validates your moves in real-time
Sudoku_Game/
โโโ ๐ assets/ # Game assets and resources
โ โโโ ๐ fonts/ # Custom fonts
โ โ โโโ Adecion-Bold.ttf
โ โโโ ๐ icons/ # Game icons
โ โ โโโ game_icon.png
โ โโโ ๐ images/ # UI images
โ โโโ back.png
โ โโโ pause.png
โ โโโ required.png
โโโ ๐ data/ # Game data and persistence
โ โโโ ๐ players/ # Player database
โ โ โโโ players.csv
โ โโโ ๐ saves/ # Game save files
โ โ โโโ ouss.txt
โ โ โโโ youne.txt
โ โโโ ๐ solution/ # Pre-generated solutions
โ โโโ solution.txt
โโโ ๐ include/ # Header files
โ โโโ auth.h # Authentication system
โ โโโ config.h # Game configuration
โ โโโ difficulty.h # Difficulty management
โ โโโ menu.h # Menu system
โ โโโ play.h # Game logic
โ โโโ player.h # Player management
โ โโโ process.h # Input processing
โ โโโ raylib.h # Graphics library
โ โโโ render.h # Rendering system
โ โโโ result.h # Results display
โ โโโ tutorial.h # Tutorial system
โโโ ๐ libraries/ # External libraries
โ โโโ libraylib.a
โโโ ๐ source/ # Source code files
โ โโโ auth.c
โ โโโ config.c
โ โโโ difficulty.c
โ โโโ main.c
โ โโโ menu.c
โ โโโ play.c
โ โโโ player.c
โ โโโ process.c
โ โโโ render.c
โ โโโ result.c
โ โโโ tutorial.c
โโโ ๐ Makefile # Build configuration
โโโ ๐ LICENSE # MIT License
โโโ ๐ README.md # This file
The game follows a modular architecture with clear separation of concerns:
- State Management: Finite state machine for game flow
- Object-Oriented C: Function pointers for method-like behavior
- Data Persistence: File-based storage for players and game states
- Real-time Validation: Immediate feedback on user input
- Main Loop: Raylib-based rendering and input handling
- State Machine: 9 distinct game states (SIGN_UP, LOG_IN, MAIN_MENU, etc.)
- Timer System: High-precision timing for game duration
- Backtracking Algorithm: Generates valid Sudoku puzzles
- Validation Engine: Real-time move validation
- Difficulty Scaling: Configurable cell removal based on difficulty
- Authentication: Secure login/signup with validation
- Profile Management: Persistent player data
- Save System: Individual game state persistence
- Memory Management: Proper allocation and deallocation
- Efficient Rendering: Optimized drawing calls
- Fast Validation: O(1) move validation algorithms
- Cross-platform: Works on Linux, Windows, and macOS
The game implements a comprehensive state machine:
| State | Description | Features |
|---|---|---|
SIGN_UP |
User registration | Input validation, unique username check |
LOG_IN |
User authentication | Credential verification, error handling |
MAIN_MENU |
Main game menu | Navigation, player info display |
MODE_MENU |
Difficulty selection | Three difficulty levels |
TUTORIAL |
Game tutorial | Interactive help system |
PLAYING |
Active gameplay | Sudoku solving, real-time validation |
LOADING |
Transition state | Animated spinner, smooth transitions |
RESULT |
Game completion | Statistics, performance metrics |
EXIT |
Application exit | Cleanup, resource deallocation |
Name,Password
youne,sbai_test
ouss,arif_test
taha,ammour_test
- Individual save files per player
- Contains: grid state, difficulty, timer, mistakes
- Automatic cleanup on game completion
- Pre-generated valid Sudoku solutions
- Used for puzzle generation and validation
- Ensures solvable puzzles at all difficulty levels
- Window Size: Modify
WINDOW_WIDTHandWINDOW_HEIGHTinconfig.h - Cell Size: Adjust
CELL_SIZEfor different grid dimensions - Colors: Customize color schemes in rendering functions
- Fonts: Replace fonts in
assets/fonts/directory
- Difficulty Levels: Modify cell removal counts in
config.h - Validation Rules: Customize input validation in
player.h - Timer Behavior: Adjust timing logic in game state handlers
- Compiler Flags: Modify
CFLAGSinMakefile - Platform Support: Add new platforms in
Makefile - Dependencies: Update library paths as needed
We welcome contributions to improve the Sudoku Game! Here's how you can help:
- Use the issue tracker to report bugs
- Include steps to reproduce the issue
- Provide system information (OS, compiler version)
- Suggest new features or improvements
- Discuss implementation approaches
- Consider backward compatibility
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow existing code style and naming conventions
- Add comments for complex logic
- Ensure cross-platform compatibility
- Test on multiple operating systems
This project is licensed under the MIT License - see the LICENSE file for details.
Youness SBAI - Lead Developer - GitHub Profile
403F2E - Collaborator - GitHub Profile
โญ Star this repository if you found it helpful!