Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 33 additions & 29 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
## Pull Request Title Convention
# Pull Request Title Convention
Please ensure your PR title follows this format: [Type]: Short, descriptive summary of changes

Examples:
- [Feature]: Implement high score system using localStorage
- [Bugfix]: Resolve camera clipping on narrow viewports
- [CI/CD]: Add code formatting check with Prettier

## 🎯 What issue does this address?
Closes #
🎯 **What issue does this address?**
Closes ### ✨ What does this change?

## ✨ What does this change?
**Checklist:**
- New functionality meets the goals defined in the linked issue.
- If changing the UI or game experience, screenshots or a GIF are included below.
- Code is formatted cleanly (ran Prettier/ESLint locally).
- All CI/CD checks in this PR passed.

## Checklist:
- [ ] New functionality meets the goals defined in the linked issue.
- [ ] If changing the UI or game experience, screenshots or a GIF are included below.
- [ ] Code is formatted cleanly (ran Prettier/ESLint locally).
- [ ] All CI/CD checks in this PR passed.
- [ ] Game mechanics work correctly (blocks stack, physics behave properly).
- [ ] Performance is maintained (no frame drops or lag introduced).
- [ ] Mobile/touch controls still function properly.
- [ ] Game resets correctly with 'R' key.
🖼️ **Screenshots / Video Preview**

## 🖼️ Screenshots / Video Preview
| Before Changes | After Changes |
| :---: | :---: |
|----------------|---------------|
| [Screenshot of old state] | [Screenshot of new state] |

## 🧪 Testing
### Steps to Test Locally (for Reviewer):
1. Clone this branch locally.
2. Open `index.html` in your browser.
3. Test core game functionality:
- Click/tap/spacebar to drop blocks
- Verify blocks stack properly with physics
- Test 'R' key to reset game
- Check mobile touch controls work
4. Verify the changes (e.g., if it's a bug fix, confirm the bug is gone).
5. Check browser console for any new errors or warnings.
6. Test on different screen sizes/devices if UI changes were made.

## 🔗 Related Resources

## 🔗 **Related Issue(s)**
Link the GitHub Issue(s) this PR addresses. Use keywords like Fixes, Closes, or Resolves to automatically close the issue when the PR is merged.
Fixes #123

Resolves #456

## ✅ Checklist (Required)
Please check all boxes that apply and ensure your PR is ready for review.

[ ] I have read the project's [CONTRIBUTING.md] guidelines.

[ ] My code follows the project's coding style and conventions.

[ ] I have performed a self-review of my own code.

[ ] My changes generate no new errors or warnings in the browser console.

[ ] I have tested my changes locally on the Vercel-simulated environment (if applicable).

[ ] For UI changes, I have tested on different screen sizes (responsive design check).

[ ] My commit message(s) are clear and descriptive.
33 changes: 15 additions & 18 deletions script.js → Js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function loadHighScore() {
function saveHighScore(value) {
try {
localStorage.setItem(HIGH_SCORE_KEY, String(Math.max(0, value | 0)));
} catch (_) {}
} catch (_) { }
}

// Initialize the game
Expand Down Expand Up @@ -99,17 +99,17 @@ function createGradientBackground(colors) {
// Function to update scene colors based on current theme
function updateSceneColors() {
if (!scene) return; // Scene not initialized yet

const themeColors = window.themeManager.getCurrentThemeColors();

// Update scene background
scene.background = createGradientBackground(themeColors.sceneBackground);

// Update particle colors if they exist
if (particleData && particleData.particles) {
particleData.particles.material.color.set(themeColors.particleSpecialColor);
}

// We don't update existing blocks' colors, only new ones will use the new theme
}

Expand Down Expand Up @@ -143,7 +143,7 @@ function init() {

// Get theme colors for particles
const themeColors = window.themeManager.getCurrentThemeColors();

const particlesMaterial = new THREE.PointsMaterial({
color: themeColors.particleColor,
size: 0.05,
Expand Down Expand Up @@ -199,7 +199,7 @@ function init() {
camera.lookAt(0, 0, 0);

scene = new THREE.Scene();

// Apply initial theme colors
const initialThemeColors = window.themeManager.getCurrentThemeColors();
scene.background = createGradientBackground(initialThemeColors.sceneBackground);
Expand Down Expand Up @@ -342,11 +342,11 @@ const particleData = createParticles();
// Helper function to generate a box (both in ThreeJS and CannonJS)
function generateBox(x, y, z, width, depth, falls) {
const geometry = new THREE.BoxGeometry(width, boxHeight, depth);

// Get current theme colors for block generation
const themeColors = window.themeManager.getCurrentThemeColors();
const hueBase = themeColors.blockHueBase || 30;

// Create color with theme-based hue
const color = new THREE.Color(`hsl(${hueBase + stack.length * 4}, 100%, 50%)`);
const material = new THREE.MeshLambertMaterial({ color });
Expand Down Expand Up @@ -401,8 +401,6 @@ function cutBox(topLayer, overlap, size, delta) {
topLayer.cannonjs.addShape(shape);
}



// Function to split the block and add the next one if it overlaps
function splitBlockAndAddNextOneIfOverlaps() {
if (gameEnded) return;
Expand Down Expand Up @@ -487,7 +485,7 @@ muteBtn.addEventListener("click", () => {
});

function enableBackgroundMusic() {
sounds.bgm.play().catch(() => {});
sounds.bgm.play().catch(() => { });
}
["mousedown", "touchstart", "keydown"].forEach((evt) =>
window.addEventListener(evt, enableBackgroundMusic, { once: true })
Expand All @@ -497,14 +495,14 @@ function playPlaceSound() {
if (!muted) {
const s = sounds.place.cloneNode();
s.volume = 0.7;
s.play().catch(() => {});
s.play().catch(() => { });
}
}
function playFailSound() {
if (!muted) {
const s = sounds.fail.cloneNode();
s.volume = 0.7;
s.play().catch(() => {});
s.play().catch(() => { });
}
}

Expand Down Expand Up @@ -537,7 +535,7 @@ window.addEventListener(
e.target.closest(".twitter-link") || // The Twitter link
e.target.closest("#muteBtn") || // The mute button
e.target.closest("#theme-controls") || // The theme buttons container
e.target.closest("#close-results")
e.target.closest("#close-results")
) {
// If it was, do nothing and let the browser handle the 'click' event
return;
Expand All @@ -549,6 +547,7 @@ window.addEventListener(
},
{ passive: false }
);

// Close results dialog button
const closeResultsBtn = document.getElementById("close-results");
if (closeResultsBtn) {
Expand Down Expand Up @@ -576,8 +575,6 @@ window.addEventListener("resize", () => {
renderer.render(scene, camera);
});



// ----- Physics Update -----
function updatePhysics(deltaTime) {
world.step(deltaTime / 1000);
Expand All @@ -600,7 +597,7 @@ function animation(time) {
(!autopilot ||
(autopilot &&
top.threejs.position[top.direction] <
prev.threejs.position[top.direction] + robotPrecision));
prev.threejs.position[top.direction] + robotPrecision));

if (moveBox) {
top.threejs.position[top.direction] += 0.008 * deltaTime;
Expand Down
10 changes: 5 additions & 5 deletions themes.js → Js/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const themeButtons = {
function initThemes() {
// Load saved theme from localStorage
loadTheme();

// Add event listeners to theme buttons
for (const theme of AVAILABLE_THEMES) {
const button = themeButtons[theme];
Expand Down Expand Up @@ -91,26 +91,26 @@ function setTheme(theme, save = true) {

// Update current theme
currentTheme = theme;

// Update body class
document.body.classList.remove(...AVAILABLE_THEMES.map(t => `theme-${t}`));
if (theme !== 'default') {
document.body.classList.add(`theme-${theme}`);
}

// Update active button state
for (const t of AVAILABLE_THEMES) {
const button = themeButtons[t];
if (button) {
button.classList.toggle('active', t === theme);
}
}

// Update scene colors if the game has started
if (typeof updateSceneColors === 'function') {
updateSceneColors();
}

// Save theme preference if requested
if (save) {
saveTheme(theme);
Expand Down
46 changes: 0 additions & 46 deletions PULL_REQUEST_TEMPLATE.md

This file was deleted.

28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![Made with Three.js](https://img.shields.io/badge/Made%20with-Three.js-orange.svg)](https://threejs.org/)
[![Contributions Welcome](https://img.shields.io/badge/Contributions-Welcome-blue.svg)](CONTRIBUTING.md)
[![Live Demo](https://img.shields.io/badge/Live%20Demo-Play%20Now-brightgreen.svg)](https://your-username.github.io/3D-Blockstack/)
[![Live Demo](https://img.shields.io/badge/Live%20Demo-Play%20Now-brightgreen.svg)](https://3d-blockstack.vercel.app/)

---

## 🎮 Demo

![Game Screenshot](screenshot.png)
## Light Theme
![Game Screenshot](preview/Light.png)
## Dark Theme
![Game Screenshot](preview/Dark.png)

*Stack blocks with precision and watch them fall with realistic physics!*

---
Expand Down Expand Up @@ -119,7 +123,7 @@
I welcome contributions! Here's how you can help:

### 🐛 Bug Reports
- Use the [GitHub Issues](https://github.com/your-username/3D-Blockstack/issues) tab
- Use the [GitHub Issues](https://github.com/maitri-vv/3D-Blockstack/issues) tab
- Include steps to reproduce the issue
- Specify your browser and device type

Expand Down Expand Up @@ -176,13 +180,25 @@ This project is licensed under the **MIT License** - see the [LICENSE](LICENSE)

---

## 👨‍💻 Author & Maintainer

**[Maitri V V](https://github.com/maitri-vv)**
🎮 Developer & Designer of *3D Blockstack*

📫 **Reach me at:**

* GitHub: [@maitri-vv](https://github.com/maitri-vv)
* LinkedIn: [maitrivaghasiya](https://linkedin.com/in/maitrivaghasiya)
* Twitter: [maitrivv](https://twitter.com/maitrivv)

---

## 📄 We're Still Playing! Shoutout to the Amazing Contributors Who Secured the Win.

<a href="https://github.com/maitri-vv/3S-Blockstack/graphs/contributors">
<img src="https://contrib.rocks/image?repo=maitri-vv/3D-Blockstack" />
<img src="https://contrib.rocks/image?repo=maitri-vv/3D-Blockstack" />
</a>


---
## ⭐ Show Your Support

Expand All @@ -196,4 +212,4 @@ If you enjoyed this game, please give it a ⭐ on GitHub!

*Happy Stacking! 🧱*

</div>
</div>
Loading
Loading