เริ่มต้นใช้งาน
TME (Time Mini Engine) คือ game engine ขนาดเล็กสำหรับสร้างเกม 2D ใช้ WebGPU สำหรับ render และมี build system ที่เรียบง่าย
การติดตั้ง
สร้างโปรเจกต์ใหม่
Build
รันเกม
Getting Started
TME (Time Mini Engine) is a small game engine for creating 2D games. Uses WebGPU for rendering and has a simple build system.
Installation
Create New Project
Build
Run Game
Project Structure
โครงสร้างโปรเจกต์
ไฟล์ที่จำเป็น
game.tsl— Game source codeindex.html— ต้องมี<canvas id="game">style.css— User CSS (optional)
Project Structure
Project Layout
Required Files
game.tsl— Game source codeindex.html— Must contain<canvas id="game">style.css— User CSS (optional)
Render
TME ใช้ WebGPU สำหรับ rendering — ไม่มี Canvas2D/WebGL fallback
rect()
วาดสี่เหลี่ยม
| Parameter | Type | Default |
|---|---|---|
| x, y | number | — |
| width, height | number | — |
| color | string | — |
| rotation | number | 0 (radians) |
| scale | number | 1 (รองรับทศนิยม) |
| alpha | number | 1 |
image()
วาดรูปภาพ
Image โหลดแบบ on-demand — โหลดเมื่อใช้เท่านั้น
Render
TME uses WebGPU for rendering — no Canvas2D/WebGL fallback.
rect()
Draw a rectangle.
| Parameter | Type | Default |
|---|---|---|
| x, y | number | — |
| width, height | number | — |
| color | string | — |
| rotation | number | 0 (radians) |
| scale | number | 1 (supports decimals) |
| alpha | number | 1 |
image()
Draw an image.
Images load on-demand — only loaded when used.
Input
รองรับ keyboard, mouse, touch
Keyboard
Mouse
Touch
Input
Supports keyboard, mouse, touch.
Keyboard
Mouse
Touch
Audio
ใช้ audio object เดียวสำหรับ SFX และ BGM
Sound Effects
Background Music
Control
Audio
Uses one unified audio object for SFX and BGM.
Sound Effects
Background Music
Control
Game Loop
TEMF runtime จัดการ game loop — คุณแค่เขียน update และ draw
โครงสร้าง
Fixed Timestep
update(dt) ใช้ fixed timestep — dt มีค่าคงที่ทุก frame
ปรับ FPS
ใช้ fps() เพื่อปรับ framerate
Game Loop
TEMF runtime manages the game loop — you just write update and draw.
Structure
Fixed Timestep
update(dt) uses fixed timestep — dt is constant every frame.
Set FPS
Use fps() to adjust framerate
Build
Build Program orchestrate การ build ทั้งหมด
คำสั่ง
Output
กฎสำคัญ
- WebGPU เท่านั้น — ไม่มี fallback
- index.html ต้องมี canvas#game
- style.css เป็น user-owned — build ไม่ทับ
- TSL เป็น external read-only — build ไม่แก้
Build
Build Program orchestrates the entire build process.
Commands
Output
Important Rules
- WebGPU only — no fallback
- index.html must have canvas#game
- style.css is user-owned — build never overwrites
- TSL is external read-only — build never modifies