A physics-based puzzle game where you cut ropes to guide a candy ball into a target box.
Cut The Rope is a puzzle game that challenges players to use physics and timing to solve levels. The candy hangs from ropes attached to anchors - your job is to cut the ropes at the right moment to let gravity and momentum guide the candy into the target box.
Built with Python, pygame-ce, and pymunk for realistic 2D physics simulation.
- ๐ Realistic Rope Physics - Chains swing and respond to cuts naturally using Pymunk physics engine
- ๐ฏ Progressive Difficulty - 6 handcrafted levels introducing new mechanics gradually
- โก Responsive Controls - Cut ropes with mouse slashes or keyboard letters
- ๐จ Clean Visual Design - Dark space theme with vibrant colors and particle effects
- ๐ ๏ธ Built-in Level Editor - Create and share your own custom levels
- ๐ Quick Reset - Instantly retry levels with the R key
- Python 3.10 or higher
- pip (Python package installer)
- Clone the repository:
git clone https://github.com/yourusername/cut-the-rope.git
cd cut-the-rope- Create a virtual environment (recommended):
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtRun the game:
python run.pyCut the ropes holding the candy to swing and drop it into the green target box. The candy must settle (stay inside for 2 seconds) to win!
| Action | Key/Mouse |
|---|---|
| Cut Rope | Mouse drag / Letter keys (A, B, C...) |
| Restart Level | R |
| Toggle Instructions | I |
| Level Select | 1-6 number keys |
| Quit | ESC |
- Observe the rope configuration and target location
- Plan which rope to cut first to create the right swing
- Time your cuts to use momentum and gravity effectively
- Avoid red spike hazards - they reset the level!
- Use platforms to bounce and redirect the candy
| Level | Description | Challenge |
|---|---|---|
| Level 1 | Simple Drop | Learn the basic mechanic - cut the single rope |
| Level 2 | Double Swing | Use momentum from two ropes to reach the target |
| Level 3 | Obstacle Course | Navigate around platforms and barriers |
| Level 4 | Precision | Time your cuts perfectly for the right arc |
| Level 5 | Hazard Warning | Avoid deadly spikes while solving the puzzle |
| Level 6 | Master Challenge | Combine all skills in a complex multi-rope setup |
Create your own puzzles with the built-in visual level editor!
python level_editor.py| Key | Action |
|---|---|
1 |
Place Candy (starting position) |
2 |
Place Anchor (rope attachment point) |
3 |
Place Target Box (click twice for corners) |
4 |
Place Platform (click twice for corners) |
5 |
Place Spike (hazard) |
Left Click |
Place selected object |
Right Click |
Delete object at mouse |
S |
Print level code to console |
C |
Clear all objects |
ESC |
Quit editor |
- Design your level in the editor
- Press
Sto get the level code - Copy the generated
LevelDatacode - Open
src/levels.py - Paste it into the
_create_levels()method - Add it to the return list
# Example in src/levels.py
def _create_levels():
level_1 = LevelData(
candy_pos=(600, 450),
anchors=[...],
target=...
)
your_level = LevelData(
candy_pos=(600, 400),
anchors=[(700, 600, 'A'), (500, 600, 'B')],
...
)
return [level_1, level_2, your_level]cut-the-rope/
โโโ src/
โ โโโ config.py # Game configuration & constants
โ โโโ entities.py # Entity classes (Candy, Rope, etc.)
โ โโโ game.py # Main game loop & state management
โ โโโ levels.py # Level definitions
โ โโโ physics.py # Pymunk physics engine wrapper
โ โโโ renderer.py # Pygame rendering
โ โโโ ui.py # UI components & menus
โ โโโ utils.py # Utility functions
โโโ level_editor.py # Visual level editor
โโโ run.py # Game entry point
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ cut-the-rope-presentation.html # Game Design Analysis
- Gravity: -900 px/sยฒ (downward acceleration)
- Sub-stepping: 4 physics steps per frame for stability
- Rope Simulation: PinJoint constraints with damping
- Collision: Category-based collision filtering
- Pymunk: Bottom-left origin (Y increases upward)
- Pygame: Top-left origin (Y increases downward)
- Conversion:
pygame_to_pymunk()andpymunk_to_pygame()utilities
def line_segment_intersection(p1, p2, p3, p4):
"""Check if line segment (p1,p2) intersects (p3,p4)"""
# Uses standard line intersection formula
# Returns True if lines cross, False otherwise- Collision sensor detects candy entering target
- Timer starts when candy is inside
- Candy must have velocity < 80 px/s (settled)
- Win after 2 seconds of continuous settlement
This game was developed as part of a Game Design course, analyzing core game design principles:
- MDA Framework: Mechanics โ Dynamics โ Aesthetics
- Bartle Player Types: Targeted at Achievers & Explorers
- Flow Theory: Progressive difficulty maintains player engagement
- Schema Theory: Teaching patterns through level progression
View the full Game Design Analysis Presentation for an in-depth look at the design decisions behind Cut The Rope.
Run the test suite:
python -m pytest uniTest/Or run specific tests:
python -m pytest uniTest/test_physics.py -v| Package | Version | Description |
|---|---|---|
| pygame-ce | โฅ2.4.1 | Modern Python game library |
| pymunk | โฅ6.5.0 | 2D physics engine based on Chipmunk |
Contributions are welcome! Feel free to:
- 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
- ๐ New levels (easy, medium, hard)
- ๐จ New visual themes or skins
- ๐ง New obstacle types (springs, fans, teleports)
- ๐ Achievement system
- ๐ Level statistics and analytics
- ๐ต Sound effects and music
Developed by:
- Muhammad Yaseen
- Hevar Hemin
- Revar Azim
Supervisor: Mrs. Rina D. Zarro
Course: Game Design - University of Salahaddin - Erbil
This project is open source and available under the MIT License.
- Pymunk - Excellent 2D physics engine
- Pygame-ce - Modern community-driven Pygame fork
- Cut the Rope (ZeptoLab) - Inspiration for this project
- Game Design course materials and lectures
Enjoy the game! ๐ฎ