Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
81 lines (75 loc) · 3.39 KB
/
Copy pathindex.html
File metadata and controls
81 lines (75 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/logo.png" />
<link rel="manifest" href="/manifest.json" />
<meta name="theme-color" content="#141e30" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<title>PythonQuest</title>
<!-- Google Fonts: Press Start 2P -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.js"></script>
<script>
function scaleGame() {
var root = document.getElementById('root');
if (!root) return;
var GAME_W = 480;
var GAME_H = 620;
var scaleX = (window.innerWidth * 0.98) / GAME_W;
var scaleY = (window.innerHeight * 0.98) / GAME_H;
var scale = Math.min(scaleX, scaleY);
root.style.transform = 'scale(' + scale + ')';
}
window.addEventListener('load', scaleGame);
window.addEventListener('resize', scaleGame);
window.addEventListener('orientationchange', function() {
setTimeout(scaleGame, 150);
});
// Bloqueia zoom por pinça e duplo toque
document.addEventListener('touchstart', function(e) {
if (e.touches.length > 1) e.preventDefault();
}, { passive: false });
var lastTap = 0;
document.addEventListener('touchend', function(e) {
var now = Date.now();
if (now - lastTap < 300) e.preventDefault();
lastTap = now;
}, { passive: false });
// iOS Safari
document.addEventListener('gesturestart', function(e) { e.preventDefault(); }, { passive: false });
document.addEventListener('gesturechange', function(e) { e.preventDefault(); }, { passive: false });
document.addEventListener('gestureend', function(e) { e.preventDefault(); }, { passive: false });
// Bloqueia wheel zoom (trackpad/desktop)
window.addEventListener('wheel', function(e) {
if (e.ctrlKey) e.preventDefault();
}, { passive: false });
// Reseta o viewport se o zoom mudar — força voltar para scale 1.0
function resetViewportZoom() {
var viewport = document.querySelector('meta[name=viewport]');
if (!viewport) return;
// Força reset removendo e readicionando o meta tag
viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover');
scaleGame();
}
// Detecta mudança de zoom pelo visualViewport
if (window.visualViewport) {
window.visualViewport.addEventListener('resize', function() {
// Se o scale do viewport mudou, reseta
if (Math.abs(window.visualViewport.scale - 1.0) > 0.05) {
resetViewportZoom();
}
});
}
</script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>