Spaces:
Running
Running
create a 100 percent same 2d version of a minecraft game
Browse files- index.html +4 -2
- minecraft2d.html +185 -0
index.html
CHANGED
|
@@ -69,7 +69,8 @@
|
|
| 69 |
<a href="#quantities" class="py-2 px-3 hover:bg-indigo-700 rounded transition duration-300">Quantities</a>
|
| 70 |
<a href="#instruments" class="py-2 px-3 hover:bg-indigo-700 rounded transition duration-300">Instruments</a>
|
| 71 |
<a href="midjourney.html" class="py-2 px-3 hover:bg-indigo-700 rounded transition duration-300">AI Art Generator</a>
|
| 72 |
-
|
|
|
|
| 73 |
<div class="md:hidden flex items-center">
|
| 74 |
<button class="outline-none mobile-menu-button">
|
| 75 |
<i data-feather="menu" class="w-6 h-6"></i>
|
|
@@ -82,7 +83,8 @@
|
|
| 82 |
<a href="#branches" class="block py-2 px-4 text-sm hover:bg-indigo-700">Branches</a>
|
| 83 |
<a href="#quantities" class="block py-2 px-4 text-sm hover:bg-indigo-700">Quantities</a>
|
| 84 |
<a href="#instruments" class="block py-2 px-4 text-sm hover:bg-indigo-700">Instruments</a>
|
| 85 |
-
|
|
|
|
| 86 |
</div>
|
| 87 |
</nav>
|
| 88 |
|
|
|
|
| 69 |
<a href="#quantities" class="py-2 px-3 hover:bg-indigo-700 rounded transition duration-300">Quantities</a>
|
| 70 |
<a href="#instruments" class="py-2 px-3 hover:bg-indigo-700 rounded transition duration-300">Instruments</a>
|
| 71 |
<a href="midjourney.html" class="py-2 px-3 hover:bg-indigo-700 rounded transition duration-300">AI Art Generator</a>
|
| 72 |
+
<a href="minecraft2d.html" class="py-2 px-3 hover:bg-indigo-700 rounded transition duration-300">2D Minecraft</a>
|
| 73 |
+
</div>
|
| 74 |
<div class="md:hidden flex items-center">
|
| 75 |
<button class="outline-none mobile-menu-button">
|
| 76 |
<i data-feather="menu" class="w-6 h-6"></i>
|
|
|
|
| 83 |
<a href="#branches" class="block py-2 px-4 text-sm hover:bg-indigo-700">Branches</a>
|
| 84 |
<a href="#quantities" class="block py-2 px-4 text-sm hover:bg-indigo-700">Quantities</a>
|
| 85 |
<a href="#instruments" class="block py-2 px-4 text-sm hover:bg-indigo-700">Instruments</a>
|
| 86 |
+
<a href="midjourney.html" class="block py-2 px-4 text-sm hover:bg-indigo-700">AI Art Generator</a>
|
| 87 |
+
<a href="minecraft2d.html" class="block py-2 px-4 text-sm hover:bg-indigo-700">2D Minecraft</a>
|
| 88 |
</div>
|
| 89 |
</nav>
|
| 90 |
|
minecraft2d.html
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>2D Minecraft | Physics Visualizer Pro</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<style>
|
| 9 |
+
canvas {
|
| 10 |
+
border: 1px solid #333;
|
| 11 |
+
background-color: #87CEEB;
|
| 12 |
+
display: block;
|
| 13 |
+
margin: 0 auto;
|
| 14 |
+
}
|
| 15 |
+
#inventory {
|
| 16 |
+
display: flex;
|
| 17 |
+
justify-content: center;
|
| 18 |
+
margin: 10px 0;
|
| 19 |
+
}
|
| 20 |
+
.block-item {
|
| 21 |
+
border: 2px solid transparent;
|
| 22 |
+
margin: 0 5px;
|
| 23 |
+
cursor: pointer;
|
| 24 |
+
}
|
| 25 |
+
.block-item.selected {
|
| 26 |
+
border-color: #4f46e5;
|
| 27 |
+
}
|
| 28 |
+
</style>
|
| 29 |
+
</head>
|
| 30 |
+
<body class="bg-gray-100">
|
| 31 |
+
<nav class="bg-indigo-600 text-white shadow-lg">
|
| 32 |
+
<div class="container mx-auto px-6 py-3">
|
| 33 |
+
<div class="flex justify-between items-center">
|
| 34 |
+
<div class="flex space-x-4">
|
| 35 |
+
<div>
|
| 36 |
+
<a href="#" class="flex items-center py-2 px-2">
|
| 37 |
+
<i data-feather="atom" class="mr-2"></i>
|
| 38 |
+
<span class="font-bold text-lg">Physics Visualizer Pro</span>
|
| 39 |
+
</a>
|
| 40 |
+
</div>
|
| 41 |
+
</div>
|
| 42 |
+
<div class="hidden md:flex items-center space-x-1">
|
| 43 |
+
<a href="index.html" class="py-2 px-3 hover:bg-indigo-700 rounded transition duration-300">Home</a>
|
| 44 |
+
<a href="minecraft2d.html" class="py-2 px-3 bg-indigo-700 rounded hover:bg-indigo-800 transition duration-300">2D Minecraft</a>
|
| 45 |
+
</div>
|
| 46 |
+
</div>
|
| 47 |
+
</div>
|
| 48 |
+
</nav>
|
| 49 |
+
|
| 50 |
+
<div class="container mx-auto px-4 py-8">
|
| 51 |
+
<h1 class="text-3xl font-bold text-center mb-6">2D Minecraft</h1>
|
| 52 |
+
|
| 53 |
+
<div class="max-w-3xl mx-auto bg-white p-6 rounded-lg shadow-md">
|
| 54 |
+
<div id="inventory">
|
| 55 |
+
<div class="block-item selected" data-block="dirt">
|
| 56 |
+
<img src="https://static.photos/agriculture/64x64/1" alt="Dirt" width="64" height="64">
|
| 57 |
+
</div>
|
| 58 |
+
<div class="block-item" data-block="stone">
|
| 59 |
+
<img src="https://static.photos/construction/64x64/2" alt="Stone" width="64" height="64">
|
| 60 |
+
</div>
|
| 61 |
+
<div class="block-item" data-block="wood">
|
| 62 |
+
<img src="https://static.photos/agriculture/64x64/3" alt="Wood" width="64" height="64">
|
| 63 |
+
</div>
|
| 64 |
+
<div class="block-item" data-block="leaf">
|
| 65 |
+
<img src="https://static.photos/nature/64x64/4" alt="Leaf" width="64" height="64">
|
| 66 |
+
</div>
|
| 67 |
+
</div>
|
| 68 |
+
|
| 69 |
+
<canvas id="gameCanvas" width="800" height="400"></canvas>
|
| 70 |
+
|
| 71 |
+
<div class="mt-4 text-center">
|
| 72 |
+
<p class="text-gray-600 mb-2">Controls: Click to place blocks. Select block type from above.</p>
|
| 73 |
+
<button id="clearBtn" class="bg-red-500 text-white px-4 py-2 rounded hover:bg-red-600">
|
| 74 |
+
Clear World
|
| 75 |
+
</button>
|
| 76 |
+
</div>
|
| 77 |
+
</div>
|
| 78 |
+
</div>
|
| 79 |
+
|
| 80 |
+
<script>
|
| 81 |
+
const canvas = document.getElementById('gameCanvas');
|
| 82 |
+
const ctx = canvas.getContext('2d');
|
| 83 |
+
let selectedBlock = 'dirt';
|
| 84 |
+
|
| 85 |
+
// Block textures (using placeholder images)
|
| 86 |
+
const blockTextures = {
|
| 87 |
+
dirt: 'https://static.photos/agriculture/32x32/1',
|
| 88 |
+
stone: 'https://static.photos/construction/32x32/2',
|
| 89 |
+
wood: 'https://static.photos/agriculture/32x32/3',
|
| 90 |
+
leaf: 'https://static.photos/nature/32x32/4'
|
| 91 |
+
};
|
| 92 |
+
|
| 93 |
+
// Game grid
|
| 94 |
+
const gridSize = 32;
|
| 95 |
+
const gridWidth = canvas.width / gridSize;
|
| 96 |
+
const gridHeight = canvas.height / gridSize;
|
| 97 |
+
let world = Array(gridWidth).fill().map(() => Array(gridHeight).fill(null));
|
| 98 |
+
|
| 99 |
+
// Generate simple terrain
|
| 100 |
+
function generateTerrain() {
|
| 101 |
+
const groundLevel = Math.floor(gridHeight * 0.7);
|
| 102 |
+
|
| 103 |
+
for (let x = 0; x < gridWidth; x++) {
|
| 104 |
+
// Base ground layer
|
| 105 |
+
for (let y = groundLevel; y < gridHeight; y++) {
|
| 106 |
+
world[x][y] = 'dirt';
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
// Stone layer below ground
|
| 110 |
+
for (let y = groundLevel + 3; y < gridHeight; y++) {
|
| 111 |
+
world[x][y] = 'stone';
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
// Add some surface features
|
| 115 |
+
if (x % 10 === 0 && x > 0 && x < gridWidth - 5) {
|
| 116 |
+
// Tree
|
| 117 |
+
const treeHeight = 5;
|
| 118 |
+
for (let y = groundLevel - 1; y >= groundLevel - treeHeight; y--) {
|
| 119 |
+
world[x][y] = 'wood';
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
// Tree leaves
|
| 123 |
+
for (let dx = -2; dx <= 2; dx++) {
|
| 124 |
+
if (x + dx >= 0 && x + dx < gridWidth) {
|
| 125 |
+
world[x + dx][groundLevel - treeHeight - 1] = 'leaf';
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
// Draw the world
|
| 133 |
+
function drawWorld() {
|
| 134 |
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
| 135 |
+
|
| 136 |
+
// Sky
|
| 137 |
+
ctx.fillStyle = '#87CEEB';
|
| 138 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
| 139 |
+
|
| 140 |
+
// Draw blocks
|
| 141 |
+
for (let x = 0; x < gridWidth; x++) {
|
| 142 |
+
for (let y = 0; y < gridHeight; y++) {
|
| 143 |
+
if (world[x][y]) {
|
| 144 |
+
const img = new Image();
|
| 145 |
+
img.src = blockTextures[world[x][y]];
|
| 146 |
+
ctx.drawImage(img, x * gridSize, y * gridSize, gridSize, gridSize);
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
// Handle block selection
|
| 153 |
+
document.querySelectorAll('.block-item').forEach(item => {
|
| 154 |
+
item.addEventListener('click', () => {
|
| 155 |
+
document.querySelectorAll('.block-item').forEach(i => i.classList.remove('selected'));
|
| 156 |
+
item.classList.add('selected');
|
| 157 |
+
selectedBlock = item.dataset.block;
|
| 158 |
+
});
|
| 159 |
+
});
|
| 160 |
+
|
| 161 |
+
// Handle canvas clicks
|
| 162 |
+
canvas.addEventListener('click', (e) => {
|
| 163 |
+
const rect = canvas.getBoundingClientRect();
|
| 164 |
+
const x = Math.floor((e.clientX - rect.left) / gridSize);
|
| 165 |
+
const y = Math.floor((e.clientY - rect.top) / gridSize);
|
| 166 |
+
|
| 167 |
+
if (x >= 0 && x < gridWidth && y >= 0 && y < gridHeight) {
|
| 168 |
+
world[x][y] = selectedBlock;
|
| 169 |
+
drawWorld();
|
| 170 |
+
}
|
| 171 |
+
});
|
| 172 |
+
|
| 173 |
+
// Clear button
|
| 174 |
+
document.getElementById('clearBtn').addEventListener('click', () => {
|
| 175 |
+
world = Array(gridWidth).fill().map(() => Array(gridHeight).fill(null));
|
| 176 |
+
generateTerrain();
|
| 177 |
+
drawWorld();
|
| 178 |
+
});
|
| 179 |
+
|
| 180 |
+
// Initialize game
|
| 181 |
+
generateTerrain();
|
| 182 |
+
drawWorld();
|
| 183 |
+
</script>
|
| 184 |
+
</body>
|
| 185 |
+
</html>
|