[ English | 中文 | Deutsch | Español | Français | Italiano | 日本語 | 한국어 | Português | Русский | Türkçe | Українська ]
Pyxel is a retro game engine for Python.
Thanks to its simple specifications inspired by retro gaming consoles, such as only 16 colors can be displayed and only 4 sounds can be played back at the same time, you can feel free to enjoy making pixel art style games.
The motivation for the development of Pyxel is the feedback from users. Please give Pyxel a star on GitHub!
Pyxel's specifications and APIs are inspired by PICO-8 and TIC-80.
Pyxel is open source and free to use. Let's start making a retro game with Pyxel!
- Runs on Windows, Mac, Linux, and Web
- Programming in Python
- 16-color palette
- 256x256-sized 3 image banks
- 256x256-sized 8 tilemaps
- 4 channels with 64 definable sounds
- 8 music tracks that can combine any sounds
- Keyboard, mouse, and gamepad inputs
- Image and sound editor
- User expansion of colors, channels, and banks
After installing Python3 (version 3.8 or higher), run the following command:
pip install -U pyxel
If you install Python using the official installer, please check the Add Python 3.x to PATH
checkbox to enable pyxel
command.
After installing Homebrew, run the following commands:
brew install pipx
pipx ensurepath
pipx install pyxel
To update the version after installing Pyxel, run pipx upgrade pyxel
.
After installing the SDL2 package (libsdl2-dev
for Ubuntu), Python3 (version 3.8 or higher), and python3-pip
, run the following command:
sudo pip3 install -U pyxel
If the above doesn't work, try self-building according to the instructions in Makefile.
The web version of Pyxel does not require Python or Pyxel installation and runs on PCs as well as smartphones and tablets with supported web browsers.
For specific instructions, please refer to this page.
After installing Pyxel, the examples of Pyxel will be copied to the current directory with the following command:
pyxel copy_examples
The examples to be copied are as follows:
01_hello_pyxel.py | Simplest application | Demo | Code |
02_jump_game.py | Jump game with Pyxel resource file | Demo | Code |
03_draw_api.py | Demonstration of drawing APIs | Demo | Code |
04_sound_api.py | Demonstration of sound APIs | Demo | Code |
05_color_palette.py | Color palette list | Demo | Code |
06_click_game.py | Mouse click game | Demo | Code |
07_snake.py | Snake game with BGM | Demo | Code |
08_triangle_api.py | Demonstration of triangle drawing APIs | Demo | Code |
09_shooter.py | Shoot'em up game with screen transition | Demo | Code |
10_platformer.py | Side-scrolling platform game with map | Demo | Code |
11_offscreen.py | Offscreen rendering with Image class | Demo | Code |
12_perlin_noise.py | Perlin noise animation | Demo | Code |
13_bitmap_font.py | Drawing a bitmap font | Demo | Code |
14_synthesizer.py | Synthesizer utilizing audio expantion features | Demo | Code |
15_tiled_map_file.py | Loading and drawing a Tile Map File (.tmx) | Demo | Code |
16_transform.py | Image rotation and scaling | Demo | Code |
99_flip_animation.py | Animation with flip function (non-web platforms only) | Demo | Code |
30sec_of_daylight.pyxapp | 1st Pyxel Jam winning game by Adam | Demo | Code |
megaball.pyxapp | Arcade ball physics game by Adam | Demo | Code |
8bit-bgm-gen.pyxapp | Background music generator by frenchbread | Demo | Code |
An examples can be executed with the following commands:
cd pyxel_examples
pyxel run 01_hello_pyxel.py
pyxel play 30sec_of_daylight.pyxapp
After importing the Pyxel module in your python script, specify the window size with init
function first, then starts the Pyxel application with run
function.
import pyxel
pyxel.init(160, 120)
def update():
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
def draw():
pyxel.cls(0)
pyxel.rect(10, 10, 20, 20, 11)
pyxel.run(update, draw)
The arguments of run
function are update
function to update each frame and draw
function to draw screen when necessary.
In an actual application, it is recommended to wrap pyxel code in a class as below:
import pyxel
class App:
def __init__(self):
pyxel.init(160, 120)
self.x = 0
pyxel.run(self.update, self.draw)
def update(self):
self.x = (self.x + 1) % pyxel.width
def draw(self):
pyxel.cls(0)
pyxel.rect(self.x, 0, 8, 8, 9)
App()
When creating simple graphics without animation, show
function can be used to make the code more concise.
import pyxel
pyxel.init(120, 120)
pyxel.cls(1)
pyxel.circb(60, 60, 40, 7)
pyxel.show()
A created Python script can be executed using the python
command:
python PYTHON_SCRIPT_FILE
It can also be run with the pyxel run
command:
pyxel run PYTHON_SCRIPT_FILE
Additionally, the pyxel watch
command enables monitoring of changes in a specified directory, automatically re-running the program when changes are detected:
pyxel watch WATCH_DIR PYTHON_SCRIPT_FILE
Directory monitoring can be stopped by pressing Ctrl(Command)+C
.
The following special controls can be performed while a Pyxel application is running:
Esc
Quit the applicationAlt(Option)+1
Save the screenshot to the desktopAlt(Option)+2
Reset the recording start time of the screen capture videoAlt(Option)+3
Save the screen capture video to the desktop (up to 10 seconds)Alt(Option)+9
Switch between screen modes (Crisp/Smooth/Retro)Alt(Option)+0
Toggle the performance monitor (fps, update time, and draw time)Alt(Option)+Enter
Toggle full screenShift+Alt(Option)+1/2/3
Save the corresponding image bank to the desktopShift+Alt(Option)+0
Save the current color palette to the desktop
Pyxel Editor can create images and sounds used in a Pyxel application.
It starts with the following command:
pyxel edit PYXEL_RESOURCE_FILE
If the specified Pyxel resource file (.pyxres) exists, the file is loaded, and if it does not exist, a new file is created with the specified name. If the resource file is omitted, the name is my_resource.pyxres
.
After starting Pyxel Editor, the file can be switched by dragging and dropping another resource file.
The created resource file can be loaded with load
function.
Pyxel Editor has the following edit modes.
Image Editor
The mode to edit the image banks.
Drag and drop an image file (PNG/GIF/JPEG) onto the Image Editor to load the image into the currently selected image bank.
Tilemap Editor
The mode to edit tilemaps in which images of the image banks are arranged in a tile pattern.
Drag and drop a TMX file (Tiled Map File) onto the Tilemap Editor to load its layer in the drawing order that corresponds to the currently selected tilemap number.
Sound Editor
The mode to edit sounds.
Music Editor
The mode to edit musics in which the sounds are arranged in order of playback.
Pyxel images and tilemaps can also be created by the following methods:
- Create an image from a list of strings with
Image.set
function orTilemap.set
function - Load an image file (PNG/GIF/JPEG) in Pyxel palette with
Image.load
function
Pyxel sounds can also be created in the following method:
- Create a sound from strings with
Sound.set
function orMusic.set
function
Please refer to the API reference for usage of these functions.
Pyxel supports a dedicated application distribution file format (Pyxel application file) that works across platforms.
Create the Pyxel application file (.pyxapp) with the pyxel package
command:
pyxel package APP_DIR STARTUP_SCRIPT_FILE
If the application should include resources or additional modules, place them in the application directory.
Metadata can be displayed at runtime by specifying it in the following format within the startup script. Fields other than title
and author
can be omitted.
# title: Pyxel Platformer
# author: Takashi Kitao
# desc: A Pyxel platformer example
# site: https://github.com/kitao/pyxel
# license: MIT
# version: 1.0
The created application file can be executed with the pyxel play
command:
pyxel play PYXEL_APP_FILE
Pyxel application file also can be converted to an executable or an HTML file with the pyxel app2exe
or pyxel app2html
commands.
-
width
,height
The width and height of the screen -
frame_count
The number of the elapsed frames -
init(width, height, [title], [fps], [quit_key], [display_scale], [capture_scale], [capture_sec])
Initialize the Pyxel application with screen size (width
,height
). The following can be specified as options: the window title withtitle
, the frame rate withfps
, the key to quit the application withquit_key
, the scale of the display withdisplay_scale
, the scale of the screen capture withcapture_scale
, and the maximum recording time of the screen capture video withcapture_sec
.
e.g.pyxel.init(160, 120, title="My Pyxel App", fps=60, quit_key=pyxel.KEY_NONE, capture_scale=3, capture_sec=0)
-
run(update, draw)
Start the Pyxel application and callupdate
function for frame update anddraw
function for drawing. -
show()
Show the screen and wait until theEsc
key is pressed. -
flip()
Refresh the screen by one frame. The application exits when theEsc
key is pressed. This function does not work in the web version. -
quit()
Quit the Pyxel application.
load(filename, [excl_images], [excl_tilemaps], [excl_sounds], [excl_musics])
Load the resource file (.pyxres). If an option isTrue
, the resource will not be loaded. If a palette file (.pyxpal) of the same name exists in the same location as the resource file, the palette display color will also be changed. The palette file is a hexadecimal entry of the display colors (e.g.1100FF
), separated by newlines. The palette file can also be used to change the colors displayed in Pyxel Editor.
-
mouse_x
,mouse_y
The current position of the mouse cursor -
mouse_wheel
The current value of the mouse wheel -
btn(key)
ReturnTrue
ifkey
is pressed, otherwise returnFalse
. (Key definition list) -
btnp(key, [hold], [repeat])
ReturnTrue
ifkey
is pressed at that frame, otherwise returnFalse
. Whenhold
andrepeat
are specified,True
will be returned at therepeat
frame interval when thekey
is held down for more thanhold
frames. -
btnr(key)
ReturnTrue
ifkey
is released at that frame, otherwise returnFalse
. -
mouse(visible)
Ifvisible
isTrue
, show the mouse cursor. IfFalse
, hide it. Even if the mouse cursor is not displayed, its position is updated.
-
colors
List of the palette display colors. The display color is specified by a 24-bit numerical value. Usecolors.from_list
andcolors.to_list
to directly assign and retrieve Python lists.
e.g.old_colors = pyxel.colors.to_list(); pyxel.colors.from_list([0x111111, 0x222222, 0x333333]); pyxel.colors[15] = 0x112233
-
images
List of the image banks (0-2). (See the Image class)
e.g.pyxel.images[0].load(0, 0, "title.png")
-
tilemaps
List of the tilemaps (0-7). (See the Tilemap class) -
clip(x, y, w, h)
Set the drawing area of the screen from (x
,y
) to widthw
and heighth
. Reset the drawing area to full screen withclip()
. -
camera(x, y)
Change the upper left corner coordinates of the screen to (x
,y
). Reset the upper left corner coordinates to (0
,0
) withcamera()
. -
pal(col1, col2)
Replace colorcol1
withcol2
at drawing.pal()
to reset to the initial palette. -
dither(alpha)
Applies dithering (pseudo-transparency) at drawing. Setalpha
in the range 0.0-1.0, where 0.0 is transparent and 1.0 is opaque. -
cls(col)
Clear screen with colorcol
. -
pget(x, y)
Get the color of the pixel at (x
,y
). -
pset(x, y, col)
Draw a pixel of colorcol
at (x
,y
). -
line(x1, y1, x2, y2, col)
Draw a line of colorcol
from (x1
,y1
) to (x2
,y2
). -
rect(x, y, w, h, col)
Draw a rectangle of widthw
, heighth
and colorcol
from (x
,y
). -
rectb(x, y, w, h, col)
Draw the outline of a rectangle of widthw
, heighth
and colorcol
from (x
,y
). -
circ(x, y, r, col)
Draw a circle of radiusr
and colorcol
at (x
,y
). -
circb(x, y, r, col)
Draw the outline of a circle of radiusr
and colorcol
at (x
,y
). -
elli(x, y, w, h, col)
Draw an ellipse of widthw
, heighth
and colorcol
from (x
,y
). -
ellib(x, y, w, h, col)
Draw the outline of an ellipse of widthw
, heighth
and colorcol
from (x
,y
). -
tri(x1, y1, x2, y2, x3, y3, col)
Draw a triangle with vertices (x1
,y1
), (x2
,y2
), (x3
,y3
) and colorcol
. -
trib(x1, y1, x2, y2, x3, y3, col)
Draw the outline of a triangle with vertices (x1
,y1
), (x2
,y2
), (x3
,y3
) and colorcol
. -
fill(x, y, col)
Fill the area connected with the same color as (x
,y
) with colorcol
. -
blt(x, y, img, u, v, w, h, [colkey], [rotate], [scale])
Copy the region of size (w
,h
) from (u
,v
) of the image bankimg
(0-2) to (x
,y
). If negative value is set forw
and/orh
, it will reverse horizontally and/or vertically. Ifcolkey
is specified, treated as transparent color. Ifrotate
(in degrees),scale
(1.0 = 100%), or both are specified, the corresponding transformation will be applied.
bltm(x, y, tm, u, v, w, h, [colkey], [rotate], [scale])
Copy the region of size (w
,h
) from (u
,v
) of the tilemaptm
(0-7) to (x
,y
). If negative value is set forw
and/orh
, it will reverse horizontally and/or vertically. Ifcolkey
is specified, treated as transparent color. Ifrotate
(in degrees),scale
(1.0 = 100%), or both are specified, the corresponding transformation will be applied. The size of a tile is 8x8 pixels and is stored in a tilemap as a tuple of(tile_x, tile_y)
.
text(x, y, s, col)
Draw a strings
of colorcol
at (x
,y
).
-
sounds
List of the sounds (0-63). (See the Sound class)
e.g.pyxel.sounds[0].speed = 60
-
musics
List of the musics (0-7). (See the Music class) -
play(ch, snd, [tick], [loop], [resume])
Play the soundsnd
(0-63) on channelch
(0-3). Ifsnd
is a list, it will be played in order. The playback start position can be specified bytick
(1 tick = 1/120 seconds). IfTrue
is specified forloop
, loop playback is performed. To resume the previous sound after playback ends, setresume
toTrue
. -
playm(msc, [tick], [loop])
Play the musicmsc
(0-7). The playback start position can be specified bytick
(1 tick = 1/120 seconds). IfTrue
is specified forloop
, loop playback is performed. -
stop([ch])
Stops playback of the specified channelch
(0-3).stop()
to stop playing all channels. -
play_pos(ch)
Get the sound playback position of channelch
(0-3) as a tuple of(sound no, note no)
. ReturnsNone
when playback is stopped.
-
ceil(x)
Returns the smallest integer greater than or equal tox
. -
floor(x)
Returns the largest integer less than or equal tox
. -
sgn(x)
Returns 1 whenx
is positive, 0 when it is zero, and -1 when it is negative. -
sqrt(x)
Returns the square root ofx
. -
sin(deg)
Returns the sine ofdeg
degrees. -
cos(deg)
Returns the cosine ofdeg
degrees. -
atan2(y, x)
Returns the arctangent ofy
/x
in degrees. -
rseed(seed)
Sets the seed of the random number generator. -
rndi(a, b)
Returns an random integer greater than or equal toa
and less than or equal tob
. -
rndf(a, b)
Returns a random decimal greater than or equal toa
and less than or equal tob
. -
nseed(seed)
Sets the seed of Perlin noise. -
noise(x, [y], [z])
Returns the Perlin noise value for the specified coordinates.
-
width
,height
The width and height of the image -
set(x, y, data)
Set the image at (x
,y
) by a list of strings.
e.g.pyxel.images[0].set(10, 10, ["0123", "4567", "89ab", "cdef"])
-
load(x, y, filename)
Load the image file (PNG/GIF/JPEG) at (x
,y
). -
pget(x, y)
Get the pixel color at (x
,y
). -
pset(x, y, col)
Draw a pixel of colorcol
at (x
,y
).
-
width
,height
The width and height of the tilemap -
imgsrc
The image bank (0-2) referenced by the tilemap -
set(x, y, data)
Set the tilemap at (x
,y
) by a list of strings.
e.g.pyxel.tilemap(0).set(0, 0, ["0000 0100 a0b0", "0001 0101 a1b1"])
-
load(x, y, filename, layer)
Load the layer in the drawing orderlayer
(0-) from the TMX file (Tiled Map File) at (x
,y
). -
pget(x, y)
Get the tile at (x
,y
). A tile is a tuple of(tile_x, tile_y)
. -
pset(x, y, tile)
Draw atile
at (x
,y
). A tile is a tuple of(tile_x, tile_y)
.
-
notes
List of notes (0-127). The higher the number, the higher the pitch, and at 33 it becomes 'A2'(440Hz). The rest is -1. -
tones
List of tones (0:Triangle / 1:Square / 2:Pulse / 3:Noise) -
volumes
List of volumes (0-7) -
effects
List of effects (0:None / 1:Slide / 2:Vibrato / 3:FadeOut / 4:Half-FadeOut / 5:Quarter-FadeOut) -
speed
Playback speed. 1 is the fastest, and the larger the number, the slower the playback speed. At 120, the length of one note becomes 1 second. -
set(notes, tones, volumes, effects, speed)
Set notes, tones, volumes, and effects with a string. If the tones, volumes, and effects length are shorter than the notes, it is repeated from the beginning. -
set_notes(notes)
Set the notes with a string made of 'CDEFGAB'+'#-'+'01234' or 'R'. Case-insensitive and whitespace is ignored.
e.g.pyxel.sounds[0].set_notes("G2B-2D3R RF3F3F3")
-
set_tones(tones)
Set the tones with a string made of 'TSPN'. Case-insensitive and whitespace is ignored.
e.g.pyxel.sounds[0].set_tones("TTSS PPPN")
-
set_volumes(volumes)
Set the volumes with a string made of '01234567'. Case-insensitive and whitespace is ignored.
e.g.pyxel.sounds[0].set_volumes("7777 7531")
-
set_effects(effects)
Set the effects with a string made of 'NSVFHQ'. Case-insensitive and whitespace is ignored.
e.g.pyxel.sounds[0].set_effects("NFNF NVVS")
-
seqs
Two-dimensional list of sounds (0-63) with the number of channels -
set(seq0, seq1, seq2, ...)
Set the lists of sound (0-63) of channels. If an empty list is specified, that channel is not used for playback.
e.g.pyxel.musics[0].set([0, 1], [], [3])
Pyxel has "advanced APIs" that are not mentioned in this reference because they "may confuse users" or "need specialized knowledge to use".
If you are familiar with your skills, try to create amazing works with this as a clue!
Use the Issue Tracker to submit bug reports and feature/enhancement requests. Before submitting a new issue, ensure that there is no similar open issue.
Anyone manually testing the code and reporting bugs or suggestions for enhancements in the Issue Tracker are very welcome!
Patches/fixes are accepted in form of pull requests (PRs). Make sure the issue the pull request addresses is open in the Issue Tracker.
Submitted pull request is deemed to have agreed to publish under MIT License.
Pyxel is under MIT License. It can be reused within proprietary software, provided that all copies of the software or its substantial portions include a copy of the terms of the MIT License and also a copyright notice.
Pyxel is looking for sponsors on GitHub Sponsors. Consider sponsoring Pyxel for continued maintenance and feature additions. Sponsors can consult about Pyxel as a benefit. Please see here for details.
pyxel's People
Forkers
ro9ueadmin tws0002 jeanaraujo atcraiger trendingtechnology neurosatan gridl weimingtom vesche hugo187 honsa bussiere mu-777 4kd mewbak smythp godzil zmarkley-reawire kod3r mohamed-rekiba tsetenl2 zpallin cflann mistylackie millerhooks arberx neuroradiology grayotter seconddog pagakarthik robroseknows morristech sabhiram goodweather0 cjkumaresh alipiqriii nanangarsyad hhy5277 anmol-gulati steffex amaruri kylebegovich bradparks lanqi0820 hzgcoding kunalyelne johnpalacios kustomzone wsf1990 queziafiladelfo ondama omgbbqhaxx elyvioley liyinglin-bruce-lee wangyu0817 tjwallas harigovindv10 barseghyanartur giddily keohaneindustries blackistheneworange kaushikyelne stjordanis gamwe6 herolf andreiprc vetoplayer tumdog gene9 efnine tonetheman silky yili1992 grandrandpa ttrkaya nan0pr0be1 kandastroge lizadesya iamtrask thegreenjedi scouly kancerezeroglu tmthyjames amazingskyline 578746954 dirmyfirst aokiyoi shaibachar cg-design anupamandroid bbarker vlada5 endsmart pixelfractal gaomingyao olachan malingyun660915 easyfmxu frostytear echozzy629pyxel's Issues
Latest glfw 3.2.1
I'm using Elementary OS, how can I force the latest glfw? Repos say 3.1.2 is latest which throws an error when using pyxel...
I'd rather not compile from source, is there an easier way? Very keen to start building games using this beautifully simple platform :)
[Feature Request] Always allow Pyxel to be used as a regular library.
Pyxel is awesome! Thank you.
The ability to use a real editor and shell is really helpful. Editing code at 240x136 resolution looks cute, but it's not much fun after a while.
Just having an implementation of the TIC-80 API in Python3 is really cool in its own right, and it works well as a regular library.
Can you please commit to always allowing Pyxel to be used as we can now, even if it does add its own IDE components (shell, text editor, sprite editor etc), like other fantasy consoles?
It would be nice to have the sandboxed environment that other consoles have, with a simple shell. The deep integration of the sprite, audio and tile map editors is also very nice. It's running everything at 240x136 that's the problem.
I found Pyxel because I was looking for a way to build modern microcomputers - physical machines that work like a fantasy console. Is Pyxel a good choice for this?
The hardware spec is simple, and boils down to this:
PLATFORM: A Raspberry Pi 3 Model B+.
STORAGE: Any 64GB UHS Micro SD card (or better).
DISPLAY: Any 1280x1024 monitor, running at 60Hz.
AUDIO: Any amplified stereo loudspeakers.
KEYBOARD: Any ANSI mechanical keyboard.
MOUSE: Any good quality five-button mouse.
PAD: Any 8bitdo Pro pad (any generation).
The hardware specs will never change. Even though every console will be a clone (as the official console is a fantasy), the community is still based on the console that each member owns.
The 1280x1024 display would allow for six (pixel perfect) fullscreen resolutions:
NAME | WIDTH | HEIGHT | SCALE |
---|---|---|---|
maximum | 1280 | 1024 | 1 |
high | 640 | 512 | 2 |
medium | 320 | 256 | 4 |
low | 160 | 128 | 8 |
minimum | 80 | 64 | 16 |
It seems fairly easy to replace the Pixel Desktop Environment (PixelOS is the new Raspbian) with a custom environment that just runs everything in full screen mode (a bit like ChromeOS).
The shell and various editors would run at the maximum resolution (1280x1024) in 24bit color. Games would run fullscreen (scaled up), obscuring everything else until they exit. Each game would use a mode.
Each mode would specify one of the five standard resolutions, a color palette and any other limitations (size of the sprite pool etc) that make sense for that mode (GB Mode, NES Mode, VCS Mode etc).
The software would be shipped as a custom Linux distribution that boots into the custom environment. The distro would bundle a ton of extra libraries, and a collection of open source assets.
Pyxel seems like a great library to build on, but it does not allow higher resolutions, larger palettes etc. If I added support for modes, would you accept a PR?
Sorry for such a long post. I'm very interested in this project, and wanted to introduce myself, so people know why I'm here. Thanks again for Pyxel. It's a really cool project.
What does : "The specifications ... of Pyxel are referring to ..PICO-8 and TIC-80." mean?
Does this mean it's api compatible with PICO-8? Or TIC-80?
If not, why not, and if so, please state it plainly!
I'm new to this bit, and am trying to build games using a cross platform api that's simple, well supported, and has lots of examples.
Between PICO-8 and it's port to LOVE,
https://github.com/picolove/picolove
I wonder what this brings to the table, with the direct comparison in your readme?
Thanks so much - not meaning this to sound negative in anyway, I'd just like to know!
Much appreciated ;-)
Brad
glfw.GLFWError: (65544) b'Cocoa: Failed to retrieve display name'
I find the same error
glfw/glfw#958
Games do not render correctly beyond 256x256 resolution.
If you pass a width or height to pyxel.init
that is above 256, the rendering is broken. The background color does not fill the screen properly (there is a black margin around the top and sides).
Above 256x256, the pyxel.cls
command does not work correctly either. Things just blit over each other, so you can still see artifacts from previous frames.
At Line 40 in constants.py
, two constants are defined:
RENDERER_IMAGE_WIDTH = 256
RENDERER_IMAGE_HEIGHT = 256
That code is presumably why everything works up to 256 pixels, and immediately breaks beyond that.
I'm still figuring out how the code works, so don't know how to fix this yet.
Empty assets directory after install_pyxel_examples
Downloaded the examples using install_pyxel_examples command, the python files are there, but assets dir is empty, so you need to download them from github.
Traceback (most recent call last):
File "02_jump_game.py", line 159, in <module>
App()
File "02_jump_game.py", line 9, in __init__
pyxel.image(0).load(0, 0, 'assets/jump_game_160x120.png')
File "C:\Users\golebiewski\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyxel\image.py", line 46, in load
pil_image = PIL.Image.open(filename).convert('RGB')
File "C:\Users\golebiewski\AppData\Local\Programs\Python\Python36-32\lib\site-packages\PIL\Image.py", line 2580, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'assets/jump_game_160x120.png'
3D library now available for pyxel
This is not a bug report!
Just a quick note to tell you that I've ported @josefnpat 3D library for PICO-8 to Pyxel.
pycocam is now available at https://github.com/marespiaut/pycocam under the public domain.
Best regards!
`SEGFAULT` when running `04_sound_api.py` or `05_color_palette.py`
Hello,
My setup is:
- Arch Linux
- Python 3.6.6
- Pyxel 0.7.6
When launching the 04_sound_api.py
or 05_color_palette.py
examples, I get a segmentation fault a few seconds after.
Is there a way to properly backtrack segfaulting code in Python?
Add functions `tri()` and `trib()` for drawing triangles.
Hello,
As the title says, I would like to request the implementation of the functions tri()
and trib()
for drawing triangles on screen.
pyxel.cls(0) is not clearing the screen properly for some resolutions
Some pixels do not get overwriten(/overdrawn) on some resolutions.
import pyxel
class MyGame:
def __init__(self):
pyxel.init(100,100)
self.x = 0
pyxel.run(self.update, self.draw)
def update(self):
self.x = (self.x + 1) % pyxel.width
def draw(self):
pyxel.cls(0)
pyxel.rect(self.x,0,self.x+7,7,9)
MyGame()
this code leads to this result:
but if I change the pyxel.init() to
pyxel.init(100,101)
This code shows how the bottom and right border aren't drawn properly
import pyxel
class MyGame:
def __init__(self):
pyxel.init(100,100)
self.x = 0
pyxel.run(self.update, self.draw)
def update(self):
self.x = (self.x + 1) % pyxel.width
def draw(self):
pyxel.cls(13)
pyxel.rect(self.x,0,self.x+7,7,9)
MyGame()
- Win10,
- Python 3.6.2
- pyxel 0.7.4
Error "AttributeError: module 'glfw' has no attribute 'set_window_size_limits" on startup
I've tried to start application but got an error : "AttributeError: module 'glfw' has no attribute 'set_window_size_limits"
all details I added to gist:
https://gist.github.com/kamyanskiy/2f2eac45656ae1575c59422841c242bf
Fullscreen mode on Macbook pro
Hi!
I'm loving this library and am planning to use it for a ludum dare this weekend, I found that fullscreen mode doesn't seem to work on my macbook pro though - when I press the shortcut to go fullscreen
I do get a fullscreen window, but whatever is currently drawn on the screen gets a bit distorted and then disappears, leaving just a black screen.
Is this is a known issue or something new? Where in the code could I look at debugging this?
Debian 9 fail on run any example
Traceback (most recent call last): File "/home/user/Downloads/python/exemplo.py", line 3, in <module> pyxel.init(160, 120) File "/home/user/.local/lib/python3.5/site-packages/pyxel/__init__.py", line 27, in init border_width, border_color) File "/home/user/.local/lib/python3.5/site-packages/pyxel/app.py", line 79, in __init__ self._renderer = Renderer(width, height) File "/home/user/.local/lib/python3.5/site-packages/pyxel/renderer.py", line 28, in __init__ DRAWING_FRAGMENT_SHADER) File "/home/user/.local/lib/python3.5/site-packages/pyxel/glwrapper.py", line 12, in __init__ shaders.compileShader(fragment_shader, gl.GL_FRAGMENT_SHADER)) File "/home/user/.local/lib/python3.5/site-packages/OpenGL/GL/shaders.py", line 196, in compileProgram program.check_validate() File "/home/user/.local/lib/python3.5/site-packages/OpenGL/GL/shaders.py", line 108, in check_validate glGetProgramInfoLog( self ), RuntimeError: Validation failure (0):
I'm try with Python 3.5.3 and Python 3.5.5 |Anaconda, Inc. (By anaconda install)
Pyxel install doesn't work on macbook
Can someone help me resolve this issue?
I followed the install instructions for mac but am unable to locate module pyxel.
If I write pyxel
the editor opens in a new window "Hello, Pyxel Editor!"
this:pyxel_examples dev$ python3 01_hello_pyxel.py
Traceback (most recent call last):
File "01_hello_pyxel.py", line 1, in <module>
import pyxel
ModuleNotFoundError: No module named 'pyxel'
Rendering issues in the pyxel window
Any shape seems to fail to render correctly. Even the basic program:
import pyxel
pyxel.init(50, 50)
def update():
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
def draw():
pyxel.cls(0)
pyxel.run(update, draw)
I would expect just a black screen but instead I see:
This seems to happen for any shape. For example if I add a circle to the mix:
Example 3 renders as follows:
OS: Linux Fedora 27
Hardware: NVIDIA Corporation GT218 [GeForce 210] (rev a2)
Pyxel Version: 0.7.7 (but running master version from git at time of writing)
Python: 3.6.6.
During the pyxel.init argument border_color is not working.
While trying to add some border to screen, there is no change with adding border_color
argument.
Border is always black.
No matter if there is custom palette added or default.
pyxel.btnp() intended use
I see that calling this method will always immediately returns True for that frame. But if I'm specifying hold, shouldn't it wait first for that amount of frame? On top of that it seems that it doesn't even wait for entire duration of hold value.
Can somebody clarify on this?
I am using like this:
if pyxel.btnp(pyxel.constants.KEY_LEFT, 60, 30):move_direction = constants.direction_L
Keys does not honor keyboard layout
Hi,
The « KEY_ » constants does not honor keyboard layout. On my french keyboard, KEY_Q is True when I press the A key, KEY_Z is True for the W key, etc.
\fab
"RuntimeError: Validation failure (0)" trying to run examples on Debian Stretch
Running on Debian 9 (Stretch) with Python 3.6.
andy@broken-screen:~/pyxel_examples$ python3.6 02_jump_game.py
Traceback (most recent call last):
File "02_jump_game.py", line 168, in
App()
File "02_jump_game.py", line 8, in init
pyxel.init(160, 120, caption='Pyxel Jump Game')
File "/home/andy/miniconda3/lib/python3.6/site-packages/pyxel/init.py", line 27, in init
border_width, border_color)
File "/home/andy/miniconda3/lib/python3.6/site-packages/pyxel/app.py", line 79, in init
self._renderer = Renderer(width, height)
File "/home/andy/miniconda3/lib/python3.6/site-packages/pyxel/renderer.py", line 28, in init
DRAWING_FRAGMENT_SHADER)
File "/home/andy/miniconda3/lib/python3.6/site-packages/pyxel/glwrapper.py", line 12, in init
shaders.compileShader(fragment_shader, gl.GL_FRAGMENT_SHADER))
File "/home/andy/miniconda3/lib/python3.6/site-packages/OpenGL/GL/shaders.py", line 196, in compileProgram
program.check_validate()
File "/home/andy/miniconda3/lib/python3.6/site-packages/OpenGL/GL/shaders.py", line 108, in check_validate
glGetProgramInfoLog( self ),
RuntimeError: Validation failure (0):
andy@broken-screen:~/pyxel_examples$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Possibility: add mypy.ini typings and bump to python version 3.6+
Hello,
I'd like to become more familiar with the pyxel code, and I love the new python typings. Would be happy to work on adding these if desirable.
Rendered elements disappear near screen edges
As far as I can tell, both shapes and images that exist at the edges of the screen are not rendered past a certain point. I've included an example below:
As you can see, rendered elements pop out at the right and left edges as the screen scrolls. It seems to be when they're more than 50% off screen. Is this intentional or is it something that could be updated to allow smoother screen transitions. A link to the project in the image above is here: https://github.com/paulsheridan/pyxel-projects/tree/master/side_scroller
OS: macOS 10.13.5
Hardware: AMD Radeon R9 M370X
Pyxel Version: 0.7.7
Python: 3.6.5
Packaging a pyxel game
Hi again,
I hope this is an acceptable place for a question like this, without a Pyxel related forum, it's the only place I know to ask other Pyxel devs:
Is there a reliable means of packaging a pyxel game for distribution/sharing with people who may not have python environments already set up?
I'd like to share my work but have had nothing but trouble with pyinstaller and py2app. It seems that glfw's use of subprocess causes the issue. I'm happy to elaborate further, but mostly I'm curious if anyone has successfully created a sharable build.
Crash if no audio system found
I know that I'm in a weird environment where my pc actually have an audio card (on the mainboard) but I don't have the drivers (and don't want them as it is a work PC and audio is not something I need here)
So when Pyxel try to find and get the audio card it "crash":
python3 pyxel_examples/01_hello_pyxel.py
Traceback (most recent call last):
File "pyxel_examples/01_hello_pyxel.py", line 20, in <module>
App()
File "pyxel_examples/01_hello_pyxel.py", line 6, in __init__
pyxel.init(160, 120, caption='Hello Pyxel')
File "/usr/local/lib/python3.6/dist-packages/pyxel/__init__.py", line 33, in init
border_width, border_color)
File "/usr/local/lib/python3.6/dist-packages/pyxel/app.py", line 87, in __init__
self._audio_player = AudioPlayer()
File "/usr/local/lib/python3.6/dist-packages/pyxel/audioplayer.py", line 143, in __init__
callback=self._output_stream_callback)
File "/usr/local/lib/python3.6/dist-packages/sounddevice.py", line 1373, in __init__
**_remove_self(locals()))
File "/usr/local/lib/python3.6/dist-packages/sounddevice.py", line 696, in __init__
extra_settings, samplerate)
File "/usr/local/lib/python3.6/dist-packages/sounddevice.py", line 2489, in _get_stream_parameters
info = query_devices(device)
File "/usr/local/lib/python3.6/dist-packages/sounddevice.py", line 487, in query_devices
raise PortAudioError('Error querying device {0}'.format(device))
sounddevice.PortAudioError: Error querying device -1
I think it should gracefully says that audio is not going to work because it can't find a valid sound card, but should not fail because of that.
Air hockey example created from pyxel!
Great library! I created an air hockey game as an example here
blt doesn't work under certain circumstances
The following code fails to blt
properly. Instead of blt
-ing the bitmap set
in Game.__init__
, it blt
's all black pixels.
Oddly enough, the following things all correct this error:
- Setting
App.mode
toGame()
instead ofMenu()
from the beginning - Replacing body of
Menu.draw
withpass
- Adding any reference to
pyxel.image(0).data
toGame.init
import pyxel
class Game:
def __init__(self):
pyxel.image(0).set(
0, 0,
[
'0123',
'4567',
'89ab',
'cdef'
]
)
def update(self):
pass
def draw(self):
pyxel.cls(12)
pyxel.blt(
0, 0,
0,
0, 0,
4, 4,
)
class Menu:
def __init__(self, app):
self.app = app
def update(self):
if pyxel.btnp(pyxel.KEY_ENTER):
self.app.mode = Game()
def draw(self):
pyxel.cls(5)
pass
class App:
def __init__(self):
pyxel.init(16, 16)
self.mode = Menu(self)
pyxel.run(self.update, self.draw)
def update(self):
self.mode.update()
def draw(self):
self.mode.draw()
App()
Add "How To Contribute" Section in the README.md
I like the documentation so far. Clear and concise. I'd suggest to add a "How to Contribute" section next.
RuntimeError: glfw version is lower than 3.2.1
my Python Version is 3.6.4,i use pip install glfw,but the glfw version is 3.1.2
In [5]: import glfw
In [6]: glfw.get_version_string()
Out[6]: b'3.1.2 X11 GLX clock_gettime /dev/js XI Xf86vm shared'
So, glfw's version can't fix the pyxel's.
[Feature Request] Use custom bitmap fonts.
I'm looking at the example files and I'm having trouble understanding exactly how the built-in font works. Is it currently possible to use custom bitmap fonts?
Add gamepad support?
not pixel perfect
More audio effects?
The AudioPlayer in pyxel is very nice (would be nice if it was also it's own submodule that could be installed without the need of pyxel, but that's a really pointless suggestion).
I really don't know much about audio and such, so, would it be possible to add the audio effects found in something like pico-8?
from https://www.lexaloffle.com/pico-8.php?page=manual:
:: Effects
0 none
1 slide // Slide to the next note and volume
2 vibrato // Rapidly vary the pitch within one quarter-tone
3 drop // Rapidly drop the frequency to very low values
4 fade in // Ramp the volume up from 0
5 fade out // Ramp the volume down to 0
6 arpeggio fast // Iterate over groups of 4 notes at speed of 4
7 arpeggio slow // Iterate over groups of 4 notes at speed of 8
If the SFX speed is <= 8, arpeggio speeds are halved to 2, 4```
Example 6 doesn't clear whole screen
On my new Windows environment, some pixels remain on the top and left side of the window when I run the example 6.
On Mac, the example #6 works well.
Specify version of glfw needed.
I ran into this error AttributeError: module 'glfw' has no attribute 'set_window_size_limits'
after installing what I think is the latest glfw version by running apt-get install libglfw3
on Ubuntu since the glfw package from the README wasn't located. I wanted to check if the versions match but they aren't specified in the README. Could you please specify them/it?
Installation instructions for Debian do not work
Not sure about the causes, but following the installation instructions for Debian do not lead to a working installation.
The glfw Python module is not able to find the library that is installed via apt. Failing with "failed to load glfw3 shared library".
Compiling and installing the GLFW library from source solves this.
Of course this is a bug in the glfw wrapper and not in pyxel, but it leads to instructions that do not work.
Documentation
Good work! Love this project already :)
I notice that you have the docs on the readme only, I think you can use sphinx, that way you can put docstrings in your python files and then put all together with sphinx. Then host the docs on read the docs, you can host translations too! Let me know if you want this, I can help with sphinx and read the docs.
API for dynamically changing game speed
Use case – a game that gradually gets faster as the difficulty ramps up.
I achieved this by modifying pyxel._app _one_frame_time and pyxel._app._fps, but it would be great if there was a more official way to do this.
Make wiki editable
Hi!
Just made another game (pong clone) which I'm keen to put up to the wiki – although there is an invitation to edit, it doesn't look like it's editable.
Could you update this if this is unintentional? It looks like this is how you do it.
Pyxel's text(x, y, string, color) function silently fails to print text to the screen.
On my Debian buster machine I added a single call to Pyxel's text() function to the introductory example code in the README:
import pyxel
pyxel.init(160, 120)
def update():
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
def draw():
pyxel.cls(0)
pyxel.rect(10, 10, 20, 20, 11)
pyxel.text(10, 10, "This is a sentence.", 11)
pyxel.run(update, draw)
and ran it, resulting in the following screenshot, which has the specified rectangle but the text is nowhere to be found:
All apt packages installed successfully as required in the README:
Reading package lists...
Building dependency tree...
Reading state information...
libasound2-dev is already the newest version (1.1.6-1).
libglfw3 is already the newest version (3.2.1-1).
libportaudio2 is already the newest version (19.6.0-1).
python3-pip is already the newest version (9.0.1-2.3).
python3 is already the newest version (3.6.6-1).
0 upgraded, 0 newly installed, 0 to remove and 908 not upgraded.
and pip3 also had no errors installing required packages:
Collecting pyxel
Using cached https://files.pythonhosted.org/packages/3d/2f/25879681cf00bc1d607322b4c59a3cfd768fa9b092910fde72194332ed34/pyxel-0.7.4-py3-none-any.whl
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from pyxel)
Collecting PyOpenGL (from pyxel)
Collecting sounddevice (from pyxel)
Using cached https://files.pythonhosted.org/packages/fb/5d/0e6cf5ce99b99e76a24b573b94f9009d9d2f5cd13a73825d7e681c9a7a96/sounddevice-0.3.11-py2.py3-none-any.whl
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (from pyxel)
Collecting glfw (from pyxel)
Collecting CFFI>=1.0 (from sounddevice->pyxel)
Using cached https://files.pythonhosted.org/packages/6d/c0/47db8f624f3e4e2f3f27be03a93379d1ba16a1450a7b1aacfa0366e2c0dd/cffi-1.11.5-cp36-cp36m-manylinux1_x86_64.whl
Collecting pycparser (from CFFI>=1.0->sounddevice->pyxel)
Installing collected packages: PyOpenGL, pycparser, CFFI, sounddevice, glfw, pyxel
Successfully installed CFFI-1.11.5 PyOpenGL-3.1.0 glfw-1.7.0 pycparser-2.18 pyxel-0.7.4 sounddevice-0.3.11
OS info is as follows:
PRETTY_NAME="Debian GNU/Linux buster/sid"
NAME="Debian GNU/Linux"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
I gave the text() function a look in the codebase but nothing stuck out at me as a potential issue, and no errors are printed to stdout/stderr when I run the above program.
Snake game – example?
Hello!
Thanks for the great library! I've created a simple snake implementation using it – happy for you to use as another example if you like (but all good if not).
The size of the captured gif animation is too large than expected
The size of the gif animation created by Pillow is too large. I wonder there's some way to compress the size of it.
Some elements are drawn partially
Shader error when trying to run any of the examples
Full error message:
Traceback (most recent call last):
File "I:\WinPython-64bit-3.6.2.0Qt5\scripts\pyxel_examples\01_hello_pyxel.py", line 20, in <module>
App()
File "I:\WinPython-64bit-3.6.2.0Qt5\scripts\pyxel_examples\01_hello_pyxel.py", line 6, in __init__
pyxel.init(160, 120, caption='Hello Pyxel')
File "I:\WinPython-64bit-3.6.2.0Qt5\python-3.6.2.amd64\lib\site-packages\pyxel\__init__.py", line 33, in init
border_width, border_color)
File "I:\WinPython-64bit-3.6.2.0Qt5\python-3.6.2.amd64\lib\site-packages\pyxel\app.py", line 83, in __init__
self._renderer = Renderer(width, height)
File "I:\WinPython-64bit-3.6.2.0Qt5\python-3.6.2.amd64\lib\site-packages\pyxel\renderer.py", line 38, in __init__
DRAWING_FRAGMENT_SHADER)
File "I:\WinPython-64bit-3.6.2.0Qt5\python-3.6.2.amd64\lib\site-packages\pyxel\glwrapper.py", line 10, in __init__
shaders.compileShader(vertex_shader, gl.GL_VERTEX_SHADER),
File "I:\WinPython-64bit-3.6.2.0Qt5\python-3.6.2.amd64\lib\site-packages\OpenGL\GL\shaders.py", line 236, in compileShader
shaderType,
RuntimeError: ('Shader compile failure (0): b"ERROR: 0:162: \'undefined\' : undeclared identifier \\nERROR: 0:162: \';\' : syntax error parse error\\n"', [b'\n#version 120\n\n#define unpack_4ui_1(x) int(mod(x / 0x1, 0x10));\n#define unpack_4ui_2(x) int(mod(x / 0x10, 0x10));\n#define unpack_4ui_3(x) int(mod(x / 0x100, 0x10));\n#define unpack_4ui_4(x) int(mod(x / 0x1000, 0x10));\n\nconst int TYPE_PIX = 0;\nconst int TYPE_LINE = 1;\nconst int TYPE_RECT = 2;\nconst int TYPE_RECTB = 3;\nconst int TYPE_CIRC = 4;\nconst int TYPE_CIRCB = 5;\nconst int TYPE_BLT = 6;\nconst int TYPE_TEXT = 7;\n\nuniform vec2 u_framebuffer_size;\n\nattribute vec3 a_mode;\nattribute vec4 a_pos;\nattribute vec2 a_size;\nattribute vec4 a_clip;\nattribute vec4 a_pal;\n\nvarying float v_type;\nvarying float v_col;\nvarying float v_image;\nvarying vec2 v_pos1;\nvarying vec2 v_pos2;\nvarying vec2 v_min_pos;\nvarying vec2 v_max_pos;\nvarying vec2 v_size;\nvarying vec2 v_min_clip;\nvarying vec2 v_max_clip;\nvarying float v_pal[16];\n\nvec4 pixelToScreen(vec2 pos)\n{\n return vec4(pos * 2.0 / u_framebuffer_size - 1.0, 0.0, 1.0);\n}\n\nvoid pix()\n{\n vec2 p = floor(a_pos.xy + 0.5);\n\n v_min_pos = v_max_pos = p;\n\n gl_PointSize = 1.0;\n gl_Position = pixelToScreen(p);\n}\n\nvoid line()\n{\n vec2 p1 = floor(a_pos.xy + 0.5);\n vec2 p2 = floor(a_pos.zw + 0.5);\n\n v_min_pos = min(p1, p2);\n v_max_pos = max(p1, p2);\n\n vec2 d = v_max_pos - v_min_pos;\n\n if (d.x > d.y)\n {\n if (p1.x < p2.x) {\n v_pos1 = p1;\n v_pos2 = p2;\n }\n else\n {\n v_pos1 = p2;\n v_pos2 = p1;\n }\n }\n else\n {\n if (p1.y < p2.y)\n {\n v_pos1 = p1;\n v_pos2 = p2;\n }\n else\n {\n v_pos1 = p2;\n v_pos2 = p1;\n }\n }\n\n gl_PointSize = max(d.x, d.y) + 1.0;\n gl_Position = pixelToScreen(v_min_pos + (gl_PointSize - 1.0) * 0.5);\n}\n\nvoid rect_rectb()\n{\n vec2 p1 = floor(a_pos.xy + 0.5);\n vec2 p2 = floor(a_pos.zw + 0.5);\n\n v_min_pos = min(p1, p2);\n v_max_pos = max(p1, p2);\n\n vec2 s = v_max_pos - v_min_pos + 1.0;\n\n gl_PointSize = max(s.x, s.y);\n gl_Position = pixelToScreen(v_min_pos + (gl_PointSize - 1.0) * 0.5);\n}\n\nvoid circ_circb()\n{\n vec2 p = floor(a_pos.xy + 0.5);\n float r = floor(a_size.x + 0.5);\n\n v_pos1 = p;\n v_min_pos = p - r;\n v_max_pos = p + r;\n v_size.x = r;\n\n gl_PointSize = r * 2.0 + 1.0;\n gl_Position = pixelToScreen(p);\n}\n\nvoid blt()\n{\n vec2 p1 = floor(a_pos.xy + 0.5);\n vec2 p2 = floor(a_pos.zw + 0.5);\n vec2 s = floor(a_size + 0.5);\n vec2 abs_s = abs(s);\n\n v_pos1 = p1;\n v_pos2 = p2;\n v_min_pos = p1;\n v_max_pos = p1 + abs_s - 1.0;\n v_size = s;\n\n gl_PointSize = max(abs_s.x, abs_s.y);\n gl_Position = pixelToScreen(v_min_pos + (gl_PointSize - 1.0) * 0.5);\n}\n\nvoid text()\n{\n v_image = 5 - 1;\n vec2 p1 = floor(a_pos.xy + 0.5);\n vec2 p2 = vec2(mod(a_pos.z, 64) * 4, floor(a_pos.z / 64) * 6);\n vec2 s = vec2(4, 6);\n vec2 abs_s = abs(s);\n\n v_pos1 = p1;\n v_pos2 = p2;\n v_min_pos = p1;\n v_max_pos = p1 + abs_s - 1.0;\n v_size = s;\n\n gl_PointSize = max(abs_s.x, abs_s.y);\n gl_Position = pixelToScreen(v_min_pos + (gl_PointSize - 1.0) * 0.5);\n}\n\nvoid main()\n{\n v_type = a_mode.x;\n v_col = a_mode.y;\n v_image = a_mode.z;\n\n v_pal[0] = unpack_4ui_1(a_pal.x);\n v_pal[1] = unpack_4ui_2(a_pal.x);\n v_pal[2] = unpack_4ui_3(a_pal.x);\n v_pal[3] = unpack_4ui_4(a_pal.x);\n v_pal[4] = unpack_4ui_1(a_pal.y);\n v_pal[5] = unpack_4ui_2(a_pal.y);\n v_pal[6] = unpack_4ui_3(a_pal.y);\n v_pal[7] = unpack_4ui_4(a_pal.y);\n v_pal[8] = unpack_4ui_1(a_pal.z);\n v_pal[9] = unpack_4ui_2(a_pal.z);\n v_pal[10] = unpack_4ui_3(a_pal.z);\n v_pal[11] = unpack_4ui_4(a_pal.z);\n v_pal[12] = unpack_4ui_1(a_pal.w);\n v_pal[13] = unpack_4ui_2(a_pal.w);\n v_pal[14] = unpack_4ui_3(a_pal.w);\n v_pal[15] = unpack_4ui_4(a_pal.w);\n\n if (v_type == TYPE_PIX) { pix(); }\n else if (v_type == TYPE_LINE) { line(); }\n else if (v_type == TYPE_RECT || v_type == TYPE_RECTB) { rect_rectb(); }\n else if (v_type == TYPE_CIRC || v_type == TYPE_CIRCB) { circ_circb(); }\n else if (v_type == TYPE_BLT) { blt(); }\n else if (v_type == TYPE_TEXT) { text(); }\n else { gl_Position = vec4(0.0, 0.0, 0.0, 1.0); }\n\n vec2 p1 = floor(a_clip.xy + 0.5);\n vec2 p2 = floor(a_clip.zw + 0.5);\n\n v_min_clip = max(min(p1, p2), v_min_pos);\n v_max_clip = min(max(p1, p2), v_max_pos);\n}\n'], GL_VERTEX_SHADER)
Do you have a solution for that problem?
tetris-clone example
Hi. First of all thanks for making such an awesome framework. I've made a minimal tetris clone using pyxel. Didn't know the right place to post this hence raising an issue.
Find the way to improve the performance
For now, there are two bottle necks in Pyxel.
One is the assigning NumPy array with indices to set the parameters to the drawing command array in drawcommand.py.
The other is realtime sound synthesis in oscillator.py.
I tried to use Numba to those classes with type information, but it didn't perform well.
Does anyone know what I should try next?
Add key definition that integrates left and right
Add KEY_SHIFT, KEY_CONTROL, KEY_ALT and KEY_SUPER which reflects both left and right key states.
owwwwwww,i like it
If you have a font size, it's great.
Got b'X11: RandR gamma ramp support seems broken'
Hi
I am trying to run pyxel on a arm-based GameConsole called GameShell, GPU is Mali 450
got these errors when try to run 01_hello_pyxel.py
Traceback (most recent call last):
File "01_hello_pyxel.py", line 20, in <module>
App()
File "01_hello_pyxel.py", line 6, in __init__
pyxel.init(160, 120, caption='Hello Pyxel')
File "/home/cpi/.local/lib/python3.5/site-packages/pyxel/__init__.py", line 33, in init
border_width, border_color)
File "/home/cpi/.local/lib/python3.5/site-packages/pyxel/app.py", line 57, in __init__
if not glfw.init():
File "/home/cpi/.local/lib/python3.5/site-packages/glfw/__init__.py", line 606, in init
res = _glfw.glfwInit()
File "/home/cpi/.local/lib/python3.5/site-packages/glfw/__init__.py", line 515, in errcheck
_reraise(exc[1], exc[2])
File "/home/cpi/.local/lib/python3.5/site-packages/glfw/__init__.py", line 45, in _reraise
raise exception.with_traceback(traceback)
File "/home/cpi/.local/lib/python3.5/site-packages/glfw/__init__.py", line 494, in callback_wrapper
return func(*args, **kwargs)
File "/home/cpi/.local/lib/python3.5/site-packages/glfw/__init__.py", line 668, in _raise_glfw_errors_as_exceptions
raise GLFWError(message)
glfw.GLFWError: (65544) b'X11: RandR gamma ramp support seems broken'
OS env:
python3.5
Linux clockworkpi 4.14.2-clockworkpi-cpi3 #1 SMP Sat Jul 14 09:34:56 CST 2018 armv7l GNU/Linux
libglfw3 (3.2.1-1).
here is the
glxinfo | grep Open
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: Gallium 0.4 on llvmpipe (LLVM 3.9, 128 bits)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 13.0.6
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 13.0.6
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 13.0.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:
the full version of glxinfo is here
Do you know why I can not run pyxel successfully ,
why I get the error X11: RandR gamma ramp support seems broken' ?
Thanks
Discussion? Argument border_with is not scaled.
If I want scale Pyxel window, and add an border to it, border has always value in pixels while rest of the screen is pixels*scale.
app.py lines 61 and 62:
window_width = width * scale + border_width
window_height = height * scale + border_width
Shouldn't be border scaled together with "work area"? I mean for me it's a little not natural if part of screen is scaled and part of it's not.
Shouldn't be fixed with:
window_width = (width + border_width) * scale
window_height = (height + border_width) * scale
?
Segfault when calling `init()`
Hello,
Your library seems really neat! Unfortunately, I've been unable to use it, because I get a segfault as soon as I run the pyxel.init()
function. Here's the minimal code that produces the segfault:
import pyxel
pyxel.init(160, 120)
and here's the error message I get from my shell:
[1] 25268 segmentation fault (core dumped) python pyxel_test.py
I am on Manjaro (i.e. Arch). I have python 3.6.6 with conda, glfw-x11 version 3.2.1-1, and python-glfw version 1.7.0-1, as well as python-pyxel version 0.7.3-4 from the AUR. I don't know what else to tell you.
Thanks in advance!
Taking screenshot or recording crashes the game
My Ubuntu is in Portuguese and when I try to take a screenshot or record a gif, the game crashes trying to create a file:
File "/home/jean/Documentos/pyxel-debug/lib/python3.6/site-packages/PIL/Image.py", line 1947, in save fp = builtins.open(filename, "w+b") FileNotFoundError: [Errno 2] No such file or directory: '/home/jean/Desktop/pyxel-180731-095749.gif'
If I create a Desktop folder on my home directory the problem is solved, but I don't that's a good solution.
An alternative would be creating a subfolder inside the game's current directory. I would do a pull request, but even that being pretty simple, I think that's more like a design decision, so it's up to you
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.