Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>SVG Engine - Documentation</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .code-block { | |
| background-color: #2d3748; | |
| color: #f7fafc; | |
| padding: 1rem; | |
| border-radius: 0.375rem; | |
| font-family: 'Courier New', monospace; | |
| overflow-x: auto; | |
| } | |
| .sidebar { | |
| scrollbar-width: thin; | |
| scrollbar-color: #4a5568 #2d3748; | |
| } | |
| .sidebar::-webkit-scrollbar { | |
| width: 8px; | |
| } | |
| .sidebar::-webkit-scrollbar-track { | |
| background: #2d3748; | |
| } | |
| .sidebar::-webkit-scrollbar-thumb { | |
| background-color: #4a5568; | |
| border-radius: 4px; | |
| } | |
| .feature-card:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1); | |
| } | |
| .gradient-text { | |
| background: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899); | |
| -webkit-background-clip: text; | |
| background-clip: text; | |
| color: transparent; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-900 text-gray-100 min-h-screen flex"> | |
| <!-- Sidebar Navigation --> | |
| <div class="sidebar w-64 bg-gray-800 p-4 hidden md:block overflow-y-auto h-screen sticky top-0"> | |
| <div class="flex items-center mb-8"> | |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-8 h-8 text-purple-500"> | |
| <path fill-rule="evenodd" d="M14.615 1.595a.75.75 0 01.359.852L12.982 9.75h7.268a.75.75 0 01.548 1.262l-10.5 11.25a.75.75 0 01-1.272-.71l1.992-7.302H3.75a.75.75 0 01-.548-1.262l10.5-11.25a.75.75 0 01.913-.143z" clip-rule="evenodd" /> | |
| </svg> | |
| <h1 class="text-2xl font-bold ml-2 gradient-text">SVG Engine</h1> | |
| </div> | |
| <nav> | |
| <ul class="space-y-2"> | |
| <li><a href="#overview" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fas fa-home mr-2 text-blue-400"></i> Overview</a></li> | |
| <li><a href="#getting-started" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fas fa-rocket mr-2 text-green-400"></i> Getting Started</a></li> | |
| <li><a href="#python-api" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fab fa-python mr-2 text-yellow-400"></i> Python API</a></li> | |
| <li> | |
| <details class="group"> | |
| <summary class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition cursor-pointer"> | |
| <i class="fas fa-gamepad mr-2 text-purple-400"></i> Game Components | |
| <i class="fas fa-chevron-down ml-auto text-xs opacity-70 group-open:rotate-180 transition-transform"></i> | |
| </summary> | |
| <ul class="ml-4 mt-1 space-y-1"> | |
| <li><a href="#sprites" class="block px-3 py-2 rounded hover:bg-gray-700 transition">Sprites</a></li> | |
| <li><a href="#animation" class="block px-3 py-2 rounded hover:bg-gray-700 transition">Animation</a></li> | |
| <li><a href="#physics" class="block px-3 py-2 rounded hover:bg-gray-700 transition">Physics</a></li> | |
| <li><a href="#audio" class="block px-3 py-2 rounded hover:bg-gray-700 transition">Audio</a></li> | |
| <li><a href="#input" class="block px-3 py-2 rounded hover:bg-gray-700 transition">Input Handling</a></li> | |
| </ul> | |
| </details> | |
| </li> | |
| <li><a href="#compilation" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fas fa-cogs mr-2 text-red-400"></i> Compilation to SVG</a></li> | |
| <li><a href="#examples" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fas fa-code mr-2 text-indigo-400"></i> Examples</a></li> | |
| <li><a href="#faq" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fas fa-question-circle mr-2 text-pink-400"></i> FAQ</a></li> | |
| </ul> | |
| </nav> | |
| <div class="mt-8 pt-4 border-t border-gray-700"> | |
| <h3 class="text-sm font-semibold text-gray-400 uppercase tracking-wider">Resources</h3> | |
| <ul class="mt-2 space-y-1"> | |
| <li><a href="#" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fas fa-book mr-2 text-blue-400"></i> API Reference</a></li> | |
| <li><a href="#" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fas fa-download mr-2 text-green-400"></i> Download</a></li> | |
| <li><a href="#" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fab fa-github mr-2 text-gray-400"></i> GitHub</a></li> | |
| </ul> | |
| </div> | |
| </div> | |
| <!-- Mobile menu button --> | |
| <button id="mobile-menu-button" class="md:hidden fixed top-4 left-4 z-50 p-2 rounded-md bg-gray-800 text-gray-200"> | |
| <i class="fas fa-bars text-xl"></i> | |
| </button> | |
| <!-- Mobile sidebar (hidden by default) --> | |
| <div id="mobile-sidebar" class="fixed inset-0 z-40 bg-gray-900 bg-opacity-90 hidden"> | |
| <div class="w-3/4 h-full bg-gray-800 p-4 overflow-y-auto"> | |
| <div class="flex justify-between items-center mb-8"> | |
| <div class="flex items-center"> | |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-8 h-8 text-purple-500"> | |
| <path fill-rule="evenodd" d="M14.615 1.595a.75.75 0 01.359.852L12.982 9.75h7.268a.75.75 0 01.548 1.262l-10.5 11.25a.75.75 0 01-1.272-.71l1.992-7.302H3.75a.75.75 0 01-.548-1.262l10.5-11.25a.75.75 0 01.913-.143z" clip-rule="evenodd" /> | |
| </svg> | |
| <h1 class="text-2xl font-bold ml-2 gradient-text">SVG Engine</h1> | |
| </div> | |
| <button id="close-mobile-menu" class="p-2 rounded-md hover:bg-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <nav> | |
| <ul class="space-y-2"> | |
| <li><a href="#overview" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fas fa-home mr-2 text-blue-400"></i> Overview</a></li> | |
| <li><a href="#getting-started" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fas fa-rocket mr-2 text-green-400"></i> Getting Started</a></li> | |
| <li><a href="#python-api" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fab fa-python mr-2 text-yellow-400"></i> Python API</a></li> | |
| <li> | |
| <details class="group"> | |
| <summary class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition cursor-pointer"> | |
| <i class="fas fa-gamepad mr-2 text-purple-400"></i> Game Components | |
| <i class="fas fa-chevron-down ml-auto text-xs opacity-70 group-open:rotate-180 transition-transform"></i> | |
| </summary> | |
| <ul class="ml-4 mt-1 space-y-1"> | |
| <li><a href="#sprites" class="block px-3 py-2 rounded hover:bg-gray-700 transition">Sprites</a></li> | |
| <li><a href="#animation" class="block px-3 py-2 rounded hover:bg-gray-700 transition">Animation</a></li> | |
| <li><a href="#physics" class="block px-3 py-2 rounded hover:bg-gray-700 transition">Physics</a></li> | |
| <li><a href="#audio" class="block px-3 py-2 rounded hover:bg-gray-700 transition">Audio</a></li> | |
| <li><a href="#input" class="block px-3 py-2 rounded hover:bg-gray-700 transition">Input Handling</a></li> | |
| </ul> | |
| </details> | |
| </li> | |
| <li><a href="#compilation" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fas fa-cogs mr-2 text-red-400"></i> Compilation to SVG</a></li> | |
| <li><a href="#examples" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fas fa-code mr-2 text-indigo-400"></i> Examples</a></li> | |
| <li><a href="#faq" class="flex items-center px-3 py-2 rounded hover:bg-gray-700 transition"><i class="fas fa-question-circle mr-2 text-pink-400"></i> FAQ</a></li> | |
| </ul> | |
| </nav> | |
| </div> | |
| </div> | |
| <!-- Main Content --> | |
| <div class="flex-1 p-6 md:p-10 max-w-6xl mx-auto"> | |
| <section id="overview" class="mb-16"> | |
| <div class="flex items-center mb-6"> | |
| <div class="w-10 h-10 rounded-full bg-blue-900 flex items-center justify-center mr-4"> | |
| <i class="fas fa-home text-blue-300"></i> | |
| </div> | |
| <h1 class="text-3xl font-bold">Overview</h1> | |
| </div> | |
| <div class="bg-gray-800 rounded-xl p-6 mb-8 border border-gray-700"> | |
| <h2 class="text-2xl font-semibold mb-4 gradient-text">SVG Game Engine</h2> | |
| <p class="text-gray-300 mb-4"> | |
| The SVG Game Engine is a revolutionary 2D game development framework that compiles Python game code into standalone SVG files. | |
| Unlike traditional game engines that require runtime environments or plugins, games built with SVG Engine run entirely within | |
| modern web browsers using native SVG capabilities. | |
| </p> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mt-6"> | |
| <div class="feature-card bg-gray-750 p-6 rounded-lg border border-gray-700 transition-all duration-300"> | |
| <div class="w-12 h-12 rounded-full bg-purple-900 flex items-center justify-center mb-4"> | |
| <i class="fas fa-bolt text-purple-300 text-xl"></i> | |
| </div> | |
| <h3 class="text-xl font-semibold mb-2">Lightweight</h3> | |
| <p class="text-gray-400">Entire games compile to single SVG files that are typically under 100KB</p> | |
| </div> | |
| <div class="feature-card bg-gray-750 p-6 rounded-lg border border-gray-700 transition-all duration-300"> | |
| <div class="w-12 h-12 rounded-full bg-green-900 flex items-center justify-center mb-4"> | |
| <i class="fab fa-python text-green-300 text-xl"></i> | |
| </div> | |
| <h3 class="text-xl font-semibold mb-2">Python API</h3> | |
| <p class="text-gray-400">Write games in Python with a simple, intuitive API that compiles to SVG</p> | |
| </div> | |
| <div class="feature-card bg-gray-750 p-6 rounded-lg border border-gray-700 transition-all duration-300"> | |
| <div class="w-12 h-12 rounded-full bg-blue-900 flex items-center justify-center mb-4"> | |
| <i class="fas fa-globe text-blue-300 text-xl"></i> | |
| </div> | |
| <h3 class="text-xl font-semibold mb-2">Web Native</h3> | |
| <p class="text-gray-400">Runs anywhere SVG is supported - no plugins or downloads required</p> | |
| </div> | |
| </div> | |
| </div> | |
| <h2 class="text-2xl font-semibold mt-8 mb-4">How It Works</h2> | |
| <div class="flex flex-col md:flex-row items-center mb-8"> | |
| <div class="md:w-1/2 mb-6 md:mb-0 md:pr-6"> | |
| <p class="text-gray-300 mb-4"> | |
| The SVG Engine transforms Python game code into optimized SVG markup with embedded JavaScript. | |
| The compilation process includes: | |
| </p> | |
| <ul class="list-disc pl-5 text-gray-400 space-y-2"> | |
| <li>Conversion of Python game logic to JavaScript</li> | |
| <li>Optimization of graphics into SVG paths and shapes</li> | |
| <li>Embedding of assets as data URIs</li> | |
| <li>Generation of efficient animation timelines</li> | |
| <li>Compression of the final SVG output</li> | |
| </ul> | |
| </div> | |
| <div class="md:w-1/2 bg-gray-800 p-4 rounded-lg border border-gray-700"> | |
| <div class="flex items-center justify-between mb-3"> | |
| <div class="flex space-x-2"> | |
| <div class="w-3 h-3 rounded-full bg-red-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-yellow-500"></div> | |
| <div class="w-3 h-3 rounded-full bg-green-500"></div> | |
| </div> | |
| <div class="text-sm text-gray-500">game_compiler.py</div> | |
| </div> | |
| <div class="code-block"> | |
| <span class="text-green-400"># Python game code</span><br> | |
| <span class="text-blue-400">import</span> svg_engine <span class="text-gray-500">as</span> game<br><br> | |
| <span class="text-blue-400">def</span> <span class="text-yellow-400">setup</span>():<br> | |
| game.create_window(<span class="text-orange-400">800</span>, <span class="text-orange-400">600</span>)<br> | |
| player = game.Sprite(<span class="text-green-400">"player.svg"</span>)<br><br> | |
| <span class="text-blue-400">def</span> <span class="text-yellow-400">update</span>():<br> | |
| <span class="text-blue-400">if</span> game.key_pressed(<span class="text-green-400">"right"</span>):<br> | |
| player.x += <span class="text-orange-400">5</span> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <section id="getting-started" class="mb-16"> | |
| <div class="flex items-center mb-6"> | |
| <div class="w-10 h-10 rounded-full bg-green-900 flex items-center justify-center mr-4"> | |
| <i class="fas fa-rocket text-green-300"></i> | |
| </div> | |
| <h1 class="text-3xl font-bold">Getting Started</h1> | |
| </div> | |
| <div class="bg-gray-800 rounded-xl p-6 mb-8 border border-gray-700"> | |
| <h2 class="text-2xl font-semibold mb-4">Installation</h2> | |
| <p class="text-gray-300 mb-6"> | |
| The SVG Engine requires Python 3.8 or higher. Install it via pip: | |
| </p> | |
| <div class="code-block mb-6"> | |
| pip install svg-engine | |
| </div> | |
| <h3 class="text-xl font-semibold mb-3 mt-6">Creating Your First Game</h3> | |
| <ol class="list-decimal pl-5 text-gray-300 space-y-3 mb-6"> | |
| <li>Create a new Python file (e.g., <code class="bg-gray-700 px-1 rounded">my_game.py</code>)</li> | |
| <li>Import the SVG Engine module</li> | |
| <li>Define your game's setup and update functions</li> | |
| <li>Compile to SVG using the command line tool</li> | |
| </ol> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-6"> | |
| <div> | |
| <h4 class="font-semibold mb-2">Basic Game Template</h4> | |
| <div class="code-block"> | |
| <span class="text-blue-400">import</span> svg_engine <span class="text-gray-500">as</span> game<br><br> | |
| <span class="text-green-400"># Called once at startup</span><br> | |
| <span class="text-blue-400">def</span> <span class="text-yellow-400">setup</span>():<br> | |
| game.create_window(<span class="text-orange-400">800</span>, <span class="text-orange-400">600</span>)<br> | |
| game.set_title(<span class="text-green-400">"My SVG Game"</span>)<br><br> | |
| <span class="text-green-400"># Called every frame</span><br> | |
| <span class="text-blue-400">def</span> <span class="text-yellow-400">update</span>():<br> | |
| <span class="text-blue-400">pass</span> | |
| </div> | |
| </div> | |
| <div> | |
| <h4 class="font-semibold mb-2">Compiling to SVG</h4> | |
| <div class="code-block"> | |
| <span class="text-green-400"># Compile your game to an SVG file</span><br> | |
| svg-compile my_game.py -o game.svg<br><br> | |
| <span class="text-green-400"># Additional options:</span><br> | |
| --optimize <span class="text-gray-500"># Enable compression</span><br> | |
| --minify <span class="text-gray-500"># Minify JavaScript</span><br> | |
| --embed <span class="text-gray-500"># Embed all assets</span><br> | |
| --fps <span class="text-orange-400">60</span> <span class="text-gray-500"># Target framerate</span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="bg-blue-900 bg-opacity-20 rounded-xl p-6 border border-blue-800"> | |
| <div class="flex"> | |
| <div class="flex-shrink-0 mr-4"> | |
| <i class="fas fa-lightbulb text-yellow-400 text-2xl"></i> | |
| </div> | |
| <div> | |
| <h3 class="text-xl font-semibold mb-2 text-blue-300">Pro Tip</h3> | |
| <p class="text-blue-200"> | |
| Use the <code class="bg-blue-900 bg-opacity-50 px-1 rounded">--debug</code> flag during development to include | |
| error messages and performance stats in your compiled SVG. | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <section id="python-api" class="mb-16"> | |
| <div class="flex items-center mb-6"> | |
| <div class="w-10 h-10 rounded-full bg-yellow-900 flex items-center justify-center mr-4"> | |
| <i class="fab fa-python text-yellow-300"></i> | |
| </div> | |
| <h1 class="text-3xl font-bold">Python API Reference</h1> | |
| </div> | |
| <div class="bg-gray-800 rounded-xl p-6 mb-8 border border-gray-700"> | |
| <h2 class="text-2xl font-semibold mb-4">Core Functions</h2> | |
| <div class="overflow-x-auto"> | |
| <table class="min-w-full divide-y divide-gray-700"> | |
| <thead class="bg-gray-750"> | |
| <tr> | |
| <th class="px-4 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Function</th> | |
| <th class="px-4 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Description</th> | |
| <th class="px-4 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Example</th> | |
| </tr> | |
| </thead> | |
| <tbody class="divide-y divide-gray-700"> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">create_window(width, height)</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Initialize game window</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">create_window(800, 600)</td> | |
| </tr> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">set_title(title)</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Set window title</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">set_title("My Game")</td> | |
| </tr> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">load_image(path)</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Load image asset</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">img = load_image("char.png")</td> | |
| </tr> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">key_pressed(key)</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Check if key is pressed</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">if key_pressed("space"):</td> | |
| </tr> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">mouse_position()</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Get current mouse position</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">x, y = mouse_position()</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| <h2 class="text-2xl font-semibold mt-8 mb-4">Sprite Class</h2> | |
| <div class="code-block mb-6"> | |
| <span class="text-green-400"># Create a sprite</span><br> | |
| player = Sprite(<span class="text-green-400">"player.png"</span>)<br> | |
| player.x = <span class="text-orange-400">100</span> <span class="text-green-400"># Set position</span><br> | |
| player.y = <span class="text-orange-400">200</span><br> | |
| player.scale = <span class="text-orange-400">0.5</span> <span class="text-green-400"># Scale to 50%</span><br> | |
| player.rotation = <span class="text-orange-400">45</span> <span class="text-green-400"># Rotate 45 degrees</span><br> | |
| player.opacity = <span class="text-orange-400">0.8</span> <span class="text-green-400"># 80% opacity</span><br><br> | |
| <span class="text-green-400"># In update():</span><br> | |
| player.move(<span class="text-orange-400">2</span>, <span class="text-orange-400">0</span>) <span class="text-green-400"># Move right</span> | |
| </div> | |
| <h2 class="text-2xl font-semibold mt-8 mb-4">Drawing API</h2> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-6"> | |
| <div class="code-block"> | |
| <span class="text-green-400"># Basic shapes</span><br> | |
| draw_rect(x, y, w, h, color)<br> | |
| draw_circle(x, y, r, color)<br> | |
| draw_line(x1, y1, x2, y2, color)<br> | |
| draw_text(text, x, y, color, size)<br><br> | |
| <span class="text-green-400"># Example:</span><br> | |
| draw_rect(<span class="text-orange-400">50</span>, <span class="text-orange-400">50</span>, <span class="text-orange-400">100</span>, <span class="text-orange-400">60</span>, <span class="text-green-400">"#ff0000"</span>) | |
| </div> | |
| <div class="code-block"> | |
| <span class="text-green-400"># Advanced drawing</span><br> | |
| begin_shape()<br> | |
| vertex(x, y)<br> | |
| vertex(x, y)<br> | |
| end_shape(fill, stroke)<br><br> | |
| <span class="text-green-400"># Example polygon:</span><br> | |
| begin_shape()<br> | |
| vertex(<span class="text-orange-400">100</span>, <span class="text-orange-400">100</span>)<br> | |
| vertex(<span class="text-orange-400">150</span>, <span class="text-orange-400">150</span>)<br> | |
| vertex(<span class="text-orange-400">100</span>, <span class="text-orange-400">200</span>)<br> | |
| end_shape(<span class="text-green-400">"blue"</span>, <span class="text-green-400">"white"</span>) | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <section id="sprites" class="mb-16"> | |
| <div class="flex items-center mb-6"> | |
| <div class="w-10 h-10 rounded-full bg-purple-900 flex items-center justify-center mr-4"> | |
| <i class="fas fa-image text-purple-300"></i> | |
| </div> | |
| <h1 class="text-3xl font-bold">Sprites</h1> | |
| </div> | |
| <div class="bg-gray-800 rounded-xl p-6 mb-8 border border-gray-700"> | |
| <p class="text-gray-300 mb-6"> | |
| Sprites are the fundamental building blocks of games in SVG Engine. They represent visual elements that can be moved, | |
| rotated, scaled, and animated. Under the hood, sprites compile to SVG <code class="bg-gray-700 px-1 rounded"><image></code> | |
| or <code class="bg-gray-700 px-1 rounded"><g></code> elements with transform attributes. | |
| </p> | |
| <h2 class="text-2xl font-semibold mb-4">Creating Sprites</h2> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8"> | |
| <div class="code-block"> | |
| <span class="text-green-400"># From image file</span><br> | |
| player = Sprite(<span class="text-green-400">"assets/player.png"</span>)<br><br> | |
| <span class="text-green-400"># With initial position</span><br> | |
| enemy = Sprite(<span class="text-green-400">"enemy.svg"</span>, x=<span class="text-orange-400">200</span>, y=<span class="text-orange-400">150</span>)<br><br> | |
| <span class="text-green-400"># From scratch (empty sprite)</span><br> | |
| custom = Sprite(width=<span class="text-orange-400">64</span>, height=<span class="text-orange-400">64</span>) | |
| </div> | |
| <div class="code-block"> | |
| <span class="text-green-400"># Adding shapes to a sprite</span><br> | |
| <span class="text-blue-400">with</span> custom.group():<br> | |
| custom.rect(<span class="text-orange-400">0</span>, <span class="text-orange-400">0</span>, <span class="text-orange-400">64</span>, <span class="text-orange-400">64</span>, fill=<span class="text-green-400">"red"</span>)<br> | |
| custom.circle(<span class="text-orange-400">32</span>, <span class="text-orange-400">32</span>, <span class="text-orange-400">20</span>, fill=<span class="text-green-400">"yellow"</span>)<br><br> | |
| <span class="text-green-400"># Adding to display list</span><br> | |
| add_sprite(custom) | |
| </div> | |
| </div> | |
| <h2 class="text-2xl font-semibold mb-4">Sprite Properties</h2> | |
| <div class="overflow-x-auto mb-8"> | |
| <table class="min-w-full divide-y divide-gray-700"> | |
| <thead class="bg-gray-750"> | |
| <tr> | |
| <th class="px-4 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Property</th> | |
| <th class="px-4 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Type</th> | |
| <th class="px-4 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Description</th> | |
| </tr> | |
| </thead> | |
| <tbody class="divide-y divide-gray-700"> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">x, y</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">number</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Position coordinates</td> | |
| </tr> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">scale_x, scale_y</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">number</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Horizontal/vertical scale</td> | |
| </tr> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">rotation</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">degrees</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Rotation angle</td> | |
| </tr> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">opacity</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">0.0-1.0</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Transparency level</td> | |
| </tr> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">visible</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">boolean</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Visibility flag</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </section> | |
| <section id="animation" class="mb-16"> | |
| <div class="flex items-center mb-6"> | |
| <div class="w-10 h-10 rounded-full bg-pink-900 flex items-center justify-center mr-4"> | |
| <i class="fas fa-film text-pink-300"></i> | |
| </div> | |
| <h1 class="text-3xl font-bold">Animation</h1> | |
| </div> | |
| <div class="bg-gray-800 rounded-xl p-6 mb-8 border border-gray-700"> | |
| <p class="text-gray-300 mb-6"> | |
| SVG Engine provides powerful animation capabilities that compile to efficient SVG SMIL animations and CSS transitions. | |
| Animations can be defined declaratively or controlled programmatically. | |
| </p> | |
| <h2 class="text-2xl font-semibold mb-4">Frame Animation</h2> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8"> | |
| <div class="code-block"> | |
| <span class="text-green-400"># Sprite sheet animation</span><br> | |
| frames = load_spritesheet(<br> | |
| <span class="text-green-400">"hero.png"</span>,<br> | |
| frame_width=<span class="text-orange-400">64</span>,<br> | |
| frame_height=<span class="text-orange-400">64</span><br> | |
| )<br><br> | |
| hero = AnimatedSprite(frames)<br> | |
| hero.play(<span class="text-orange-400">10</span>) <span class="text-green-400"># 10 FPS</span> | |
| </div> | |
| <div class="code-block"> | |
| <span class="text-green-400"># Controlling animation</span><br> | |
| hero.pause()<br> | |
| hero.resume()<br> | |
| hero.stop()<br> | |
| hero.goto_frame(<span class="text-orange-400">3</span>)<br><br> | |
| <span class="text-green-400"># Animation events</span><br> | |
| <span class="text-blue-400">def</span> <span class="text-yellow-400">on_animation_end</span>():<br> | |
| hero.play(<span class="text-orange-400">5</span>, loop=<span class="text-blue-400">False</span>) | |
| </div> | |
| </div> | |
| <h2 class="text-2xl font-semibold mb-4">Tween Animations</h2> | |
| <div class="code-block mb-8"> | |
| <span class="text-green-400"># Simple tween</span><br> | |
| tween(hero, {<span class="text-green-400">"x"</span>: <span class="text-orange-400">300</span>}, duration=<span class="text-orange-400">1.5</span>)<br><br> | |
| <span class="text-green-400"># With easing</span><br> | |
| tween(hero, {<br> | |
| <span class="text-green-400">"y"</span>: <span class="text-orange-400">200</span>,<br> | |
| <span class="text-green-400">"rotation"</span>: <span class="text-orange-400">360</span><br> | |
| }, duration=<span class="text-orange-400">2</span>, ease=<span class="text-green-400">"bounceOut"</span>)<br><br> | |
| <span class="text-green-400"># Easing types:</span><br> | |
| <span class="text-green-400">"linear"</span>, <span class="text-green-400">"quadInOut"</span>, <span class="text-green-400">"elasticOut"</span>, <span class="text-green-400">"backIn"</span>, etc. | |
| </div> | |
| <h2 class="text-2xl font-semibold mb-4">Motion Paths</h2> | |
| <div class="code-block"> | |
| <span class="text-green-400"># Define path as list of points</span><br> | |
| path = [<br> | |
| (<span class="text-orange-400">100</span>, <span class="text-orange-400">100</span>),<br> | |
| (<span class="text-orange-400">200</span>, <span class="text-orange-400">150</span>),<br> | |
| (<span class="text-orange-400">300</span>, <span class="text-orange-400">50</span>)<br> | |
| ]<br><br> | |
| <span class="text-green-400"># Animate along path</span><br> | |
| follow_path(hero, path, duration=<span class="text-orange-400">3</span>)<br><br> | |
| <span class="text-green-400"># Continuous path following</span><br> | |
| <span class="text-blue-400">def</span> <span class="text-yellow-400">update</span>():<br> | |
| hero.follow_path(path, speed=<span class="text-orange-400">100</span>) | |
| </div> | |
| </div> | |
| </section> | |
| <section id="compilation" class="mb-16"> | |
| <div class="flex items-center mb-6"> | |
| <div class="w-10 h-10 rounded-full bg-red-900 flex items-center justify-center mr-4"> | |
| <i class="fas fa-cogs text-red-300"></i> | |
| </div> | |
| <h1 class="text-3xl font-bold">Compilation to SVG</h1> | |
| </div> | |
| <div class="bg-gray-800 rounded-xl p-6 mb-8 border border-gray-700"> | |
| <p class="text-gray-300 mb-6"> | |
| The compilation process transforms your Python game into a standalone SVG file containing all game logic, assets, | |
| and animations. This section covers advanced compilation options and optimization techniques. | |
| </p> | |
| <h2 class="text-2xl font-semibold mb-4">Compilation Process</h2> | |
| <div class="mb-8"> | |
| <div class="flex flex-col md:flex-row items-center mb-6"> | |
| <div class="md:w-1/2 mb-4 md:mb-0 md:pr-6"> | |
| <ol class="list-decimal pl-5 text-gray-300 space-y-2"> | |
| <li><strong>Code Analysis:</strong> Parse Python source and detect game structure</li> | |
| <li><strong>Asset Processing:</strong> Convert images to embedded data URIs</li> | |
| <li><strong>Translation:</strong> Convert Python to optimized JavaScript</li> | |
| <li><strong>SVG Generation:</strong> Create SVG markup with embedded scripts</li> | |
| <li><strong>Optimization:</strong> Apply size reduction techniques</li> | |
| </ol> | |
| </div> | |
| <div class="md:w-1/2 bg-gray-750 p-4 rounded-lg"> | |
| <div class="flex items-center justify-between mb-3"> | |
| <div class="text-sm font-semibold">Compilation Output</div> | |
| <div class="text-xs text-gray-500">game.svg</div> | |
| </div> | |
| <div class="code-block text-xs"> | |
| <span class="text-gray-500"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600"></span><br> | |
| <span class="text-gray-500"><script type="application/ecmascript"></span><br> | |
| <span class="text-gray-500"> <span class="text-blue-400">//</span> Compiled JavaScript...</span><br> | |
| <span class="text-gray-500"></script></span><br> | |
| <span class="text-gray-500"><image href="data:image/png;base64,..."/></span><br> | |
| <span class="text-gray-500"><g transform="translate(100,200)"></span><br> | |
| <span class="text-gray-500"> <span class="text-blue-400"><!--</span> Game elements <span class="text-blue-400">--></span></span><br> | |
| <span class="text-gray-500"></g></span><br> | |
| <span class="text-gray-500"></svg></span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <h2 class="text-2xl font-semibold mb-4">Advanced Compilation Options</h2> | |
| <div class="overflow-x-auto mb-8"> | |
| <table class="min-w-full divide-y divide-gray-700"> | |
| <thead class="bg-gray-750"> | |
| <tr> | |
| <th class="px-4 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Option</th> | |
| <th class="px-4 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Description</th> | |
| <th class="px-4 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Example</th> | |
| </tr> | |
| </thead> | |
| <tbody class="divide-y divide-gray-700"> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">--optimize</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Enable size optimization</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">svg-compile --optimize</td> | |
| </tr> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">--minify</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Minify JavaScript code</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">svg-compile --minify</td> | |
| </tr> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">--external-assets</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Keep assets as external files</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">svg-compile --external-assets</td> | |
| </tr> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">--fps</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Set target framerate</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">svg-compile --fps 30</td> | |
| </tr> | |
| <tr> | |
| <td class="px-4 py-3 whitespace-nowrap text-sm font-mono text-purple-300">--size</td> | |
| <td class="px-4 py-3 text-sm text-gray-300">Override window size</td> | |
| <td class="px-4 py-3 text-sm font-mono text-gray-400">svg-compile --size 1024x768</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| <h2 class="text-2xl font-semibold mb-4">Performance Optimization</h2> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-6"> | |
| <div> | |
| <h3 class="text-xl font-semibold mb-2">Code Optimization</h3> | |
| <ul class="list-disc pl-5 text-gray-300 space-y-1"> | |
| <li>Use sprite batching when possible</li> | |
| <li>Minimize dynamic property changes</li> | |
| <li>Prefer static elements where possible</li> | |
| <li>Use simple shapes instead of complex paths</li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h3 class="text-xl font-semibold mb-2">Asset Optimization</h3> | |
| <ul class="list-disc pl-5 text-gray-300 space-y-1"> | |
| <li>Optimize images before importing</li> | |
| <li>Use SVG assets when possible</li> | |
| <li>Reduce color depth for simpler assets</li> | |
| <li>Share textures between sprites</li> | |
| </ul> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <section id="examples" class="mb-16"> | |
| <div class="flex items-center mb-6"> | |
| <div class="w-10 h-10 rounded-full bg-indigo-900 flex items-center justify-center mr-4"> | |
| <i class="fas fa-code text-indigo-300"></i> | |
| </div> | |
| <h1 class="text-3xl font-bold">Examples</h1> | |
| </div> | |
| <div class="bg-gray-800 rounded-xl p-6 mb-8 border border-gray-700"> | |
| <h2 class="text-2xl font-semibold mb-4">Simple Game Example</h2> | |
| <div class="code-block mb-6"> | |
| <span class="text-blue-400">import</span> svg_engine <span class="text-gray-500">as</span> game<br><br> | |
| <span class="text-blue-400">class</span> <span class="text-yellow-400">Player</span>:<br> | |
| <span class="text-blue-400">def</span> <span class="text-yellow-400">__init__</span>(<span class="text-blue-400">self</span>):<br> | |
| <span class="text-blue-400">self</span>.sprite = game.Sprite(<span class="text-green-400">"player.png"</span>)<br> | |
| <span class="text-blue-400">self</span>.speed = <span class="text-orange-400">5</span><br><br> | |
| <span class="text-blue-400">def</span> <span class="text-yellow-400">update</span>(<span class="text-blue-400">self</span>):<br> | |
| <span class="text-blue-400">if</span> game.key_pressed(<span class="text-green-400">"left"</span>):<br> | |
| <span class="text-blue-400">self</span>.sprite.x -= <span class="text-blue-400">self</span>.speed<br> | |
| <span class="text-blue-400">if</span> game.key_pressed(<span class="text-green-400">"right"</span>):<br> | |
| <span class="text-blue-400">self</span>.sprite.x += <span class="text-blue-400">self</span>.speed<br><br> | |
| player = Player()<br><br> | |
| <span class="text-blue-400">def</span> <span class="text-yellow-400">setup</span>():<br> | |
| game.create_window(<span class="text-orange-400">800</span>, <span class="text-orange-400">600</span>)<br><br> | |
| <span class="text-blue-400">def</span> <span class="text-yellow-400">update</span>():<br> | |
| player.update() | |
| </div> | |
| <h2 class="text-2xl font-semibold mb-4">Interactive Demo</h2> | |
| <div class="bg-gray-750 rounded-lg p-6 mb-6 border border-gray-700"> | |
| <div class="flex justify-center mb-4"> | |
| <svg width="400" height="300" viewBox="0 0 400 300" class="bg-gray-900 rounded"> | |
| <!-- This would be replaced with actual compiled SVG game content --> | |
| <rect x="50" y="100" width="50" height="50" fill="#4f46e5" id="demo-player"/> | |
| <text x="200" y="50" fill="white" text-anchor="middle" font-family="Arial" font-size="14"> | |
| Press left/right arrow keys | |
| </text> | |
| </svg> | |
| </div> | |
| <div class="text-center text-sm text-gray-400"> | |
| This demo shows a simple player character that can be moved with arrow keys. | |
| The actual compiled SVG would include interactive JavaScript. | |
| </div> | |
| </div> | |
| <h2 class="text-2xl font-semibold mb-4">Sample Games</h2> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-4"> | |
| <a href="#" class="block bg-gray-750 rounded-lg overflow-hidden border border-gray-700 hover:border-purple-500 transition"> | |
| <div class="h-32 bg-gradient-to-br from-purple-900 to-blue-900 flex items-center justify-center"> | |
| <i class="fas fa-gamepad text-4xl text-white opacity-70"></i> | |
| </div> | |
| <div class="p-4"> | |
| <h3 class="font-semibold">Space Shooter</h3> | |
| <p class="text-sm text-gray-400 mt-1">Classic arcade shooter</p> | |
| </div> | |
| </a> | |
| <a href="#" class="block bg-gray-750 rounded-lg overflow-hidden border border-gray-700 hover:border-green-500 transition"> | |
| <div class="h-32 bg-gradient-to-br from-green-900 to-teal-900 flex items-center justify-center"> | |
| <i class="fas fa-puzzle-piece text-4xl text-white opacity-70"></i> | |
| </div> | |
| <div class="p-4"> | |
| <h3 class="font-semibold">Puzzle Game</h3> | |
| <p class="text-sm text-gray-400 mt-1">Tile matching game</p> | |
| </div> | |
| </a> | |
| <a href="#" class="block bg-gray-750 rounded-lg overflow-hidden border border-gray-700 hover:border-red-500 transition"> | |
| <div class="h-32 bg-gradient-to-br from-red-900 to-pink-900 flex items-center justify-center"> | |
| <i class="fas fa-running text-4xl text-white opacity-70"></i> | |
| </div> | |
| <div class="p-4"> | |
| <h3 class="font-semibold">Platformer</h3> | |
| <p class="text-sm text-gray-400 mt-1">Jump and run adventure</p> | |
| </div> | |
| </a> | |
| </div> | |
| </div> | |
| </section> | |
| <section id="faq" class="mb-16"> | |
| <div class="flex items-center mb-6"> | |
| <div class="w-10 h-10 rounded-full bg-pink-900 flex items-center justify-center mr-4"> | |
| <i class="fas fa-question-circle text-pink-300"></i> | |
| </div> | |
| <h1 class="text-3xl font-bold">Frequently Asked Questions</h1> | |
| </div> | |
| <div class="bg-gray-800 rounded-xl p-6 mb-8 border border-gray-700"> | |
| <div class="space-y-6"> | |
| <div class="border-b border-gray-700 pb-6"> | |
| <h3 class="text-xl font-semibold mb-2">Is SVG Engine suitable for complex games?</h3> | |
| <p class="text-gray-300"> | |
| SVG Engine is optimized for lightweight 2D games. While it can handle moderately complex games, | |
| it's best suited for casual games, interactive art, and educational projects. For very complex | |
| games with thousands of objects, a traditional game engine might be more appropriate. | |
| </p> | |
| </div> | |
| <div class="border-b border-gray-700 pb-6"> | |
| <h3 class="text-xl font-semibold mb-2">What browsers support SVG games?</h3> | |
| <p class="text-gray-300"> | |
| SVG games work in all modern browsers including Chrome, Firefox, Safari, Edge, and Opera. | |
| Mobile browsers on both iOS and Android are also supported. Internet Explorer has limited | |
| support (IE11 works but with some feature restrictions). | |
| </p> | |
| </div> | |
| <div class="border-b border-gray-700 pb-6"> | |
| <h3 class="text-xl font-semibold mb-2">How is performance compared to Canvas/WebGL?</h3> | |
| <p class="text-gray-300"> | |
| SVG rendering is generally slower than Canvas or WebGL for complex scenes, but offers | |
| excellent performance for typical 2D games with dozens to hundreds of elements. The | |
| advantage is that SVG provides resolution-independent graphics and easy DOM manipulation. | |
| </p> | |
| </div> | |
| <div class="border-b border-gray-700 pb-6"> | |
| <h3 class="text-xl font-semibold mb-2">Can I monetize games made with SVG Engine?</h3> | |
| <p class="text-gray-300"> | |
| Yes! SVG Engine is MIT licensed, which means you can create commercial games with it. | |
| The compiled SVG files are yours to distribute however you like - on your website, | |
| app stores (wrapped in a web view), or as standalone files. | |
| </p> | |
| </div> | |
| <div class=""> | |
| <h3 class="text-xl font-semibold mb-2">How do I handle game saves and persistence?</h3> | |
| <p class="text-gray-300"> | |
| SVG games can use the browser's localStorage API to save game state. The engine provides | |
| helper functions like <code class="bg-gray-700 px-1 rounded">save_data(key, value)</code> | |
| and <code class="bg-gray-700 px-1 rounded">load_data(key)</code> to simplify this process. | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="bg-indigo-900 bg-opacity-20 rounded-xl p-6 border border-indigo-800"> | |
| <div class="flex"> | |
| <div class="flex-shrink-0 mr-4"> | |
| <i class="fas fa-comments text-indigo-300 text-2xl"></i> | |
| </div> | |
| <div> | |
| <h3 class="text-xl font-semibold mb-2 text-indigo-300">Need More Help?</h3> | |
| <p class="text-indigo-200 mb-3"> | |
| Join our community forum to ask questions and share your SVG game projects! | |
| </p> | |
| <a href="#" class="inline-flex items-center px-4 py-2 bg-indigo-700 rounded-md hover:bg-indigo-600 transition"> | |
| <i class="fas fa-users mr-2"></i> Visit Community | |
| </a> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <footer class="mt-16 pt-8 border-t border-gray-800"> | |
| <div class="flex flex-col md:flex-row justify-between items-center"> | |
| <div class="flex items-center mb-4 md:mb-0"> | |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6 text-purple-500"> | |
| <path fill-rule="evenodd" d="M14.615 1.595a.75.75 0 01.359.852L12.982 9.75h7.268a.75.75 0 01.548 1.262l-10.5 11.25a.75.75 0 01-1.272-.71l1.992-7.302H3.75a.75.75 0 01-.548-1.262l10.5-11.25a.75.75 0 01.913-.143z" clip-rule="evenodd" /> | |
| </svg> | |
| <span class="ml-2 text-xl font-bold gradient-text">SVG Engine</span> | |
| </div> | |
| <div class="flex space-x-6"> | |
| <a href="#" class="text-gray-400 hover:text-white transition"><i class="fab fa-github text-xl"></i></a> | |
| <a href="#" class="text-gray-400 hover:text-white transition"><i class="fab fa-twitter text-xl"></i></a> | |
| <a href="#" class="text-gray-400 hover:text-white transition"><i class="fab fa-discord text-xl"></i></a> | |
| <a href="#" class="text-gray-400 hover:text-white transition"><i class="fas fa-book text-xl"></i></a> | |
| </div> | |
| </div> | |
| <div class="mt-8 text-center text-sm text-gray-500"> | |
| <p>SVG Engine is open source software licensed under MIT. © 2023 SVG Engine Team.</p> | |
| <p class="mt-1">Documentation version 1.0.0</p> | |
| </div> | |
| </footer> | |
| </div> | |
| <script> | |
| // Mobile menu toggle | |
| const mobileMenuButton = document.getElementById('mobile-menu-button'); | |
| const mobileSidebar = document.getElementById('mobile-sidebar'); | |
| const closeMobileMenu = document.getElementById('close-mobile-menu'); | |
| mobileMenuButton.addEventListener('click', () => { | |
| mobileSidebar.classList.remove('hidden'); | |
| }); | |
| closeMobileMenu.addEventListener('click', () => { | |
| mobileSidebar.classList.add('hidden'); | |
| }); | |
| // Close mobile menu when clicking on a link | |
| document.querySelectorAll('#mobile-sidebar a').forEach(link => { | |
| link.addEventListener('click', () => { | |
| mobileSidebar.classList.add('hidden'); | |
| }); | |
| }); | |
| // Simple demo interaction for the example game | |
| if (document.getElementById('demo-player')) { | |
| document.addEventListener('keydown', (e) => { | |
| const player = document.getElementById('demo-player'); | |
| if (!player) return; | |
| let x = parseInt(player.getAttribute('x')); | |
| if (e.key === 'ArrowLeft') { | |
| x = Math.max(0, x - 10); | |
| player.setAttribute('x', x); | |
| } else if (e.key === 'ArrowRight') { | |
| x = Math.min(350, x + 10); | |
| player.setAttribute('x', x); | |
| } | |
| }); | |
| } | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=kainecorneko/ds" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |