Skip to content

l0kod/PX8

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Build Status

PX8

PX8 is an open source fantasy console (128x128 pixels) in Rust, where the cartridge code could be in Python or Lua.

It is still in development but the main features are:

  • 128x128 pixels, 16 colours
  • Python 3 / Lua 5.X support for the cartridge
  • Controls with dpad + 2 buttons (gamecontroller/joystick support)
  • No limit size in the code !
  • Unlimited sprites (8x8)
  • Map support (128x32)
  • Edition of the cartridge data
  • PX8 format to use your favorite code editor
  • Screenshot (PNG) / Video recording (GIF)
  • Pico-8 (P8/P8.PNG) cartridge format support
  • Mainly run @60 FPS

It should work on all platform (Linux/OSX/Windows), and on tiny hardware like Raspberry Pi (with opengl enabled).

The console is inspired from Pico-8, so you can play Pico-8 cartridges (P8/P8.PNG).

  • Youtube Video

[PX8 SKI] (https://youtu.be/b-secxed-fk "PX8 SKI")

  • Recorded GIF

The time for each frame is slow (10ms) in the GIF, and doesn't correspond to the speed of the game (see the previous videos on Youtube).

Download

You can get directly the latest version via git:

git clone https://github.com/Gigoteur/PX8.git
cd PX8

Binaries

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)

Requirements

You will need multiple things:

  • SDL2
  • python3
  • libreadline

Linux

Packages:

  • libsdl2-dev
  • libreadline-dev
  • libpython3-dev
Raspberry Pi

Please enable the GL Driver (7 - Advanced Options -> Ac - GL Driver -> Yes) via:

sudo raspi-config

OSX

Build

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 

Run a cartridge

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, or in fullscreen by using '-f' option.

Edit a cartridge

You can edit the cartridge by using the specific '-e' option:

./target/release/px8 -s 4 -e ./games/ski/ski.px8

Keyboard Shortcut

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

Game controller / Joystick

Change shortcuts

Add player

Create a new cartridge

PX8 could 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 :)

Python

def _init():
  print("INIT")
  
def _update():
  px8_print("UPDATE")
  
def _draw():
  px8_print("DRAW")

Lua


Cartridge format

Format Read Write
P8 βœ… βœ…
P8.PNG βœ… πŸ”΄
PX8 βœ… βœ…

API documentation

See API

PX8 Format documentation

Compatible API with Pico-8

Audio

API Python Lua
sfx πŸ”΄ πŸ”΄
music πŸ”΄ πŸ”΄

Cart Data

API Python Lua
cartdata πŸ”΄ πŸ”΄
dget πŸ”΄ πŸ”΄
dset πŸ”΄ πŸ”΄

Graphics

API Python Lua
camera βœ… βœ…
circ βœ… βœ…
circfill βœ… βœ…
clip πŸ”΄ πŸ”΄
cls βœ… βœ…
color βœ… βœ…
cursor πŸ”΄ πŸ”΄
fget πŸ”΄ πŸ”΄
flip πŸ”΄ πŸ”΄
fset πŸ”΄ πŸ”΄
line βœ… βœ…
print βœ… (px8_print) βœ…
pal βœ… βœ…
palt βœ… βœ…
pget βœ… βœ…
print βœ… βœ…
pset βœ… βœ…
rect βœ… βœ…
rectfill βœ… βœ…
sget βœ… βœ…
spr βœ… βœ…
sspr βœ… βœ…

Input

API Python Lua
btn βœ… βœ…
btnp βœ… βœ…

Map

API Python Lua
map βœ… (spr_map) βœ…
mget πŸ”΄ βœ…
mset πŸ”΄ βœ…

Math

API Python Lua
rnd βœ… (random.randint) βœ…
flr βœ… (math.floor) βœ…
ceil βœ… (math.ceil) βœ…
cos βœ… βœ…
sin βœ… βœ…
atan2 πŸ”΄ βœ…
sqrt βœ… (math.sqrt) βœ…
abs βœ… (math.abs) βœ…
sgn βœ… βœ…
band βœ… βœ…
bor βœ… βœ…
bxor βœ… βœ…
bnot βœ… βœ…
shl βœ… βœ…
shr βœ… βœ…
sub βœ… βœ…

Memory

API Python Lua
cstore πŸ”΄ πŸ”΄
memcpy πŸ”΄ πŸ”΄
memset πŸ”΄ πŸ”΄
reload πŸ”΄ πŸ”΄

Peek Poke

API Python Lua
stat πŸ”΄ βœ…
peek πŸ”΄ πŸ”΄
poke πŸ”΄ πŸ”΄

Specific Lua functions

API Lua
add βœ…
del βœ…
min βœ…
max βœ…
mid βœ…
foreach βœ…
count βœ…
all βœ…

Pico-8 compatibility

The version of LUA in Pico-8 has some differences with the original one.

Lua features Compatibility
Compound assignment operators βœ…
Single line shorthand for if then else operator πŸ”΄
Not Equal To πŸ”΄

GFX: βœ…

MUSIC: πŸ”΄

Screenshots and Records

With a physical engine

PX8 + Python + Pymunk

About

Open source fantasy console in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 58.8%
  • Rust 40.1%
  • GLSL 1.1%