|
| 1 | +# 🌊 Choppy Engine v1.0 |
| 2 | +**The ultra-lightweight game orchestration layer for Canvas API.** |
| 3 | + |
| 4 | +Choppy is not a heavy framework; it's a high-speed abstraction script for developers who love the **Canvas API** but hate managing scenes in visual engines, Z-orders, and game loops from scratch. It's designed for **speed-running game development** and rapid prototyping. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## 🔥 Why Choppy? |
| 9 | + |
| 10 | +* **Pure Canvas API**: If you know `ctx.fillRect()` and CanvasAPI, you already know Choppy. |
| 11 | +* **Zero Overhead**: A single, tiny JS file. No dependencies. No bloat. |
| 12 | +* **Dynamic Scripting**: Use the power of string-based logic (`eval`) for instant prototyping. |
| 13 | +* **Scene-Based Z-Order**: Each scene manages its own independent rendering layers (Background, Game, UI). |
| 14 | +* **Semi-Recursive Flow**: Change scenes and modify the engine state directly from within your scene scripts. |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## 🚀 Quick Start (Speed-run style) |
| 19 | + |
| 20 | +### 1. Setup your HTML |
| 21 | +1. In the body tag: |
| 22 | +```html |
| 23 | +<canvas id="myCanvas" width="200" height="100"></canvas> |
| 24 | +<script src="choppy.js"></script> |
| 25 | +``` |
| 26 | + |
| 27 | +2. Create your Game Logic |
| 28 | +```html |
| 29 | +<script> |
| 30 | + var choppy = new Choppy("myCanvas"); |
| 31 | +
|
| 32 | + // Scene 0: Forest |
| 33 | + choppy.sceneCreate(` |
| 34 | + // Define drawings once (or update them dynamically) |
| 35 | + escenaActual.layers[0] = "ctx.fillStyle = 'green'; ctx.fillRect(0,0,200,100);"; // Floor |
| 36 | + escenaActual.layers[2] = "ctx.fillStyle = 'white'; ctx.fillText('Level: Forest', 10, 20);"; // UI |
| 37 | + `, "Forest"); |
| 38 | +
|
| 39 | + // Scene 1: Cave |
| 40 | + choppy.sceneCreate(` |
| 41 | + escenaActual.layers[0] = "ctx.fillStyle = 'black'; ctx.fillRect(0,0,200,100);"; // Dark background |
| 42 | + escenaActual.layers[1] = "ctx.fillStyle = 'gray'; ctx.fillRect(50,50,20,20);"; // A rock |
| 43 | + `, "Cave"); |
| 44 | +
|
| 45 | + choppy.play(); // Launch the game loop |
| 46 | +
|
| 47 | + // Example of scene transition after 2 seconds |
| 48 | + setTimeout(() => { |
| 49 | + choppy.setScene(1); |
| 50 | + }, 2000); |
| 51 | +</script> |
| 52 | +``` |
| 53 | +💡 Important Tips 🔥 |
| 54 | +Scene Management: Choppy provides a lightweight display list. You can switch scenes instantly without memory leaks. |
| 55 | +Extensibility: You can extend the Choppy class easily to add physics or sound systems. |
| 56 | +Security Disclaimer: This script uses eval() for extreme flexibility and speed. Be careful when copying scripts from untrusted sites; malicious code could be hidden in strings. Always know what your eval strings are doing. |
| 57 | + |
| 58 | +## Usage & Credits |
| 59 | + |
| 60 | +### 📦 Local Installation Only |
| 61 | +For security reasons (due to the use of `eval()`), **ChoppyJS must be hosted locally**. Do not link to this script via a CDN. Download the `choppy.js` file and include it directly in your project's ZIP or repository. |
| 62 | + |
| 63 | +### 📜 Attribution |
| 64 | +This project is licensed under the MIT License. This means you **must** keep the copyright notice in the code. Additionally, we highly recommend and appreciate it if you credit **ChoppyJS** in: |
| 65 | +* Your project's `README.md`. |
| 66 | +* Your game's "Credits" screen. |
| 67 | +* The "Tools Used" section of your game's page. |
| 68 | + |
| 69 | +Example: "Built with ChoppyJS by B4uti4GD" |
| 70 | + |
| 71 | + |
| 72 | +Made by me with a little help from AI 😉. Go build something fast! |
0 commit comments