mirror of
https://github.com/litruv/lit.ruv.wtf.git
synced 2026-07-25 03:06:02 +10:00
mobile fixes
This commit is contained in:
@@ -30,6 +30,10 @@ METADATA:{
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: block;
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mining-ui {
|
.mining-ui {
|
||||||
@@ -40,7 +44,7 @@ METADATA:{
|
|||||||
font-family: 'Minecraft', monospace; /* Fallback */
|
font-family: 'Minecraft', monospace; /* Fallback */
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
text-shadow: 2px 2px 0 #000;
|
text-shadow: 2px 2px 0 #000;
|
||||||
z-index: 10;
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mining-stat {
|
.mining-stat {
|
||||||
@@ -59,8 +63,26 @@ METADATA:{
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
|
overflow-x: auto;
|
||||||
|
max-width: 95%;
|
||||||
|
white-space: nowrap;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
/* Scrollbar styling for inventory */
|
||||||
|
.inventory-container::-webkit-scrollbar {
|
||||||
|
height: 6px;
|
||||||
|
}
|
||||||
|
.inventory-container::-webkit-scrollbar-track {
|
||||||
|
background: rgba(0,0,0,0.3);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
.inventory-container::-webkit-scrollbar-thumb {
|
||||||
|
background: rgba(255,255,255,0.3);
|
||||||
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
.inventory-slot {
|
.inventory-slot {
|
||||||
|
flex: 0 0 auto; /* Don't shrink */
|
||||||
width: 40px;
|
width: 40px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
background: rgba(255, 255, 255, 0.1);
|
background: rgba(255, 255, 255, 0.1);
|
||||||
@@ -96,6 +118,22 @@ METADATA:{
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
pointer-events: auto; /* Allow clicking */
|
pointer-events: auto; /* Allow clicking */
|
||||||
|
overflow-y: auto;
|
||||||
|
max-height: 60vh;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
/* Scrollbar styling for crafting */
|
||||||
|
.crafting-container::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
.crafting-container::-webkit-scrollbar-track {
|
||||||
|
background: rgba(0,0,0,0.3);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
.crafting-container::-webkit-scrollbar-thumb {
|
||||||
|
background: rgba(255,255,255,0.3);
|
||||||
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
.crafting-slot {
|
.crafting-slot {
|
||||||
width: 40px;
|
width: 40px;
|
||||||
@@ -151,21 +189,24 @@ METADATA:{
|
|||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
font-family: 'Minecraft', monospace;
|
font-family: 'Minecraft', monospace;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
z-index: 20;
|
z-index: 100;
|
||||||
}
|
}
|
||||||
.shop-container {
|
.shop-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 10%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translateX(-50%);
|
||||||
background: rgba(0, 0, 0, 0.9);
|
background: rgba(0, 0, 0, 0.9);
|
||||||
border: 2px solid #555;
|
border: 2px solid #555;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
color: white;
|
color: white;
|
||||||
font-family: 'Minecraft', monospace;
|
font-family: 'Minecraft', monospace;
|
||||||
display: none;
|
display: none;
|
||||||
z-index: 30;
|
z-index: 101;
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
|
max-height: 80vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
}
|
}
|
||||||
.shop-section {
|
.shop-section {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
@@ -224,6 +265,35 @@ METADATA:{
|
|||||||
.shop-container .close-btn:hover {
|
.shop-container .close-btn:hover {
|
||||||
background: #f44336;
|
background: #f44336;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fullscreen-btn {
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
right: 80px;
|
||||||
|
background: #2196F3;
|
||||||
|
color: white;
|
||||||
|
border: 2px solid #1976D2;
|
||||||
|
padding: 5px 10px;
|
||||||
|
font-family: 'Minecraft', monospace;
|
||||||
|
cursor: pointer;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
.fullscreen-btn:hover {
|
||||||
|
background: #42A5F5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mining-container:fullscreen {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
max-width: none;
|
||||||
|
aspect-ratio: auto;
|
||||||
|
border: none;
|
||||||
|
background: #87CEEB; /* Match sky color */
|
||||||
|
}
|
||||||
|
.mining-container:fullscreen #game-canvas {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<!-- END_STYLES -->
|
<!-- END_STYLES -->
|
||||||
|
|
||||||
@@ -245,15 +315,16 @@ METADATA:{
|
|||||||
<div class="mining-stat">Depth: <span id="depth-counter">0</span></div>
|
<div class="mining-stat">Depth: <span id="depth-counter">0</span></div>
|
||||||
<div class="mining-stat">Score: <span id="score-counter">0</span></div>
|
<div class="mining-stat">Score: <span id="score-counter">0</span></div>
|
||||||
</div>
|
</div>
|
||||||
|
<button id="fullscreen-btn" class="fullscreen-btn" onclick="toggleFullscreen()">[ ]</button>
|
||||||
<button id="shop-btn" class="shop-btn" onclick="toggleShop()">Shop</button>
|
<button id="shop-btn" class="shop-btn" onclick="toggleShop()">Shop</button>
|
||||||
<div id="shop-modal" class="shop-container" style="display:none; flex-direction:column; max-height: 80vh; overflow-y: auto;">
|
|
||||||
<div id="shop-content"></div>
|
|
||||||
</div>
|
|
||||||
<div id="inventory-display" class="inventory-container">
|
<div id="inventory-display" class="inventory-container">
|
||||||
<!-- Slots will be added here dynamically -->
|
<!-- Slots will be added here dynamically -->
|
||||||
</div>
|
</div>
|
||||||
<div id="crafting-display" class="crafting-container">
|
<div id="crafting-display" class="crafting-container">
|
||||||
<!-- Crafting slots will be added here dynamically -->
|
<!-- Crafting slots will be added here dynamically -->
|
||||||
</div>
|
</div>
|
||||||
|
<div id="shop-modal" class="shop-container" style="display:none; flex-direction:column; max-height: 80vh; overflow-y: auto;">
|
||||||
|
<div id="shop-content"></div>
|
||||||
|
</div>
|
||||||
<canvas id="game-canvas"></canvas>
|
<canvas id="game-canvas"></canvas>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
camera.updateProjectionMatrix();
|
camera.updateProjectionMatrix();
|
||||||
|
|
||||||
const renderer = new THREE.WebGLRenderer({ canvas: canvas, alpha: false, antialias: true });
|
const renderer = new THREE.WebGLRenderer({ canvas: canvas, alpha: false, antialias: true });
|
||||||
renderer.setSize(canvas.clientWidth, canvas.clientHeight);
|
renderer.setSize(canvas.clientWidth, canvas.clientHeight, false);
|
||||||
renderer.setPixelRatio(window.devicePixelRatio);
|
renderer.setPixelRatio(window.devicePixelRatio);
|
||||||
// renderer.outputEncoding = THREE.sRGBEncoding; // We use GammaCorrectionShader instead
|
// renderer.outputEncoding = THREE.sRGBEncoding; // We use GammaCorrectionShader instead
|
||||||
renderer.shadowMap.enabled = true;
|
renderer.shadowMap.enabled = true;
|
||||||
@@ -993,12 +993,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
vector.project(camera);
|
vector.project(camera);
|
||||||
|
|
||||||
const canvas = renderer.domElement;
|
const canvas = renderer.domElement;
|
||||||
const rect = canvas.getBoundingClientRect();
|
// Use relative coordinates for the container
|
||||||
const scrollX = window.scrollX || window.pageXOffset;
|
const x = (vector.x + 1) / 2 * canvas.clientWidth;
|
||||||
const scrollY = window.scrollY || window.pageYOffset;
|
const y = -(vector.y - 1) / 2 * canvas.clientHeight;
|
||||||
|
|
||||||
const x = (vector.x + 1) / 2 * rect.width + rect.left + scrollX;
|
|
||||||
const y = -(vector.y - 1) / 2 * rect.height + rect.top + scrollY;
|
|
||||||
|
|
||||||
// Create 2D floating item
|
// Create 2D floating item
|
||||||
createFloatingItem(drop.userData.type, x - 16, y - 16, drop.userData.count || 1);
|
createFloatingItem(drop.userData.type, x - 16, y - 16, drop.userData.count || 1);
|
||||||
@@ -1721,9 +1718,16 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle resize
|
// Handle resize
|
||||||
window.addEventListener('resize', () => {
|
const resizeObserver = new ResizeObserver(() => {
|
||||||
const aspect = canvas.clientWidth / canvas.clientHeight;
|
const width = canvas.clientWidth;
|
||||||
const d = 5;
|
const height = canvas.clientHeight;
|
||||||
|
|
||||||
|
if (width === 0 || height === 0) return;
|
||||||
|
|
||||||
|
const aspect = width / height;
|
||||||
|
// Dynamic view size based on grid size
|
||||||
|
const d = 5 + (upgrades.grid_size || 0);
|
||||||
|
|
||||||
camera.left = -d * aspect;
|
camera.left = -d * aspect;
|
||||||
camera.right = d * aspect;
|
camera.right = d * aspect;
|
||||||
camera.top = d;
|
camera.top = d;
|
||||||
@@ -1731,9 +1735,11 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
camera.updateProjectionMatrix();
|
camera.updateProjectionMatrix();
|
||||||
|
|
||||||
renderer.setPixelRatio(window.devicePixelRatio);
|
renderer.setPixelRatio(window.devicePixelRatio);
|
||||||
renderer.setSize(canvas.clientWidth, canvas.clientHeight, false);
|
renderer.setSize(width, height, false);
|
||||||
composer.setSize(canvas.clientWidth, canvas.clientHeight);
|
composer.setSize(width, height);
|
||||||
|
if (ssaoPass) ssaoPass.setSize(width, height);
|
||||||
});
|
});
|
||||||
|
resizeObserver.observe(canvas);
|
||||||
|
|
||||||
// Start
|
// Start
|
||||||
initGame();
|
initGame();
|
||||||
@@ -1877,6 +1883,18 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fullscreen
|
||||||
|
window.toggleFullscreen = function() {
|
||||||
|
const elem = document.querySelector('.mining-container');
|
||||||
|
if (!document.fullscreenElement) {
|
||||||
|
elem.requestFullscreen().catch(err => {
|
||||||
|
console.error(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
document.exitFullscreen();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Shop System
|
// Shop System
|
||||||
window.toggleShop = function() {
|
window.toggleShop = function() {
|
||||||
const shop = document.getElementById('shop-modal');
|
const shop = document.getElementById('shop-modal');
|
||||||
@@ -2287,20 +2305,21 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
img.style.pointerEvents = 'none';
|
img.style.pointerEvents = 'none';
|
||||||
img.style.zIndex = '1000';
|
img.style.zIndex = '1000';
|
||||||
|
|
||||||
document.body.appendChild(img);
|
const container = document.querySelector('.mining-container');
|
||||||
|
container.appendChild(img);
|
||||||
|
|
||||||
// Find target
|
// Find target relative to container
|
||||||
const scrollX = window.scrollX || window.pageXOffset;
|
const containerRect = container.getBoundingClientRect();
|
||||||
const scrollY = window.scrollY || window.pageYOffset;
|
|
||||||
|
// Default target (center bottom if slot not found)
|
||||||
let targetX = (window.innerWidth / 2) + scrollX;
|
let targetX = containerRect.width / 2;
|
||||||
let targetY = (window.innerHeight - 50) + scrollY;
|
let targetY = containerRect.height - 50;
|
||||||
|
|
||||||
const slot = document.querySelector(`.inventory-slot[data-type="${type}"]`);
|
const slot = document.querySelector(`.inventory-slot[data-type="${type}"]`);
|
||||||
if (slot) {
|
if (slot) {
|
||||||
const rect = slot.getBoundingClientRect();
|
const rect = slot.getBoundingClientRect();
|
||||||
targetX = rect.left + rect.width / 2 - 16 + scrollX;
|
targetX = rect.left - containerRect.left + rect.width / 2 - 16;
|
||||||
targetY = rect.top + rect.height / 2 - 16 + scrollY;
|
targetY = rect.top - containerRect.top + rect.height / 2 - 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Control point for Bezier curve
|
// Control point for Bezier curve
|
||||||
@@ -2337,7 +2356,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
requestAnimationFrame(animate);
|
requestAnimationFrame(animate);
|
||||||
} else {
|
} else {
|
||||||
if (img.parentNode) {
|
if (img.parentNode) {
|
||||||
document.body.removeChild(img);
|
img.parentNode.removeChild(img);
|
||||||
}
|
}
|
||||||
addToInventory(type, count);
|
addToInventory(type, count);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user