kitao / pyxel Goto Github PK
View Code? Open in Web Editor NEWA retro game engine for Python
License: MIT License
A retro game engine for Python
License: MIT License
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
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'
Hello,
My setup is:
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?
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.
Hello,
As the title says, I would like to request the implementation of the functions tri()
and trib()
for drawing triangles on screen.
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.
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.
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
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
The size of the gif animation created by Pillow is too large. I wonder there's some way to compress the size of it.
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.
If you have a font size, it's great.
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
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.
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.
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.
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.
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 :)
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!
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.
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/"
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)
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.
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
?
I like the documentation so far. Clear and concise. I'd suggest to add a "How to Contribute" section next.
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!
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'
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).
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.
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.
I find the same error
glfw/glfw#958
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```
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
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.
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?
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?
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.
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
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?
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()
Great library! I created an air hockey game as an example here
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?
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
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:
App.mode
to Game()
instead of Menu()
from the beginningMenu.draw
with pass
pyxel.image(0).data
to Game.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()
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?
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.
Add KEY_SHIFT, KEY_CONTROL, KEY_ALT and KEY_SUPER which reflects both left and right key states.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.