我的世界(2)
2025-10-07 10:00:18
发布于:安徽
<i class="fa fa-star"></i>
</button>
<span class="text-gray-500 text-sm">342 likes</span>
</div>
</div>
<h3 class="text-xl font-bold mb-2 text-minecraft-dark">Epic Castle Generator</h3>
<p class="text-gray-600 mb-4">Generate massive castles with just one command. Customize the size, materials, and features.</p>
<div class="flex justify-between items-center">
<div class="flex items-center">
<img src="https://p11-doubao-search-sign.byteimg.com/labis/99034a695297833f320dc307ca370e9f~tplv-be4g95zd3a-image.jpeg?rk3s=542c0f93&x-expires=1764985935&x-signature=BIKwE0iIkWr6KOdlfZAcB86XBAo%3D" alt="User Avatar" class="w-8 h-8 rounded-full mr-2">
<span class="text-gray-700">BuilderPro</span>
</div>
<button class="text-minecraft-green hover:text-minecraft-dark-green font-medium">
View Project
</button>
</div>
</div>
</div>
<!-- Community Project 2 -->
<div class="bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition-shadow blocky">
<img src="https://p26-doubao-search-sign.byteimg.com/labis/958c3161c4734a99a2bf0ccc169d0eeb~tplv-be4g95zd3a-image.jpeg?rk3s=542c0f93&x-expires=1764985936&x-signature=YrteVhd7ccGOUg2aE6IWfRFdJ7E%3D" alt="Minecraft City" class="w-full h-48 object-cover">
<div class="p-6">
<div class="flex justify-between items-center mb-3">
<span class="bg-green-100 text-green-800 text-xs font-medium px-2.5 py-0.5 rounded">Mod</span>
<div class="flex items-center">
<button class="text-gray-400 hover:text-yellow-500 mr-2">
<i class="fa fa-star"></i>
</button>
<span class="text-gray-500 text-sm">418 likes</span>
</div>
</div>
<h3 class="text-xl font-bold mb-2 text-minecraft-dark">Advanced Redstone Mod</h3>
<p class="text-gray-600 mb-4">Enhance your redstone builds with new components and logic gates. Create complex machines easily.</p>
<div class="flex justify-between items-center">
<div class="flex items-center">
<img src="https://p11-doubao-search-sign.byteimg.com/tos-cn-i-xv4ileqgde/ea9b2543d8344f53b17c410876afe16a~tplv-be4g95zd3a-image.jpeg?rk3s=542c0f93&x-expires=1764985935&x-signature=LutbleO2qmqPklOMG3BI202hFu0%3D" alt="User Avatar" class="w-8 h-8 rounded-full mr-2">
<span class="text-gray-700">RedstoneWizard</span>
</div>
<button class="text-minecraft-green hover:text-minecraft-dark-green font-medium">
View Project
</button>
</div>
</div>
</div>
<!-- Community Project 3 -->
<div class="bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition-shadow blocky">
<img src="https://p26-doubao-search-sign.byteimg.com/labis/5e317cba4790578fbd54044cab215de6~tplv-be4g95zd3a-image.jpeg?rk3s=542c0f93&x-expires=1764985936&x-signature=rs50pPYo7p%2Bxwf%2BQx5hzEeY8rmQ%3D" alt="Minecraft Dungeon" class="w-full h-48 object-cover">
<div class="p-6">
<div class="flex justify-between items-center mb-3">
<span class="bg-blue-100 text-blue-800 text-xs font-medium px-2.5 py-0.5 rounded">Commands</span>
<div class="flex items-center">
<button class="text-gray-400 hover:text-yellow-500 mr-2">
<i class="fa fa-star"></i>
</button>
<span class="text-gray-500 text-sm">276 likes</span>
</div>
</div>
<h3 class="text-xl font-bold mb-2 text-minecraft-dark">Dungeon Generator</h3>
<p class="text-gray-600 mb-4">Generate procedural dungeons with custom loot, enemies, and puzzles. Perfect for adventure maps.</p>
<div class="flex justify-between items-center">
<div class="flex items-center">
<img src="https://p11-doubao-search-sign.byteimg.com/labis/96cba2d918b425d7534decaa9c569c4d~tplv-be4g95zd3a-image.jpeg?rk3s=542c0f93&x-expires=1764985935&x-signature=4%2FnP2JE9nmlRI7WJHZk0Bj58j9Q%3D" alt="User Avatar" class="w-8 h-8 rounded-full mr-2">
<span class="text-gray-700">AdventureMaster</span>
</div>
<button class="text-minecraft-green hover:text-minecraft-dark-green font-medium">
View Project
</button>
</div>
</div>
</div>
</div>
<!-- Share Your Project -->
<div class="mt-12 text-center">
<h3 class="text-2xl font-bold mb-4 text-minecraft-dark-green">Share Your Project</h3>
<p class="text-gray-700 mb-6 max-w-2xl mx-auto">
Have you created something amazing with Minecraft code? Share it with our community and get feedback from other players.
</p>
<button class="bg-minecraft-green hover:bg-minecraft-dark-green text-white py-3 px-6 rounded-lg text-lg font-bold blocky-btn">
Share Your Project
</button>
</div>
</div>
</section>
<!-- Learn Section -->
<section class="py-16 bg-white">
<div class="container mx-auto px-4">
<h2 class="text-3xl md:text-4xl font-bold text-center mb-4 text-minecraft-dark-green">
Learn Minecraft Coding
</h2>
<p class="text-center text-gray-700 mb-12 max-w-2xl mx-auto">
New to Minecraft coding? Check out our tutorials and resources to get started.
</p>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
<!-- Tutorial 1 -->
<div class="bg-minecraft-gray rounded-lg shadow-md overflow-hidden hover:shadow-lg transition-shadow blocky">
<div class="h-40 bg-minecraft-green flex items-center justify-center">
<i class="fa fa-book text-white text-5xl"></i>
</div>
<div class="p-6">
<h3 class="text-xl font-bold mb-2 text-minecraft-dark">Getting Started</h3>
<p class="text-gray-600 mb-4">Learn the basics of Minecraft coding and command blocks.</p>
<button class="text-minecraft-green hover:text-minecraft-dark-green font-medium">
Start Learning
</button>
</div>
</div>
<!-- Tutorial 2 -->
<div class="bg-minecraft-gray rounded-lg shadow-md overflow-hidden hover:shadow-lg transition-shadow blocky">
<div class="h-40 bg-minecraft-brown flex items-center justify-center">
<i class="fa fa-code text-white text-5xl"></i>
</div>
<div class="p-6">
<h3 class="text-xl font-bold mb-2 text-minecraft-dark">Command Blocks</h3>
<p class="text-gray-600 mb-4">Master the art of command blocks and create amazing contraptions.</p>
<button class="text-minecraft-green hover:text-minecraft-dark-green font-medium">
Start Learning
</button>
</div>
</div>
<!-- Tutorial 3 -->
<div class="bg-minecraft-gray rounded-lg shadow-md overflow-hidden hover:shadow-lg transition-shadow blocky">
<div class="h-40 bg-blue-500 flex items-center justify-center">
<i class="fa fa-cubes text-white text-5xl"></i>
</div>
<div class="p-6">
<h3 class="text-xl font-bold mb-2 text-minecraft-dark">Datapacks</h3>
<p class="text-gray-600 mb-4">Create custom gameplay mechanics with datapacks.</p>
<button class="text-minecraft-green hover:text-minecraft-dark-green font-medium">
Start Learning
</button>
</div>
</div>
<!-- Tutorial 4 -->
<div class="bg-minecraft-gray rounded-lg shadow-md overflow-hidden hover:shadow-lg transition-shadow blocky">
<div class="h-40 bg-purple-500 flex items-center justify-center">
<i class="fa fa-wrench text-white text-5xl"></i>
</div>
<div class="p-6">
<h3 class="text-xl font-bold mb-2 text-minecraft-dark">Modding</h3>
<p class="text-gray-600 mb-4">Learn how to create custom mods for Minecraft.</p>
<button class="text-minecraft-green hover:text-minecraft-dark-green font-medium">
Start Learning
</button>
</div>
</div>
</div>
</div>
</section>
<!-- CTA Section -->
<section class="py-16 bg-gradient-to-r from-minecraft-dark-green to-minecraft-green animated-bg text-white">
<div class="container mx-auto px-4 text-center">
<h2 class="text-3xl md:text-4xl font-bold mb-6 text-shadow">
Ready to Start Coding?
</h2>
<p class="text-xl mb-8 max-w-2xl mx-auto">
Join our community of Minecraft coders and start creating amazing things today!
</p>
<div class="flex flex-col sm:flex-row justify-center space-y-4 sm:space-y-0 sm:space-x-4">
<button class="bg-white text-minecraft-green hover:bg-gray-100 py-3 px-6 rounded-lg text-lg font-bold blocky-btn">
Sign Up Free
</button>
<button class="border-2 border-white text-white hover:bg-white hover:text-minecraft-green py-3 px-6 rounded-lg text-lg font-bold transition-colors">
View Documentation
</button>
</div>
</div>
</section>
<!-- Footer -->
<footer class="bg-minecraft-dark text-white py-12">
<div class="container mx-auto px-4">
<div class="grid grid-cols-1 md:grid-cols-4 gap-8">
<!-- Column 1 -->
<div>
<div class="flex items-center space-x-2 mb-4">
<img src="https://p9-flow-imagex-sign.byteimg.com/tos-cn-i-a9rns2rl98/rc/pc/super_tool/e138f73c00bd473083d97e619a8a0c3b~tplv-a9rns2rl98-image.image?rcl=20251007095156DBD77A2F6AD28DB4BE00&rk3s=8e244e95&rrcfp=f06b921b&x-expires=1762393949&x-signature=vvBTIUKX7jUSu1lLfM%2BR6fdxiQ8%3D" alt="Logo" class="h-10 w-10">
<h3 class="text-xl font-bold">Minecraft Code Platform</h3>
</div>
<p class="text-gray-400 mb-4">
Learn to code and create amazing things in Minecraft.
</p>
<div class="flex space-x-4">
<a href="#" class="text-gray-400 hover:text-white transition-colors">
<i class="fa fa-twitter"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white transition-colors">
<i class="fa fa-facebook"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white transition-colors">
<i class="fa fa-instagram"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white transition-colors">
<i class="fa fa-github"></i>
</a>
</div>
</div>
<!-- Column 2 -->
<div>
<h3 class="text-lg font-bold mb-4">Quick Links</h3>
<ul class="space-y-2">
<li><a href="#home" class="text-gray-400 hover:text-white transition-colors">Home</a></li>
<li><a href="#code-library" class="text-gray-400 hover:text-white transition-colors">Code Library</a></li>
<li><a href="#code-editor" class="text-gray-400 hover:text-white transition-colors">Code Editor</a></li>
<li><a href="#community" class="text-gray-400 hover:text-white transition-colors">Community</a></li>
<li><a href="#" class="text-gray-400 hover:text-white transition-colors">Documentation</a></li>
</ul>
</div>
<!-- Column 3 -->
<div>
<h3 class="text-lg font-bold mb-4">Resources</h3>
<ul class="space-y-2">
<li><a href="#" class="text-gray-400 hover:text-white transition-colors">Tutorials</a></li>
<li><a href="#" class="text-gray-400 hover:text-white transition-colors">Guides</a></li>
<li><a href="#" class="text-gray-400 hover:text-white transition-colors">API Reference</a></li>
<li><a href="#" class="text-gray-400 hover:text-white transition-colors">Examples</a></li>
<li><a href="#" class="text-gray-400 hover:text-white transition-colors">FAQ</a></li>
</ul>
</div>
<!-- Column 4 -->
<div>
<h3 class="text-lg font-bold mb-4">Subscribe</h3>
<p class="text-gray-400 mb-4">
Get the latest updates and resources directly to your inbox.
</p>
<form class="flex">
<input type="email" placeholder="Your email" class="px-4 py-2 rounded-l-lg w-full focus:outline-none text-minecraft-dark">
<button type="submit" class="bg-minecraft-green hover:bg-minecraft-light-green px-4 py-2 rounded-r-lg transition-colors">
<i class="fa fa-paper-plane"></i>
</button>
</form>
</div>
</div>
<div class="border-t border-gray-700 mt-8 pt-8 flex flex-col md:flex-row justify-between items-center">
<p class="text-gray-400 text-sm mb-4 md:mb-0">
© 2025 Minecraft Code Platform. All rights reserved.
</p>
<div class="flex space-x-6">
<a href="#" class="text-gray-400 hover:text-white text-sm transition-colors">Privacy Policy</a>
<a href="#" class="text-gray-400 hover:text-white text-sm transition-colors">Terms of Service</a>
<a href="#" class="text-gray-400 hover:text-white text-sm transition-colors">Contact Us</a>
</div>
</div>
</div>
</footer>
<!-- JavaScript -->
<script>
// Mobile Menu Toggle
document.getElementById('mobile-menu-button').addEventListener('click', function() {
const mobileMenu = document.getElementById('mobile-menu');
mobileMenu.classList.toggle('hidden');
});
// Category Buttons
const categoryButtons = document.querySelectorAll('.category-btn');
categoryButtons.forEach(button => {
button.addEventListener('click', function() {
// Remove active class from all buttons
categoryButtons.forEach(btn => {
btn.classList.remove('bg-minecraft-green', 'text-white');
btn.classList.add('bg-white', 'text-minecraft-green', 'hover:bg-minecraft-green', 'hover:text-white');
});
// Add active class to clicked button
this.classList.remove('bg-white', 'text-minecraft-green', 'hover:bg-minecraft-green', 'hover:text-white');
this.classList.add('bg-minecraft-green', 'text-white');
// Filter code cards based on category (would implement actual filtering in a real app)
const category = this.textContent.trim();
console.log(`Filtering by: ${category}`);
});
});
// Code Editor Initialization
let editor;
document.addEventListener('DOMContentLoaded', function() {
// Initialize CodeMirror editor
editor = CodeMirror(document.getElementById('code-editor-container'), {
value: '// Minecraft JavaScript Example\n// Create a custom sword with enchantments\n\nfunction createCustomSword() {\n const sword = new ItemStack(Material.DIAMOND_SWORD);\n const meta = sword.getItemMeta();\n meta.setDisplayName("Excalibur");\n meta.addEnchant(Enchantment.DAMAGE_ALL, 10, true);\n meta.addEnchant(Enchantment.FIRE_ASPECT, 5, true);\n sword.setItemMeta(meta);\n return sword;\n}\n\n// Give the sword to the player\nplayer.getInventory().addItem(createCustomSword());',
mode: 'javascript',
theme: 'dracula',
lineNumbers: true,
matchBrackets: true,
autoCloseBrackets: true,
indentUnit: 2,
tabSize: 2,
lineWrapping: true
});
// Update preview when editor changes
editor.on('change', updatePreview);
// Initialize 3D preview canvas
initPreviewCanvas();
});
// Update Code Preview
function updatePreview() {
const codePreview = document.getElementById('code-preview');
const code = editor.getValue();
if (code.trim() === '') {
codePreview.innerHTML = '<p class="text-gray-500 text-center italic">Your code will be previewed here...</p>';
} else {
codePreview.innerHTML = `<pre class="code-block">${escapeHTML(code)}</pre>`;
}
// Update 3D preview based on code (simplified example)
update3DPreview(code);
}
// Escape HTML for code preview
function escapeHTML(str) {
return str.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}
// Reset Editor
document.getElementById('reset-editor').addEventListener('click', function() {
editor.setValue('// Minecraft JavaScript Example\n// Create a custom sword with enchantments\n\nfunction createCustomSword() {\n const sword = new ItemStack(Material.DIAMOND_SWORD);\n const meta = sword.getItemMeta();\n meta.setDisplayName("Excalibur");\n meta.addEnchant(Enchantment.DAMAGE_ALL, 10, true);\n meta.addEnchant(Enchantment.FIRE_ASPECT, 5, true);\n sword.setItemMeta(meta);\n return sword;\n}\n\n// Give the sword to the player\nplayer.getInventory().addItem(createCustomSword());');
});
// Save Code
document.getElementById('save-code').addEventListener('click', function() {
const code = editor.getValue();
// In a real app, this would save to a database or local storage
alert('Code saved successfully!');
console.log('Saved code:', code);
});
// Language Select
document.getElementById('language-select').addEventListener('change', function() {
const language = this.value;
let mode = 'javascript';
if (language === 'json') {
mode = 'application/json';
} else if (language === 'command') {
mode = 'text/plain'; // Would use a custom mode for Minecraft commands in a real app
}
editor.setOption('mode', mode);
});
// Example Code Buttons
const exampleButtons = document.querySelectorAll('.example-code');
exampleButtons.forEach(button => {
button.addEventListener('click', function() {
const title = this.querySelector('h4').textContent;
if (title === 'Teleport Command') {
editor.setValue('// Minecraft Teleport Command Example\n// Teleport a player to specific coordinates\n\n// Basic teleport command\n/teleport @p 100 70 -50\n\n// Teleport a specific player to another player\n/teleport Notch Steve\n\n// Teleport with rotation\n/teleport @p 100 70 -50 90 0\n\n// Teleport relative to current position\n/teleport @p ~5 ~ ~-10');
} else if (title === 'Custom Item') {
editor.setValue('// Minecraft Custom Item Example\n// Create an item with custom properties\n\nfunction createCustomItem() {\n // Create a new diamond sword\n const item = new ItemStack(Material.DIAMOND_SWORD);\n const meta = item.getItemMeta();\n \n // Set display name\n meta.setDisplayName("Sword of Destruction");\n \n // Add lore\n meta.setLore([\n "Forged in the depths of the nether",\n "Grants immense power to its wielder",\n "One hit kill against all enemies"\n ]);\n \n // Add enchantments\n meta.addEnchant(Enchantment.DAMAGE_ALL, 10, true);\n meta.addEnchant(Enchantment.FIRE_ASPECT, 5, true);\n meta.addEnchant(Enchantment.KNOCKBACK, 3, true);\n \n // Set custom model data (for resource packs)\n meta.setCustomModelData(12345);\n \n item.setItemMeta(meta);\n return item;\n}\n\n// Give the custom item to the player\nplayer.getInventory().addItem(createCustomItem());');
} else if (title === 'Mob Spawner') {
editor.setValue('// Minecraft Mob Spawner Example\n// Spawn custom mobs with specific attributes\n\nfunction spawnCustomZombie(location) {\n // Create a new zombie entity\n const zombie = world.spawnEntity(EntityType.ZOMBIE, location);\n \n // Set custom name\n zombie.setCustomName("Undead Warrior");\n zombie.setCustomNameVisible(true);\n \n // Set health and attributes\n zombie.setHealth(40); // Default is 20\n \n // Set equipment\n zombie.setItemInHand(Hand.MAIN_HAND, new ItemStack(Material.IRON_SWORD));\n zombie.setItemInHand(Hand.OFF_HAND, new ItemStack(Material.SHIELD));\n zombie.setHelmet(new ItemStack(Material.IRON_HELMET));\n zombie.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));\n zombie.setLeggings(new ItemStack(Material.IRON_LEGGINGS));\n zombie.setBoots(new ItemStack(Material.IRON_BOOTS));\n \n // Add custom attributes\n const attributes = zombie.getAttributeManager();\n attributes.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.35);\n attributes.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE).setBaseValue(8);\n \n return zombie;\n}\n\n// Spawn the custom zombie at the player\'s location\nconst playerLocation = player.getLocation();\nconst spawnLocation = new Location(\n playerLocation.getWorld(),\n playerLocation.getX() + 5,\n playerLocation.getY(),\n playerLocation.getZ()\n);\n\nspawnCustomZombie(spawnLocation);');
}
});
});
// Preview Canvas Initialization
function initPreviewCanvas() {
const canvas = document.getElementById('preview-canvas');
const ctx = canvas.getContext('2d');
// Set canvas dimensions
function resizeCanvas() {
const container = document.getElementById('3d-preview');
canvas.width = container.clientWidth;
canvas.height = container.clientHeight;
drawPreview();
}
// Initial resize and draw
resizeCanvas();
// Resize on window resize
window.addEventListener('resize', resizeCanvas);
// Draw initial preview
function drawPreview() {
// Clear canvas
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Draw sky background
const gradient = ctx.createLinearGradient(0, 0, 0, canvas.height);
gradient.addColorStop(0, '#87CEEB');
gradient.addColorStop(1, '#B0E2FF');
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Draw sun
ctx.fillStyle = '#FFD700';
ctx.beginPath();
ctx.arc(canvas.width - 50, 50, 30, 0, Math.PI * 2);
ctx.fill();
// Draw grass
ctx.fillStyle = '#71A95A';
ctx.fillRect(0, canvas.height - 60, canvas.width, 60);
// Draw dirt
ctx.fillStyle = '#8B5A2B';
ctx.fillRect(0, canvas.height - 20, canvas.width, 20);
// Draw a simple block structure
drawBlock(canvas.width / 2 - 30, canvas.height - 80, 60, 60, '#A0522D'); // Log
drawBlock(canvas.width / 2 - 10, canvas.height - 140, 20, 60, '#228B22'); // Trunk
drawBlock(canvas.width / 2 - 50, canvas.height - 160, 100, 20, '#228B22'); // Leaves
drawBlock(canvas.width / 2 - 70, canvas.height - 180, 140, 20, '#228B22'); // Leaves
drawBlock(canvas.width / 2 - 30, canvas.height - 200, 60, 20, '#228B22'); // Leaves
}
// Draw a block with Minecraft-style shading
function drawBlock(x, y, width, height, color) {
// Main block
ctx.fillStyle = color;
ctx.fillRect(x, y, width, height);
// Top shading
ctx.fillStyle = darkenColor(color, 0.3);
ctx.fillRect(x, y, width, height / 4);
// Left shading
ctx.fillStyle = darkenColor(color, 0.2);
ctx.fillRect(x, y, width / 4, height);
// Right highlight
ctx.fillStyle = lightenColor(color, 0.3);
ctx.fillRect(x + width * 0.75, y, width / 4, height);
// Bottom highlight
ctx.fillStyle = lightenColor(color, 0.2);
ctx.fillRect(x, y + height * 0.75, width, height / 4);
}
// Helper function to darken a color
function darkenColor(color, factor) {
const hex = color.replace('#', '');
const r = parseInt(hex.substring(0, 2), 16);
const g = parseInt(hex.substring(2, 4), 16);
const b = parseInt(hex.substring(4, 6), 16);
return `rgb(${Math.floor(r * (1 - factor))}, ${Math.floor(g * (1 - factor))}, ${Math.floor(b * (1 - factor))})`;
}
// Helper function to lighten a color
function lightenColor(color, factor) {
const hex = color.replace('#', '');
const r = parseInt(hex.substring(0, 2), 16);
const g = parseInt(hex.substring(2, 4), 16);
const b = parseInt(hex.substring(4, 6), 16);
return `rgb(${Math.min(255, Math.floor(r * (1 + factor)))}, ${Math.min(255, Math.floor(g * (1 + factor)))}, ${Math.min(255, Math.floor(b * (1 + factor)))})`;
}
// Initial draw
drawPreview();
// Store draw function for later use
window.drawPreview = drawPreview;
}
// Update 3D Preview based on code
function update3DPreview(code) {
// In a real app, this would parse the code and update the 3D preview accordingly
// For this demo, we'll just add some random elements based on code content
const canvas = document.getElementById('preview-canvas');
const ctx = canvas.getContext('2d');
// Clear canvas
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Draw sky background
const gradient = ctx.createLinearGradient(0, 0, 0, canvas.height);
gradient.addColorStop(0, '#87CEEB');
gradient.addColorStop(1, '#B0E2FF');
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Draw sun
ctx.fillStyle = '#FFD700';
ctx.beginPath();
ctx.arc(canvas.width - 50, 50, 30, 0, Math.PI * 2);
ctx.fill();
// Draw grass
ctx.fillStyle = '#71A95A';
ctx.fillRect(0, canvas.height - 60, canvas.width, 60);
// Draw dirt
ctx.fillStyle = '#8B5A2B';
ctx.fillRect(0, canvas.height - 20, canvas.width, 20);
// Simple code analysis
const hasSword = code.includes('sword') || code.includes('Sword');
const hasTeleport = code.includes('teleport') || code.includes('Teleport');
const hasMob = code.includes('zombie') || code.includes('Zombie') || code.includes('mob') || code.includes('Mob');
const hasItem = code.includes('item') || code.includes('Item');
// Draw structures based on code content
if (hasSword) {
// Draw a sword in a stone pedestal
drawBlock(canvas.width / 2 - 20, canvas.height - 80, 40, 40, '#A0522D'); // Pedestal base
drawBlock(canvas.width / 2 - 10, canvas.height - 120, 20, 40, '#A0522D'); // Pedestal top
// Draw sword
ctx.fillStyle = '#C0C0C0';
ctx.fillRect(canvas.width / 2 - 5, canvas.height - 180, 10, 60); // Blade
ctx.fillStyle = '#8B4513';
ctx.fillRect(canvas.width / 2 - 10, canvas.height - 120, 20, 20); // Hilt
} else if (hasTeleport) {
// Draw a teleportation portal
ctx.fillStyle = '#4B0082';
ctx.fillRect(canvas.width / 2 - 30, canvas.height - 120, 60, 80); // Frame
// Portal effect
ctx.fillStyle = '#9932CC';
ctx.beginPath();
ctx.arc(canvas.width / 2, canvas.height - 80, 20, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = '#8A2BE2';
ctx.beginPath();
ctx.arc(canvas.width / 2, canvas.height - 80, 15, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = '#9400D3';
ctx.beginPath();
ctx.arc(canvas.width / 2, canvas.height - 80, 10, 0, Math.PI * 2);
ctx.fill();
} else if (hasMob) {
// Draw a zombie
drawBlock(canvas.width / 2 - 20, canvas.height - 80, 40, 40, '#006400'); // Body
drawBlock(canvas.width / 2 - 10, canvas.height - 120, 20, 20, '#006400'); // Head
drawBlock(canvas.width / 2 - 30, canvas.height - 80, 10, 40, '#006400'); // Left arm
drawBlock(canvas.width / 2 + 20, canvas.height - 80, 10, 40, '#006400'); // Right arm
drawBlock(canvas.width / 2 - 15, canvas.height - 40, 15, 20, '#006400'); // Left leg
drawBlock(canvas.width / 2, canvas.height - 40, 15, 20, '#006400'); // Right leg
// Draw zombie face
ctx.fillStyle = '#FFFFFF';
ctx.fillRect(canvas.width / 2 - 8, canvas.height - 115, 5, 5); // Left eye
ctx.fillRect(canvas.width / 2 + 3, canvas.height - 115, 5, 5); // Right eye
ctx.fillRect(canvas.width / 2 - 5, canvas.height - 105, 10, 5); // Mouth
} else if (hasItem) {
// Draw a chest with items
drawBlock(canvas.width / 2 - 30, canvas.height - 80, 60, 40, '#8B4513'); // Chest
// Draw items
ctx.fillStyle = '#FFD700';
ctx.fillRect(canvas.width / 2 - 20, canvas.height - 90, 10, 10); // Gold ingot
ctx.fillStyle = '#C0C0C0';
ctx.fillRect(canvas.width / 2 - 5, canvas.height - 90, 10, 10); // Iron ingot
ctx.fillStyle = '#00FFFF';
ctx.fillRect(canvas.width / 2 + 10, canvas.height - 90, 10, 10); // Diamond
} else {
// Draw a simple tree
drawBlock(canvas.width / 2 - 30, canvas.height - 80, 60, 60, '#A0522D'); // Log
drawBlock(canvas.width / 2 - 10, canvas.height - 140, 20, 60, '#228B22'); // Trunk
drawBlock(canvas.width / 2 - 50, canvas.height - 160, 100, 20, '#228B22'); // Leaves
drawBlock(canvas.width / 2 - 70, canvas.height - 180, 140, 20, '#228B22'); // Leaves
drawBlock(canvas.width / 2 - 30, canvas.height - 200, 60, 20, '#228B22'); // Leaves
}
}
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 80,
behavior: 'smooth'
});
// Close mobile menu if open
const mobileMenu = document.getElementById('mobile-menu');
if (!mobileMenu.classList.contains('hidden')) {
mobileMenu.classList.add('hidden');
}
}
});
});
// Add scroll event listener for header
window.addEventListener('scroll', function() {
const header = document.querySelector('header');
if (window.scrollY > 50) {
header.classList.add('shadow-md');
} else {
header.classList.remove('shadow-md');
}
});
</script>
</body>
</html>
全部评论 1
接我的世界(1)后面
昨天 来自 安徽
1
有帮助,赞一个