Sokoban - Classic Puzzle Game

Seele01-Flash
By
Sokoban is the legendary Japanese puzzle game that challenges your strategic thinking. Push boxes to designated locations across 20 increasingly difficult levels in this modern remake of the 1982 classic.

Prompt

MODEL: Seele01-Flash
Please use Three.js to generate a **mobile-first game** with the theme "Modern 3D Sokoban". Please read the following detailed game design requirements first, and then generate the code accordingly: ### 1. Assets & Environment * **Visual Style:** A clean, vibrant **Voxel or Low-Poly aesthetic** inspired by the provided screenshot. The game should use an **Orthographic Camera** (angled at roughly 45 degrees, isometric view) to ensure the grid is clearly readable on small mobile screens. * **Color Palette:** Use the screenshot's palette: Bright emerald green for the floor grid, saturated red for wall blocks (brick texture), and warm brown for wooden crate boxes. The background (clear color) should be a darker, soothing green to make the board pop. * **Models:** * **Player:** A simple low-poly character (or a distinct capsule/cube with a "face" texture) wearing a green cap. * **Crates:** Cubes with a diagonal wooden brace texture. When placed on a goal, they should emit a soft glow or change tint (e.g., to gold). * **Goals:** Marked on the floor texture with bright green brackets or a glowing particle effect. * **Mobile Optimization:** Use `THREE.InstancedMesh` for rendering the floor tiles and wall blocks to minimize draw calls. Ensure textures are low-resolution (e.g., 256x256) pixel art style to keep load times instant. ### 2. Audio Requirements * **BGM:** A relaxing, lo-fi, or soft chiptune track that encourages thinking. It should loop seamlessly and not be distracting. * **Sound Effects (SFX):** * **Move/Step:** A quiet "tap" sound. * **Push Box:** A "wood sliding across stone" friction sound. * **Hit Wall (Invalid Move):** A dull "thud" or "bump" sound. * **Goal Reached:** A satisfying, high-pitched "ding" or chime. * **Level Complete:** A short, celebratory fanfare. * **Undo:** A "rewind" or "whoosh" sound. ### 3. Gameplay Loop * **Core Logic:** Implement a strictly grid-based movement system. The player can move Up, Down, Left, or Right. * **Push Mechanics:** The player can push **one** crate at a time into an empty space. Pushing two crates or pushing a crate into a wall is forbidden. * **State Management:** * Implement an **Undo Stack**: Store the history of player moves and box positions to allow unlimited "Undo" actions. * **Move Counter**: Display a move counter at the top of the screen. * **Win Condition:** The level is complete when **all** crates are positioned on top of **all** goal tiles. Upon winning, trigger a confetti particle effect and a "Level Complete" modal overlay. * **Level Design:** Generate a hardcoded level layout (based on a 2D array map) representing a classic puzzle layout. ### 4. Mobile Controls & Interaction * **Gesture Controls (Primary):** Implement a robust **Swipe Detection System**. A quick swipe on the screen (Up/Down/Left/Right) triggers a movement. Set a minimum swipe distance threshold to prevent accidental moves. * **On-Screen UI (Secondary):** * **Undo Button:** A large, circular button with a "U-turn" arrow icon in the bottom-left corner (min size 60x60px). * **Restart Button:** A refresh icon in the top-right corner. * **Visual & Haptic Feedback:** * **Camera Shake:** When the player tries to move into a wall or push an immovable object, apply a tiny, short camera shake. * **Smooth Tweening:** Use a library like TWEEN.js or GSAP to smoothly animate the character and boxes moving between grid tiles (do not just teleport them). * **Vibration:** Trigger a short haptic feedback (using `navigator.vibrate(10)`) when a box is successfully pushed or a goal is reached. Do not ask for clarification. Do not request confirmation. Directly execute the generation task based on the given instructions.

Game Introduction

About the Game

Sokoban is a timeless puzzle game that has captivated players worldwide since 1982. This modern remake preserves the essence of the original Japanese classic while adding contemporary features like move counting and level replay. The game challenges you to think several moves ahead as you navigate increasingly complex warehouse layouts.

The core gameplay revolves around strategic box placement - you control a warehouse worker who must push boxes onto designated target spots. What seems simple at first becomes a mind-bending challenge that tests your spatial reasoning and forward-thinking abilities.

Core Features

Classic Gameplay Mechanics

Sokoban follows the pure, elegant rules that made it a puzzle gaming legend. You can only push boxes, never pull them, and boxes move one space at a time. This limitation creates the strategic depth that puzzle enthusiasts love.

20 Challenging Levels

Each level presents a unique warehouse layout with progressively complex puzzles. From simple introductory challenges to brain-twisting expert layouts, the difficulty curve keeps you engaged without becoming frustrating.

Move Counter System

Every level tracks your move count, encouraging efficient solutions. This feature adds replay value as you strive to complete levels with the minimum number of moves possible, turning each puzzle into a optimization challenge.

Quality of Life Features

  • Undo Function : Made a mistake? Press U or use the in-game button to undo your last move
  • Level Restart : Hold R or use the restart button to quickly try a level again
  • Goal Highlighting : Press H to highlight target positions when you need a visual reminder
  • Level Selection : Replay any completed level to improve your move count

Game Mechanics

Box Pushing Rules

The fundamental mechanic involves pushing wooden crates onto red brick target areas. Boxes can only be pushed in four directions (up, down, left, right) and cannot be pulled. If a box gets stuck against a wall or another box, you'll need to restart or undo moves.

Strategic Planning

Success requires thinking multiple moves ahead. Consider the consequences of each push, as boxes can easily become trapped in corners or against walls. The best solutions often involve temporarily moving boxes away from their targets to create maneuvering space.

Controls and Gameplay

Desktop Controls

  • Arrow Keys or WASD : Move your character in four directions
  • U Key : Undo the last move
  • R Key (Hold) : Restart the current level
  • H Key : Highlight goal positions
  • Mouse : Click in-game buttons for undo and restart

Mobile Controls

Mobile players can simply tap anywhere on the screen to move their character in that direction. All desktop functions are available through intuitive touch buttons.

Platform Compatibility

This browser-based game works seamlessly across desktop and mobile devices. No downloads required - simply open your web browser and start playing immediately.

Why Play Sokoban

Mental Exercise

Sokoban is more than entertainment - it's a comprehensive brain training exercise. The game develops spatial reasoning, logical thinking, and problem-solving skills that benefit you beyond gaming.

Timeless Appeal

As a remake of a 40-year-old classic, Sokoban has proven its lasting appeal. The simple yet deep gameplay mechanics create puzzles that remain engaging regardless of gaming trends.

Perfect for Short Sessions

Each level can be completed in minutes, making Sokoban ideal for quick mental breaks or longer puzzle-solving sessions. The move counter system encourages repeated play to achieve optimal solutions.

Accessible to Everyone

With straightforward rules and intuitive controls, Sokoban welcomes players of all ages and gaming experience levels. The clean, minimalist graphics ensure the focus stays on pure puzzle solving.

Frequently Asked Questions (FAQ)