Pyxel is published under MIT License.
This allow you to use 2D sprites, sound and interactions.
The project can be found at the GitHub webpage.
The basic features are:
- Run on Windows, Mac, and Linux
- Code writing with Python3
- Fixed 16 color palette
- 256x256 sized 3 image banks
- 256x256 sized 8 tilemaps
- 4 channels with 64 definable sounds
- 8 musics which can combine arbitrary sounds
- Keyboard, mouse, and gamepad inputs
- Image and sound editor
pip3 install pyxel
Collecting pyxel
...
Successfully installed altgraph-0.17 pefile-2019.4.18 pyinstaller-3.6 pywin32-ctypes-0.2.0 pyxel-1.3.7
Use this command to start the tool for create sprites and sounds.pyxeleditor
You can test many examples on GitHub.The basic example from the web is simple:
import pyxel
class App:
def __init__(self):
pyxel.init(160, 120, caption="Hello Pyxel")
pyxel.image(0).load(0, 0, "assets/pyxel_logo_38x16.png")
pyxel.run(self.update, self.draw)
def update(self):
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
def draw(self):
pyxel.cls(0)
pyxel.text(55, 41, "Hello, Pyxel!", pyxel.frame_count % 16)
pyxel.blt(61, 66, 0, 0, 0, 38, 16)
App()
I start with a simple example. I don't find a collision system on Pyxel. Let's see the source code:
import pyxel
from pyxel import circ, cls, flip, init
from random import randint
# the position of the ball
x = y = 30
# the speed of the ball
v = w = 3
# create the screen as 160x120 size
pyxel.init(160, 112)
#
data = [70, 60, 30, 70]
# draw a line below the bar chart
while True:
# erase the screen with color number 1 (blue)
pyxel.cls(1)
# process the movement of the ball
x += v
y += w
r = randint(0, 160)
a = randint(0, 112)
rr = randint(0, 160)
aa = randint(0, 112)
# create random lines on screen
pyxel.line(a, aa, r, rr, 5)
# set the border
if x <= 7 or x >= 160:
x = min(max(x, 7), 160)
v = -v
if y <= 7 or y >= 112:
y = min(max(y, 7), 112)
w = -w
# draw the ball with different colors
pyxel.circ(x, y, 4, pyxel.frame_count % 8)
# create a simple chart
for i, d in enumerate(data):
pyxel.rect(i * 33 + 10, 120 - d, 10, d, 8 + i)
# draw the game
pyxel.flip()