A fully interactive 3D Rubik's Cube built with Python using Pygame and PyOpenGL.
You can freely rotate the entire cube by dragging with your mouse to see different sides. You can also rotate each layer of the cube using keyboard shortcuts with smooth animations — just like a real Rubik's Cube!
- Realistic 3D rendering with classic colors and black edges
- Mouse drag to rotate and view the cube from any angle
- Animated 90° layer rotations
- Shift key to reverse rotation direction
- Single-file, clean implementation
- Python 3.6 or higher
-
Clone the repository:
git clone https://github.com/amirsafa2024/Visual-Rubik-s-Cube.git cd THE-REPO-DIRECTORY -
(Recommended) Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the simulator:
python rubikCube.py
- Left-click and drag with the mouse to rotate the whole cube and see different sides.
Press these keys to rotate the corresponding face counter-clockwise:
U→ Up face (white)D→ Down face (yellow)F→ Front face (green)B→ Back face (blue)L→ Left face (orange)R→ Right face (red)
Hold Shift while pressing any of the above keys to rotate the face clockwise instead.
Esc→ Quit the program
Made with ❤️ using Pygame and PyOpenGL.
Window title inspiration: "Dish Dirin Dirin Mashallah xD"
Have fun scrambling and solving the cube! Feel free to open issues or submit pull requests if you find bugs or want to add features. 🎲