惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
The GitHub Blog
The GitHub Blog
美团技术团队
Security Latest
Security Latest
The Cloudflare Blog
D
DataBreaches.Net
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
宝玉的分享
宝玉的分享
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
P
Proofpoint News Feed
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Security Affairs
腾讯CDC
H
Hacker News: Front Page
Microsoft Security Blog
Microsoft Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 三生石上(FineUI控件)
C
Check Point Blog
S
Security @ Cisco Blogs
Google DeepMind News
Google DeepMind News
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Security Archives - TechRepublic
Security Archives - TechRepublic
I
InfoQ
量子位
Apple Machine Learning Research
Apple Machine Learning Research
AWS News Blog
AWS News Blog
TaoSecurity Blog
TaoSecurity Blog
月光博客
月光博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
A
Arctic Wolf
Hacker News: Ask HN
Hacker News: Ask HN
D
Docker
Hugging Face - Blog
Hugging Face - Blog
I
Intezer
雷峰网
雷峰网
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
SecWiki News
SecWiki News
N
News and Events Feed by Topic

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
🟢 Level 1 Tutorial — Limn Engine Beginner Guide
Kehinde Owolabi · 2026-06-20 · via DEV Community

🟢 Level 1 Tutorial — Limn Engine Beginner Guide

Start Your Game Development Journey Here

Welcome to Limn Engine — the zero‑configuration, browser‑based 2D game engine that prioritises creativity over complexity.

This is Level 1: Beginner, where you'll learn everything you need to make your first game in under 60 seconds.

A special thank you to **GyaanSetu Javascript* for featuring our work and helping us share Limn Engine with the JavaScript community. Your support means the world to us. 🙏*


What You'll Learn

Topic What You'll Build
1. Creating a Display Your first canvas
2. Adding & moving Components Your first game object
3. Keyboard input & deltaTime Move with arrow keys
4. Boundaries with move.bound() Keep objects on screen
5. Rectangle collision Collect coins, hit walls
6. Text with Tctxt Score display
7. Images with setImage() Add sprites
8. Mouse input & clicked() Click interactions
9. Sound class Add audio
10. Game states with display.scene Menu → Game → Game Over
11. Coin collector tutorial Complete beginner game
12. Quick reference All the essentials

Before You Start

What You Need

  • A text editor (VS Code, Notepad++, or even Notepad)
  • A browser (Chrome, Firefox, Edge, etc.)
  • Limn Engine — Download epic.js from limn-engine.vercel.app

The Golden Rule

Your Display instance **must* be named display (lowercase). The engine relies on this variable name internally. Any other name will break it.*


1. Creating a Display

The Display class is the foundation of every Limn Engine game. It creates the canvas, runs the game loop, captures input, manages the camera, and controls which scene is active.

<!DOCTYPE html>
<html>
<head>
    <title>My First Limn Game</title>
</head>
<body>
    <script src="epic.js"></script>
    <script>
        // Create the engine
        const display = new Display();

        // Start the game
        display.start(800, 600);

        // Set a background colour (optional)
        display.backgroundColor("#0d0d2a");

        // Your game logic runs here every frame
        function update() {
            // Game code goes here
        }
    </script>
</body>
</html>

What's Happening?

Line What It Does
new Display() Creates the engine instance
display.start(800, 600) Creates an 800x600 canvas and starts the game loop
display.backgroundColor("#0d0d2a") Sets a dark blue background
function update() Runs every frame — your game logic lives here

💡 Tip: Always name your Display instance display. The engine uses this name internally across many classes.


2. Adding & Moving Components

A Component is any visible object in your game — the player, an enemy, a coin, a wall. You create one and register it with display.add() so the engine draws and moves it every frame.

// Component(width, height, color, x, y, type)
const player = new Component(50, 50, "blue", 100, 200, "rect");
display.add(player); // Now the engine draws and moves it

// Move the player
player.speedX = 3;  // Moves 3px right per frame
player.speedY = 2;  // Moves 2px down per frame

// Teleport instantly
player.x = 400;
player.y = 300;

// Stop all movement
player.stopMove();

Component Properties

Property Type Purpose
x / y Number Position (top-left corner)
width / height Number Size in pixels
speedX / speedY Number Velocity added every frame
color String Fill colour (or image path)
angle Number Rotation in radians
type String "rect", "image", or "text"

Component Types

Type How to Use
"rect" Default — draws a filled rectangle
"image" Draws an image — pass file path as color
"text" Draws text — use Tctxt for more control

3. Keyboard Input & DeltaTime

Limn Engine fills display.keys[] with true while a key is held. Check key codes inside update() and multiply by deltaTime (dt) for frame‑rate‑independent movement.

function update(dt) {
    // Reset every frame so player stops when no key is held
    player.speedX = 0;
    player.speedY = 0;

    // Arrow keys
    if (display.keys[37]) player.speedX = -250 * dt; // ←
    if (display.keys[39]) player.speedX =  250 * dt; // →
    if (display.keys[38]) player.speedY = -250 * dt; // ↑
    if (display.keys[40]) player.speedY =  250 * dt; // ↓

    // WASD — same thing, different codes
    if (display.keys[65]) player.speedX = -250 * dt; // A
    if (display.keys[68]) player.speedX =  250 * dt; // D
    if (display.keys[87]) player.speedY = -250 * dt; // W
    if (display.keys[83]) player.speedY =  250 * dt; // S
}

Common Key Codes

Key Code Key Code
← Left Arrow 37 A 65
↑ Up Arrow 38 W 87
→ Right Arrow 39 D 68
↓ Down Arrow 40 S 83
Space 32 Enter 13
Escape 27 Shift 16

💡 Tip: Without dt, your game runs faster on fast monitors. With dt, 250 pixels per second is the same on every device.


4. Boundaries with move.bound()

move.bound() prevents a Component from walking off any edge of the canvas. One line replaces four manual if-checks.

function update(dt) {
    if (display.keys[39]) player.speedX =  4;
    if (display.keys[37]) player.speedX = -4;
    else if (!display.keys[39]) player.speedX = 0;

    // Keep player on screen
    move.bound(player);

    // OR clamp to custom boundaries
    move.boundTo(player, 50, 750, 0, 580);
    // left=50, right=750, top=0, bottom=580

    // Leave top and bottom open (only clamp horizontally)
    move.boundTo(player, 0, 800, false, false);
}

Method Parameters Purpose
move.bound(id) Component Clamp to all four canvas edges
move.boundTo(id, l, r, t, b) Component, left, right, top, bottom Clamp to custom boundaries

5. Rectangle Collision with crashWith()

crashWith(other) checks if two Components overlap and returns true if they do. This is the foundation for hit detection, pickups, and obstacle collision.

const player = new Component(40, 40, "blue", 100, 300, "rect");
const coin   = new Component(20, 20, "gold", 400, 200, "rect");
const wall   = new Component(200, 20, "gray", 300, 350, "rect");
display.add(player);
display.add(coin);
display.add(wall);

let score = 0;

function update(dt) {
    // Move player
    if (display.keys[39]) player.speedX =  4;
    if (display.keys[37]) player.speedX = -4;
    else if (!display.keys[39]) player.speedX = 0;

    // Collect coin on touch
    if (player.crashWith(coin)) {
        score++;
        coin.x = Math.random() * 760;
        coin.y = Math.random() * 560;
    }

    // Stop at wall
    if (player.crashWith(wall)) {
        player.speedX = 0;
    }
}

💡 Tip: crashWith() is rotation-aware. Even if your Component is rotated, collisions still work correctly.


6. Text with Tctxt

Tctxt is Limn Engine's rich text Component. It extends the base Component class with font size, font family, text alignment, optional background, and padding.

// Tctxt(size, font, color, x, y, align, stroke, baseline, background, padX, padY)
const scoreText = new Tctxt(
    "22px",                   // font size
    "Arial",                  // font family
    "white",                  // text colour
    20, 36,                   // x, y position
    "left",                   // alignment: "left", "center", or "right"
    false,                    // stroke mode (false = fill, true = outline only)
    "alphabetic",             // text baseline
    "rgba(0,0,0,0.6)",        // background fill colour (null to disable)
    14, 6                     // paddingX, paddingY
);
scoreText.setText("Score: 0");
display.add(scoreText);

let score = 0;

function update() {
    score++;
    scoreText.setText("Score: " + Math.floor(score / 60));

    // Keep the score box locked to the screen when the camera moves
    scoreText.fixed();
}

💡 Tip: fixed() must be called every frame. It keeps the text at the same screen position even when the camera moves.

Parameter Example Purpose
size "22px" Font size as CSS string
font "Arial" Font family name
align "left" "left", "center", or "right"
stroke false false = filled text, true = outlined
background "rgba(0,0,0,0.6)" Background fill (null to disable)
padX / padY 14, 6 Pixel padding inside background

7. Images with setImage()

Any Component can display an image instead of a coloured rectangle. Pass "image" as the type at construction, or call setImage(src) at any point.

// Method 1 — image at construction
const player = new Component(64, 64, "img/hero.png", 100, 100, "image");
display.add(player);

// Method 2 — switch to image at runtime
const enemy = new Component(40, 40, "red", 300, 200, "rect");
display.add(enemy);
enemy.setImage("img/enemy.png"); // switches to image mode

// Switch back to a colour rectangle
enemy.setColor("purple"); // image cleared, back to rect mode

Method Parameters Behaviour
setImage(src) file path Load image — falls back to red rect on error
setColor(color) CSS color Switch back to filled rect

💡 Tip: If the image fails to load, Limn automatically falls back to a red rectangle so you can diagnose the problem.


8. Mouse Input & clicked()

Limn Engine stores the mouse position in display.x and display.y while pressed. clicked() checks if the press landed on a specific Component.

const btn = new Component(160, 50, "#7fffb2", 320, 270, "rect");
display.add(btn);

function update() {
    // Check if mouse is pressed anywhere
    if (display.x) {
        console.log("Mouse at", display.x, display.y);
    }

    // Check if mouse pressed specifically on the button
    if (display.x && btn.clicked()) {
        btn.setColor("lime");
        console.log("Button clicked!");
    } else {
        btn.setColor("#7fffb2");
    }
}

💡 Tip: Works on touchscreen too — touchstart sets display.x and display.y to the finger position.


9. Sound with the Sound Class

The Sound class wraps the browser's Audio API for simple load-and-play audio with volume control, looping, pause, and automatic clone-on-overlap.

// Create sounds at the top — preloading starts immediately
const jumpSfx  = new Sound("audio/jump.wav");
const hitSfx   = new Sound("audio/hit.wav", { volume: 0.8 });
const bgMusic  = new Sound("audio/music.mp3", { loop: true, volume: 0.5 });

bgMusic.play(); // start background music

function update() {
    // Jump on Space — reset key so it fires only once per press
    if (display.keys[32]) {
        display.keys[32] = false;
        jumpSfx.play(); // clones if already playing — no cut-off
    }

    if (player.crashWith(enemy)) {
        hitSfx.play();
    }
}

Method Purpose
play(volume?) Play sound — clones if already playing (overlap safe)
stop() Stop and rewind to beginning
pause() Pause at current position
setVolume(0–1) Change volume
setLoop(bool) Enable or disable looping
isPlaying() Returns true if currently playing

10. Game States with display.scene

display.scene is Limn Engine's scene management system. Every Component is registered to a scene number, and only Components whose scene matches display.scene are drawn and updated.

// Scene 0 — main menu
const playBtn = new Component(160, 50, "#7fffb2", 320, 270, "rect");
display.add(playBtn, 0);

// Scene 1 — gameplay
const player = new Component(40, 40, "cyan", 100, 100, "rect");
display.add(player, 1);

// Scene 2 — game over
const gameOverText = new Tctxt("36px","Arial","red",260,280,"center");
gameOverText.setText("GAME OVER");
display.add(gameOverText, 2);

display.scene = 0; // start on the menu

let playerDead = false;

function update() {
    if (display.scene === 0) {
        if (display.x && playBtn.clicked()) {
            display.scene = 1; // start game
        }
    }

    if (display.scene === 1) {
        // gameplay logic here
        if (playerDead) display.scene = 2;
    }
}

💡 Tip: Components default to scene 0 if you call display.add(obj) without a second argument.


11. Coin Collector — Complete Tutorial

This builds a complete game using only Level 1 concepts — movement, collision, score, boundaries, and Tctxt.

<!DOCTYPE html>
<html>
<head>
    <title>Coin Collector</title>
    <script src="epic.js"></script>
</head>
<body>
    <script>
        let gameActive = true;
        const display = new Display();
        display.perform();
        display.start(800, 600);
        display.backgroundColor("green");

        const player = new Component(40, 40, "blue", 400, 300, "rect");
        display.add(player);

        const scoreText = new Tctxt("24px", "Arial", "white", 20, 50);
        scoreText.setText("Score: 0 / 10");
        display.add(scoreText);

        const winText = new Tctxt("48px", "Arial", "gold", 400, 300);
        winText.align = "center";
        winText.setText("YOU WIN!");
        winText.hide();
        display.add(winText);

        const restartText = new Tctxt("20px", "Arial", "white", 400, 380);
        restartText.align = "center";
        restartText.setText("Press R to play again");
        restartText.hide();
        display.add(restartText);

        let score = 0;
        const totalCoins = 10;
        let coins = [];

        for (let i = 0; i < totalCoins; i++) {
            let coin = new Component(30, 30, "gold",
                Math.random() * 700 + 50,
                Math.random() * 500 + 50, "rect");
            display.add(coin);
            coins.push(coin);
        }

        function restart() {
            location.reload();
        }

        function update(deltaTime) {
            if (display.keys[82]) { restart(); return; }
            if (!gameActive) return;

            // Player movement
            if (display.keys[37]) player.speedX = -400 * deltaTime;
            else if (display.keys[39]) player.speedX = 400 * deltaTime;
            else player.speedX = 0;

            if (display.keys[38]) player.speedY = -400 * deltaTime;
            else if (display.keys[40]) player.speedY = 400 * deltaTime;
            else player.speedY = 0;

            move.bound(player);

            // Coin collection
            for (let i = 0; i < coins.length; i++) {
                if (player.crashWith(coins[i])) {
                    display.camera.shake(3, 3);
                    coins[i].hide();
                    coins.splice(i, 1);
                    score++;
                    scoreText.setText("Score: " + score + " / " + totalCoins);
                    break;
                }
            }

            // Win condition
            if (score === totalCoins && gameActive) {
                gameActive = false;
                winText.show();
                restartText.show();
                scoreText.hide();
            }
        }
    </script>
</body>
</html>

✅ What You Get:

  • Move with arrow keys
  • Collect gold coins
  • Screen shake on collection
  • Win screen when all coins collected
  • Press R to restart

12. Quick Reference

What you want Code
Start the engine const display = new Display(); display.start(800,600);
Add a coloured box const b = new Component(w,h,"red",x,y); display.add(b);
Move with keys if(display.keys[39]) player.speedX = 250*dt;
Stop moving player.stopMove(); or player.speedX = 0;
Keep inside canvas move.bound(player);
Detect collision if(a.crashWith(b)) { ... }
Show score text const t = new Tctxt("20px","Arial","white",10,30); t.setText("0");
Lock HUD to screen t.fixed(); // every frame
Display an image obj.setImage("img/hero.png");
Detect mouse click if(display.x && btn.clicked()) { ... }
Play a sound const s = new Sound("sfx.wav"); s.play();
Switch game screen display.add(obj, 1); display.scene = 1;

What's Next?

You've completed Level 1: Beginner! 🎉

Level Description
🟢 Level 1 — Beginner ✅ You are here
🟡 Level 2 — Intermediate Physics, tilemaps, camera follow
🟠 Level 3 — Advanced Particles, circle collision, dynamic tilemaps
🔴 Level 4 — 10x Dual‑renderer, performance optimization, engine extension

Special Thanks

"A heartfelt thank you to **GyaanSetu Javascript* for featuring Limn Engine and helping us share this tutorial with the JavaScript community. Your support means the world to us."*

If you're reading this because of GyaanSetu Javascript's post, welcome! We're thrilled to have you here.


Useful Links


Draw your game into existence. 🎨