Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/litecanvas/game-engine
🎮 Lightweight HTML5 canvas engine suitable for small games, prototypes and animations.
https://github.com/litecanvas/game-engine
canvas fantasy-console game-development game-engine gamedev hacktoberfest html5 js13k
Last synced: 1 day ago
JSON representation
🎮 Lightweight HTML5 canvas engine suitable for small games, prototypes and animations.
- Host: GitHub
- URL: https://github.com/litecanvas/game-engine
- Owner: litecanvas
- License: mit
- Created: 2024-02-25T19:53:10.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-11-22T18:22:35.000Z (about 1 month ago)
- Last Synced: 2024-12-18T18:07:30.201Z (9 days ago)
- Topics: canvas, fantasy-console, game-development, game-engine, gamedev, hacktoberfest, html5, js13k
- Language: JavaScript
- Homepage: https://litecanvas.js.org/
- Size: 626 KB
- Stars: 30
- Watchers: 3
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![logo](https://github.com/user-attachments/assets/cbff543a-17be-44e4-b4ce-f9ff0a0581bb)
# Litecanvas
[![Discord Server](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.com/invite/r2c3rGsvH3)
Litecanvas is a lightweight HTML5 canvas engine suitable for small web games, prototypes, game jams, animations, creative coding, learning game programming and game design, etc.
:warning: **This project is still under development. All feedback is appreciated!** :warning:
### Features
- **Tiny**: Only `~4KB` (minified + gzipped).
- **Simple API**: Just few functions to draw shapes and some utilities.
- **Predefined colors**: Just use a number (from 0 to 11) to choose a color in our 12-color palette.
- **ZzFX**: Play or create sound effects with [ZzFX](https://killedbyapixel.github.io/ZzFX/).
- **Extensible**: Use or create [plugins](https://www.npmjs.com/search?q=keywords:litecanvas) to add functionalities or change the engine.
- **Playground**: Access or install the [playground](https://litecanvas.js.org/) webapp to code and share games (even offline).[Learn more in the cheatsheet...](https://litecanvas.js.org/about.html)
## Getting Started
You can try our [online playground](https://litecanvas.github.io) or just installing the [basic template](https://github.com/litecanvas/template):
```sh
# requires Node.js
npx tiged litecanvas/template my-game
cd my-game
npm install
npm run dev
```If you prefer, you can manually install the package via NPM:
```
npm install litecanvas
``````js
// import the engine or put the script in your HTML
// CDN: https://unpkg.com/litecanvas/dist/dist.min.js
import litecanvas from 'litecanvas'// you can setup other configurations here
// learn more in the cheatsheet
litecanvas({
loop: { init, update, draw, tapped },
})function init() {
// this function run once
// before the game starts
bg = 0
color = 3
radius = 32
posx = CENTERX
posy = CENTERY
}// this function detect taps/clicks
// and changes the circle position
function tapped(x, y) {
posx = x
posy = y
}// this function controls the game logic
function update(dt) {
// make the circle falls 100 pixels per second
posy += 100 * dt
}// this function render the game scene
function draw() {
cls(bg) // clear the screen
circfill(posx, posy, radius, color) // draw a circle
}
```## Docs
Check out our [Cheatsheet](https://litecanvas.js.org/about.html).
## Basic Demos
Try some demos in our playground:
- [Pong](https://litecanvas.js.org?c=eJy1Vlly20YQ%2FccpOl8ATBACuEiWYslFM5DlKkdMkUwkJpVKwcCQnAoEoIChpdiWr%2BAT%2BC%2BHyHlygVwh3TODTZYU%2F0QsDdELenm9DBMmIA%2FjCzgGf%2BA5BuAf0mdEj2vykkivEa%2BQHg01HbNSkALpKc6bMElaj6vmccHfsZZpYk3STUK8yhovpLeaWjVUmTMWIzmoQimjrGi9m%2FA1K5EcKlKwG0EOta4ICyFfX4dJyQwj4YJFYfo2LK33UuOax2J7BMMKhy3jm604gtFTZNzahrG3B9NdKbIr%2BPnd6SWU2S6NS1hnBYgtL2ETXjHSyQsmBGdFn29SjM%2BIsrQU8GL24%2Fk0QPe%2FOOCAz4b05XpDOgbIcGBAHAcOR54WVB8XJe6%2B0t%2F%2F9duHfSyWk%2FmSXHju2EFUYIxIyddGeAzbXsYHnvYsD%2B3IGz1m%2FsXk9evfZqeni%2Bk8CM7Jj%2B8OfZnOGB14rkdeyQ8eB9KbpPqH7iGe%2B3TSx3N9v3oayPfkOZKnTxka610aCZ6lwFMuLBveN42FfqfB%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/floppy): a micro game engine for beginners.
- [PICO-8](https://www.lexaloffle.com/pico-8.php): fantasy console for making, sharing and playing tiny games.
- [js13kGames](https://js13kgames.com/): a JavaScript coding competition with size limit set to 13 kilobytes.
- [raylib](https://www.raylib.com/): a simple and easy-to-use gamedev library.
- [p5.js/Processing](https://p5js.org/): a library for creative coding.