https://github.com/abusch/pixels-playground
Playground for old-school pixel effects in lua
https://github.com/abusch/pixels-playground
Last synced: about 1 year ago
JSON representation
Playground for old-school pixel effects in lua
- Host: GitHub
- URL: https://github.com/abusch/pixels-playground
- Owner: abusch
- License: other
- Created: 2021-11-24T00:02:58.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-01-20T12:51:24.000Z (over 1 year ago)
- Last Synced: 2025-02-10T11:48:14.553Z (over 1 year ago)
- Language: Rust
- Size: 66.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# pixels-playground
A little experiment to play with old-school pixel effects using lua. Gives you a vaguely mode-13h-ish environment: a 320x240 screen, with a 256-color palette.
Uses [`mlua`](https://crates.io/crates/mlua) for lua integration, [`pixels`](https://crates.io/crates/pixels) for rendering. Effects ported over from [this repo](https://seancode.com/demofx/).
## To run:
You need a working Rust environment, then run `cargo run --release -- lua/blobs.lua` (or another script).
## API
Provides a tiny api, vaguely inspired by pico-8:
- `pset(x, y, c)`: sets the pixel at coordinates (x,y) to color index `c`
- `cls(c)`: clear screen with color `c`
- `pal(c, r, g, b)`: set palette index `c` to color (r,g,b)
- more to come...
Lua scripts simply need to define a `Render(t)` function where you can do your rendering. The argument passed in is the current time in milliseconds. You can also define an optional `Init()` function that will be called once at the beginning (and when hot-reloading).
## TODO
- [ ] better error handling
- [x] hot-reload of lua scripts
- [ ] more api
## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.