Stack Block Game is a JavaScript-based project that challenges players to stack blocks on top of each other, aiming to build the tallest tower possible. The objective is to precisely position each block; the game concludes if a block is inaccurately placed on the stack.
This game utilizes HTML, CSS, and JavaScript alongside Three.js and Cannon.js libraries to create an interactive and visually engaging stacking experience. By leveraging physics simulations, it offers players an immersive and challenging gameplay environment.
The game offers an autopilot mode, allowing it to play itself automatically. This feature showcases various stacking strategies and techniques.
To prevent rapid and unintentional inputs, a 500 milliseconds cooldown period is enforced between consecutive inputs. This enhances gameplay by promoting thoughtful and deliberate actions.
Players can reset the game at any point by pressing the 'R' or 'r' key. This functionality provides convenience and allows for restarting the game seamlessly.
This function manages game input events. In autopilot mode, it initiates the game. Otherwise, it calls the splitBlockAndAddNextOneIfOverlaps()
function.
Responsible for handling the logic of splitting blocks and adding the next one. It computes sizes, deltas, overhangs, and overlaps. When an overlap occurs, a click sound is triggered, and the block is cut accordingly.
Initiates a game reset when triggered by the 'R' or 'r' keypress. It prevents the default action and starts the game afresh, providing users with a convenient restart option.
- Game Start: Launch the game by pressing the 'R' or 'r' key.
- Stacking Strategy: Precisely stack the blocks to create a towering structure.
- Game End: If a block is inaccurately placed, the game concludes.
- Reset: To restart the game, press the 'R' or 'r' key again.
To run the game locally:
- Clone this repository:
git clone https://github.com/your-username/stack-block-game.git
- run "npm i" to install any dependencies
- Navigate to the project directory:
cd stack-block-game
- Open
index.html
in a web browser.
Alternatively, the game is accessible online Here.