A minimalistic mobile puzzle game built with HTML5 Canvas and touch gestures.
Flipgame is a level-based puzzle game designed exclusively for mobile devices. The user navigates a ball through various board layouts by dragging it along permitted paths, with the goal of reaching the end point of each level.
- Mobile-First Design: Optimized for touch interactions and mobile screens
- Level-Based Progression: Solve puzzles to unlock new levels
- Proportional Rendering: Balls, halos, and goal rings scale with board size for consistent visuals
- Touch Gestures: Intuitive drag and tap controls
- No Text UI: Clean, visual-only interface with level numbers displayed graphically
- Progress Saving: Automatic save/load of game progress
The project follows a modular architecture with clear separation of concerns:
CONSTANTS โ Utils โ HtmlBuilder โ DisplayManager โ
StorageManager โ GameManager โ App
- GameManager: Handles game logic, level management, and touch interactions
- StorageManager: Manages game progress and settings persistence
- DisplayManager: Renders game UI and manages display states
- HtmlBuilder: Generates HTML components for the game interface
- Utils: Provides utility functions for validation and calculations
- Modern web browser with HTML5 Canvas support
- Touch-enabled device (recommended) or mouse for desktop testing
- Clone the repository:
git clone <repository-url>
cd flipgame- Open
index.htmlin a web browser or serve locally:
# Using Python
python3 -m http.server 8099
# Using Node.js
npx serve .
# Using PHP
php -S localhost:8099- Access the game at
http://localhost:8099
The project uses vanilla JavaScript with no build process required. Key files:
index.html- Main HTML structureapp.js- Main application controllermanagers/game-manager.js- Game logic and mechanicsstyles.css- Game styling and mobile optimizationsconstants.js- Game configuration and messages
- Level Loading: Each level presents a unique board layout
- Ball Movement: Drag the white ball to move along permitted paths
- Goal Achievement: Reach the green end point to complete the level
- Board Manipulation: Use rotation and flip mechanics to find new solutions
- Progression: Complete levels to unlock new challenges
- Square Lattice: Traditional grid-based layouts with 90ยฐ rotation
- Triangular Lattice: Hexagonal-based layouts with 60ยฐ rotation
- Empty: Free movement space
- Path: Permitted movement corridors
- Teleport: Instant movement between points
- Switch: Interactive elements that change board state
- Collectible: Optional items that enhance gameplay
- Touch Events: Optimized for mobile touch interactions with preventDefault + stopPropagation
- Device Pixel Ratio: Canvas scaled for high-DPI displays without touch offset
- Responsive Design: Adapts to different screen sizes and orientations
- Performance: 60fps target for smooth gameplay
- Touch Targets: Minimum 44px for all interactive elements
- Visual Feedback: Clear visual indicators for all game states
- Reduced Motion: Respects user preferences for motion sensitivity
Levels are defined in the GameManager (grid-based). Balls and goal rings scale with gridSize. Use the following structure:
{
board: {
nodes: [
"........",
"........",
"........",
"........",
"........",
"........",
"........",
"........"
]
},
balls: [
{
start: [2, 2],
end: [6, 6],
color: 'white'
}
]
}.- Empty space#- Path (movement allowed)T- TeleportS- SwitchC- Collectible
start: [x, y]- Starting grid positionend: [x, y]- Goal grid positioncolor- Ball color (optional)
Note: Visual ball size scales with the board (gridSize * 0.375 base), touch feedback scales up to match the goal inner radius, and halo matches the goal outer radius.
The game uses CSS custom properties for easy theming:
:root {
--background-color: #000000;
--ball-color: #ffffff;
--goal-color: #00ff00;
--path-color: #666666;
}- Zero Duplication: No code or message duplication allowed
- Constants First: All text and configuration in constants files
- Modular Architecture: Clear separation of concerns
- Mobile Performance: Optimize for 60fps on target devices
flipgame/
โโโ index.html # Main HTML file
โโโ app.js # Main application controller
โโโ app-bridge.js # Global bridge functions
โโโ styles.css # Game styling
โโโ constants.js # Constants
โโโ utils.js # Utility functions
โโโ html-builder.js # HTML component generation
โโโ display-manager.js # Display state management
โโโ managers/
โ โโโ storage-manager.js # Data persistence
โ โโโ game-manager.js # Game logic and mechanics
โโโ levels/ # Level definitions (future)
- Canvas not rendering: Check browser console and verify devicePixelRatio scaling is applied
- Touch offset: Ensure touch coordinates use CSS pixels (not DPR-scaled)
- Performance issues: Check for background processes affecting frame rate
- Progress not saving: Verify localStorage is enabled in browser
Enable debug logging by setting:
localStorage.setItem('flipgame_debug', 'true');This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch
- Follow the coding standards and architecture guidelines
- Test on mobile devices
- Submit a pull request
-
Additional level types and mechanics
-
Sound effects and background music
-
Particle effects and animations
-
Level editor for custom puzzles
-
Progressive Web App (PWA) support
-
Social sharing and leaderboards
For questions or issues, please check the documentation or create an issue in the repository.