PX8 is an open source fantasy console (128x128 pixels) in Rust, by using a cartridge that contains the code/gfx/music. The code could be in Python/Lua, or you could create directly everything in Rust.
It is still in development, but it is usable and the main features are: * 128x128 pixels, 16 colours * Python 3 / Lua 5.X support for the cartridge (no tokens limit) * Desktop/Mobile/Browser (Emscripten) support * Controls with dpad + 2 buttons (gamecontroller/joystick support) * Unlimited sprites (8x8) * Map support (128x32) * Edition of the cartridge data * PX8 format to be able to use your favorite code editor * Change the screen definition * Screenshot (PNG) / Video recording (GIF) * Pico-8 (P8/P8.PNG) cartridge format support
It works on all platforms (Linux/OSX/Windows), in the browser (via Emscripten), and on tiny hardware like Raspberry Pi.
The console is inspired from the awesome Pico-8, so a compatibility is available with Pico-8 cartridges (P8/PNG).
The time for each frame is slow (10ms) in the GIF, and doesn't correspond to the speed of the game.
You can get directly the latest version via git:
git clone https://github.com/Gigoteur/PX8.git
cd PX8
Or you can get binaries for multiples platforms directly on itch.io: * Raspberry Pi (available) * Windows (Work in progress) * Linux (Work in progress) * Mac (Work in progress)
You will need multiple things: * SDL2 * python3 * libreadline
Packages: * libsdl2-dev * libreadline-dev * libpython3-dev
Please enable the GL Driver (7 - Advanced Options -> Ac - GL Driver -> Yes) via:
sudo raspi-config
You could build PX8 with cargo directly, in release mode for example, with the support of Python and Lua.
cargo build --features="cpython lua" --release
If you want to use only the SDL renderer without opengl, you could use the sdl_renderer feature:
cargo build --features="sdl_renderer" --release
You must follow the following guide to install Emscripten.
After that you need to use the sdl_renderer feature to have a working example in the browser.
You can see example of PX8 + Emscripten in the demos repository. You could also see live example from your browser: * Hello World [Source Code] [Live Demo] * Lua Cartridge [Source Code] [Live Demo] * Cast [Source Code] [Live Demo]
You should be able to run it directly by providing the path of the cartridge:
./target/release/px8 -s 4 ./games/ski/ski.px8
The '-s' option is the scale, so you can increase it (2/4/8/10), or in fullscreen by using '-f' option.
You could run the API demos:
./target/release/px8 -s 4 ./demos/api_demos.py
or some fancy demos:
./target/release/px8 -s 4 ./demos/demos.py
You can edit the cartridge by using the specific '-e' option:
./target/release/px8 -s 4 -e ./games/ski/ski.px8
Player 1: * cursors, Z,X / C,V / N,M
Player 2: * ESDF, LSHIFT,A / TAB,Q,E
System shortcut: * F2: FPS debug * F3: Take a screenshot * F4: Take a video * F5: Save the current cartridge * F6: Switch between editor/play mode
PX8 will call 3 functions: * _init : Called once on cartridge startup, mainly to initialize your variables * _update: Called once per visible frame, mainly to get keyboard input for example * _draw: Called once per visible frame, mainly to draw things on the screen :)
After that you can use the API to draw whatever you want !
You can create a classical Python program, all you need is to define the previous functions (_init, _update, _draw), and you can import any packages.
``` def init(): px8print("INIT")
def update(): px8print("UPDATE")
def draw(): px8print("DRAW") ```
``` function _init() print("INIT") end
function _update() print("UPDATE") end
function _draw() print("DRAW") end ```
Format | Read | Write ------------ | ------------- | ------------- P8 | :whitecheckmark: | :whitecheckmark: P8.PNG | :whitecheckmark: | :redcircle: PX8 | :whitecheckmark: | :whitecheck_mark:
See API
API | Python | Lua ------------ | ------------- | ------------- sfx | :redcircle: | :redcircle: music | :redcircle: | :redcircle:
API | Python | Lua ------------ | ------------- | ------------- cartdata | :redcircle: | :redcircle: dget | :redcircle: | :redcircle: dset | :redcircle: | :redcircle:
API | Python | Lua ------------ | ------------- | ------------- camera | :whitecheckmark: | :whitecheckmark: circ | :whitecheckmark: | :whitecheckmark: circfill | :whitecheckmark: | :whitecheckmark: clip | :redcircle: | :redcircle: cls | :whitecheckmark: | :whitecheckmark: color | :whitecheckmark: | :whitecheckmark: cursor | :redcircle: | :redcircle: fget | :redcircle: | :redcircle: flip | :redcircle: | :redcircle: fset | :redcircle: | :redcircle: line | :whitecheckmark: | :whitecheckmark: print | :whitecheckmark: (px8print) | :whitecheckmark: pal | :whitecheckmark: | :whitecheckmark: palt | :whitecheckmark: | :whitecheckmark: pget | :whitecheckmark: | :whitecheckmark: print | :whitecheckmark: | :whitecheckmark: pset | :whitecheckmark: | :whitecheckmark: rect | :whitecheckmark: | :whitecheckmark: rectfill | :whitecheckmark: | :whitecheckmark: sget | :whitecheckmark: | :whitecheckmark: spr | :whitecheckmark: | :whitecheckmark: sspr | :whitecheckmark: | :whitecheck_mark:
API | Python | Lua ------------ | ------------- | ------------- btn | :whitecheckmark: | :whitecheckmark: btnp | :whitecheckmark: | :whitecheckmark:
API | Python | Lua ------------ | ------------- | ------------- map | :whitecheckmark: (sprmap) | :whitecheckmark: mget | :whitecheckmark: | :whitecheckmark: mset | :whitecheckmark: | :whitecheck_mark:
API | Python | Lua ------------ | ------------- | ------------- rnd | :whitecheckmark: | :whitecheckmark: flr | :whitecheckmark: | :whitecheckmark: ceil | :whitecheckmark: (math.ceil) | :whitecheckmark: cos | :whitecheckmark: | :whitecheckmark: sin | :whitecheckmark: | :whitecheckmark: atan2 | :redcircle: | :whitecheckmark: sqrt | :whitecheckmark: (math.sqrt) | :whitecheckmark: abs | :whitecheckmark: (math.abs) | :whitecheckmark: sgn | :whitecheckmark: | :whitecheckmark: band | :whitecheckmark: | :whitecheckmark: bor | :whitecheckmark: | :whitecheckmark: bxor | :whitecheckmark: | :whitecheckmark: bnot | :whitecheckmark: | :whitecheckmark: shl | :whitecheckmark: | :whitecheckmark: shr | :whitecheckmark: | :whitecheckmark: sub | :whitecheckmark: | :whitecheck_mark:
API | Python | Lua ------------ | ------------- | ------------- cstore | :redcircle: | :redcircle: memcpy | :redcircle: | :redcircle: memset | :redcircle: | :redcircle: reload | :redcircle: | :redcircle:
API | Python | Lua ------------ | ------------- | ------------- stat | :redcircle: | :whitecheckmark: peek | :redcircle: | :redcircle: poke | :redcircle: | :red_circle:
API | Lua ------------ | ------------- add | :whitecheckmark: del | :whitecheckmark: min | :whitecheckmark: max | :whitecheckmark: mid | :whitecheckmark: foreach | :whitecheckmark: count | :whitecheckmark: all | :whitecheckmark:
The version of LUA in Pico-8 has some differences with the original one.
Lua features | Compatibility ------------ | ------------- Compound assignment operators | :whitecheckmark: Single line shorthand for if then else operator | :redcircle: Not Equal To | :redcircle:
GFX: :whitecheckmark:
MUSIC: :red_circle:
It is simple with Python support to use for example the Pymunk physical engine.
Please check the example in the demos directory.