OneLine is a sleek, minimalist, 2D connection puzzle game designed with mathematics and modularity at its core. Players are challenged to connect all nodes in a puzzle with a single, continuous, non-overlapping line.
This project was built from scratch in two weeks to prototype grid mechanics and study graph-theory solvers, and has since been documented as a technical showcase highlighting professional software design patterns, automated Eulerian graph validation, and cross-platform file serialization.
- Engaging Connection Gameplay: Drag-and-draw mechanics using Unity's EventSystem handlers for fluid, high-performance interactions on both touch and mouse displays.
- Full-Featured Level Editor:
- Precision grid-snap drawing matching customizable cell sizes.
- Real-time drag/move, insertion, and removal tools.
- Unlimited Undo/Redo operations powered by a robust Command pattern history stack.
- Eulerian Path Level Validator: An built-in topological validator that mathematically verifies a level's solvability before permitting saving.
- Cross-Platform JSON Serialization: Level profiles saved and loaded dynamically via JSON, allowing users to import/export levels seamlessly.
- Multi-Platform Support: Integrated with native OS file-picker wrappers to import and share levels on Windows, iOS, and Android.
- Adaptive Viewport Camera: A custom aspect-ratio fitting camera wrapper that ensures consistent visibility and scale across varying mobile and desktop aspect ratios.
Rather than relying on quick prototype hacks, the codebase leverages mature software patterns commonly used in production-scale titles.
To prevent users from saving unsolvable levels, the level editor implements an automatic topological checker. According to graph theory, a graph has an Eulerian Path (a trail that visits every edge exactly once) if and only if:
- The graph is fully connected (excluding isolated vertices).
- The number of vertices with an odd degree (odd number of connected edges) is exactly 0 or 2.
The level validator uses a Depth-First Search (DFS) algorithm to verify connectedness and then counts the odd degrees.
To handle complex user commands (placing nodes, drawing connections, moving vertices, and deleting elements) while maintaining perfect state history, the Editor uses the Command Pattern.
Every modification is encapsulated as an object implementing IEditorCommand, which is pushed onto an Undo stack.
namespace Level_Editor.Commands
{
public interface IEditorCommand
{
void Undo();
void Redo();
}
}For instance, when a user adds a node, the operation is wrapped inside AddNode.cs.
This encapsulates state completely, allowing the LevelEditor.cs class to orchestrate undo and redo operations in a single line of code by shifting commands between two stacks (_undoStack and _redoStack).
To keep visual configurations decoupled from logic and avoid hardcoded magic numbers, global configurations are stored in a dedicated Settings ScriptableObject. This allows game designers to tweak values like camera boundaries, grid sizes, asset-prefab maps, and UI hover colors directly in the Unity Inspector without recompiling scripts.
- Unity Editor 6000.4.7f1 (or newer)
- Universal Render Pipeline (URP) package installed via Package Manager
- Clone this repository into your local directory.
- Open the project in the Unity Editor.
- Load and play the
Assets/Scenes/Main Menu.unityscene. - Click Play to run standard campaigns, or open the Level Editor to build and validate custom boards!