
Pyxel: A retro game development environment in Python - autocorr
https://github.com/kitao/pyxel
======
aquova
Since it seems that many people here are unaware, so let me introduce Pico-8,
the "Fantasy Video Game console" that is referenced in Pyxel's README as an
inspiration:
[https://www.lexaloffle.com/pico-8.php](https://www.lexaloffle.com/pico-8.php)

Pico-8 is (AFAIK) the program that kicked off a trend of simple game engines,
and it is by far the most popular. A popular game that came out this year,
Celeste, was originally a Pico-8 game that proved popular enough to remake in
a more modern game engine. Pico-8 supports a Lua API, with a built-in graphics
editor for 8x8 sprites, and a 4-channel audio editor. Games can be exported as
a PC/Mac/Linux binary, into HTML+JS for embedding into a webpage, and even as
a PNG for easy sharing to other users with the Pico-8 program. There's also a
very active BBS where 'cartridges' can be shared and played online:
[https://www.lexaloffle.com/bbs/?cat=7#mode=carts](https://www.lexaloffle.com/bbs/?cat=7#mode=carts)

I'm a relatively novice programmer, and one of the things that frustrated me
was how difficult it was to make a simple game on modern machines. I didn't
want to have to set up a whole Unity project or dive into OpenGL just for a
little proof of concept. I've been heavily using Pico-8 and really recommend
it for simple game programming. There's also a hashtag on Twitter (if you're
into that sort of thing), #pico8, where people try to create interesting
visual code golf programs that fit into the size of a Tweet, then they post
the source code and a gif.

~~~
NortySpock
Building on your reply, I have found that Processing (Java) and P5
(JavaScript) have a similar easy-to-use design and the documentation is
decent. (It's not opinionated on the color palette though.)

I've been using P5 to write retro video games to learn JavaScript, and it's
been a lot of fun using that to learn JS. (Vanilla JS sucks, but the learning
process is at least fun).

[https://processing.org](https://processing.org)

[https://p5js.org](https://p5js.org)

~~~
satsuma
oh man, processing. i did a weeklong video game programming "camp" back when i
was in middle school and processing was the language we used. definitely easy
to pick up and use.

~~~
iamcreasy
Could you please elaborate on why Processing is easier to use over OpenGL
wrapper like LWJGL? You still have to write OpenGL shaders to get the desired
visual, right?

~~~
kowdermeister
It's just simple function calls, minimal boilerplate and simple API.

You can write shaders (not mandatory since it supports 3D without them) but
loading them is simple as using ShaderToy.

[https://processing.org/tutorials/pshader/](https://processing.org/tutorials/pshader/)

------
TuringTest
Cool for learning to program games.

Development environments in the 80's and 90's were so simple that you had to
program down to every pixel shown on the screen (well, maybe calling some
_line_ and _sprite_ primitives for speed), so you only needed to learn a small
mental model for programming, and everything above it was designed by you.
Also, the primitive hardware and no expectations of portability meant that you
only had to care about one or two combinations of platforms (maybe supporting
a small range of graphics and sound cards).

This can help teach younger developers to understand the basic principles, and
get a glimpse of how things are done below the surface of those modern do-it-
all gaming engines.

~~~
Drakim
Actually, programming homebrew for the NES and SNES, I was surprised by how
similar my experience was to learning OpenGL. You can't plot individual pixels
on hardware like that, you have to fill CHR memory (like textures) and create
arrays of sprite data (like triangles) to upload to the hardware accelerated
unit of the console.

While it's totally true that you had to be very "close to the metal" in
everything you do, I feel it's not that dissimilar from coding C and OpenGL
today, in terms of the overall flow of your project.

~~~
beagle3
NES and SNES were not your general "development system of the 80s"; I'm quite
sure GP was referring to the Apple, Oric, Acorn, BBC, Dragon, MSX, Tandy CoCo,
Spectrum, Amiga and even PCg/PCjr/XT of the time.

Commodore's C64, PET and VIC20 were exceptional in how hard they made using
graphics at the time from the included BASIC; But in general it was quite
easy.

The Atari VCS2600 had an even weirder video setup: It had one line of video
memory (a 1D canvas!), and it was up to the program to replace the contents of
that line while the screen raster was flying back to the next line. And a few
sprites to sweeten the deal.

------
djaychela
Having had a quick look through, I think I'm going to spend some time playing
around with this... I think that simple game engines are really important to
getting young people into programming.

I have two step-sons (11 and 17), both of who are into gaming, but the elder
one showed a bit of interest in programming when he was 11-12, but the problem
(I think) is that the games they are playing are light-years away from
anything they can even hope to program - and if they see what's involved in
programming a FPS, they are (understandably!) crestfallen and look elsewhere.
However, something like this would give them a way in to program something
playable (and retro games are cool as far as they're concerned), but do some
genuine learning AND see that there may be a path forward for them to produce
something worthwhile.

When I was their age, games like Manic Miner seemed possible. I'm not in any
way saying I had the skill of Matthew Smith (and still don't, I'm learning
myself for a career change), but it didn't seem like impossible future alien
technology, whereas today's games are - they take thousands of man years to
create, and are made by incredibly skilled people.

~~~
jcelerier
> I have two step-sons (11 and 17), both of who are into gaming, but the elder
> one showed a bit of interest in programming when he was 11-12, but the
> problem (I think) is that the games they are playing are light-years away
> from anything they can even hope to program

Well, that would be like going to the cinema for Marvel movies and then
refusing to do amateur films because you think that you would not be able to
make Marvel movies on your own.

~~~
fredoliveira
Sure, that's a good analogy, but what's the point? He's still right.

When you are a kid, it is hard to see the forest from the trees. To people
here, understanding the basics of game development in a limited environment as
a stepping stone to building larger games is probably obvious. But kids don't
really have that insight.

I think the solution is to provide that insight (and this should go for
parents and game engine developers): that this is foundational game design and
thinking. That everyone who's working in the industry today understands these
foundations. And maybe that retro is still pretty cool ;-)

------
adrianoconnor
This looks really nice. It's a shame the name is so similar to an existing app
though (Pyxel Edit, [https://pyxeledit.com/](https://pyxeledit.com/))

My favourite 2D framework right now is is LOVE (love2d.org) - I'm using that
to build stuff with/for my kids and it's just a joy to use. I'll probably
write up some parent/child friendly tutorials at some point. I also like
Monkey-2 ([http://monkeycoder.co.nz/](http://monkeycoder.co.nz/)), but I only
really use that when I want to do basic 3D stuff, because Love does the 2D
stuff so well...

~~~
empyrical
Also similar in name to "Pyxl", like React JSX for Python

[https://github.com/gvanrossum/pyxl3](https://github.com/gvanrossum/pyxl3)

~~~
benatkin
Those are all unmaintained projects. pyxl4/pyxl4 and Dropbox/pyxl haven't been
in a long time and pyxl4 says gvanrossum/pyxl3 is unmaintained and while
gvanrossum/pyxl3 was updated a month ago, it was just the README. The code
hasn't been updated in over two years.

------
wokwokwok
This is actually very nice.

I'd just like to point out as well, that unlike many other similar attempts it
is _is not_ based on pygame, and does not suffer from either the flakeyness
nor installation irritations that comes with.

Instead it implements a very minimal (dependency wise) custom layer on top of
glfw.

Many people will be skeptical of a python game engine, but I would recommend
this one over many others.

Limited in scope and very good at what it does.

~~~
megaman22
Is PyGame flaky these days? I haven't much played with it in quite some time;
it used to be pretty solid, although as I recall it wasn't much more than a
wrapper for SDL 1.2 at the time.

~~~
wokwokwok
It's never been really solid in my experience; it crashes when it fails and
its difficult to build due to the heavy use of cython.

See, for example how kivy has moved away from using it as a backend
[https://github.com/kivy/kivy/issues/5590](https://github.com/kivy/kivy/issues/5590)

~~~
bitcraft
Pygame is mostly C. Cython is not used.

------
w1nt3rmu4e
Awesome stuff. Just spent 20 minutes with my 4 year old tweaking settings in
the platformer example to see what the results would be. He loved it. Way more
fun (for him) than the other day when he asked what the modulo operator was.

It bums me out that the economics of indie games are so awful. The kid in me
wants, so badly, to make a gigantic, sprawling version of Zelda or a dungeon
crawler. But there's no way I can justify the time investment.

Still, seeing an API this simple is inspiring. Props to kitao.

~~~
monadgonad
> But there's no way I can justify the time investment.

It's fun. People build gigantic, sprawling model train sets in their attics
over the course of years, not to sell them or to have many people play with
them, but just for the fun of building something.

------
sehugg
The hardware Pyxel simulates seems closest to the Williams arcade games --
Defender, Robotron, Joust, etc.

These games had a single 256 x 304 pixel frame buffer, 4 bits per pixel (16
color palette). A hardware bit blitter performed fast block copy operations to
draw sprites, scrolling, etc.

There was a dedicated 8-bit CPU for sound which could play cool effects,
albeit one at a time -- Pyxel's sound generator is closer to the NES, better
for music and pure tones.

You can see a sample game written in C for the Williams hardware here:
[http://8bitworkshop.com/v2.1.1/?platform=williams-z80&file=g...](http://8bitworkshop.com/v2.1.1/?platform=williams-z80&file=game1.c)

------
akuji1993
This is acutally pretty cool. I'll take a look later and check your Jump + Run
example, seems to me like there's not as much code required as I thought. I'm
still intrigued by game development, just didn't really have the time to delve
deep into it the last few months. Really cool project!

~~~
ryan-allen
I thought the same things from the code examples. FYI other readers, to get to
the example click on the image in the README!

------
adrianN
What is the Python packaging story like today? The last time I tried to
distribute something that depended on platform specific libraries it was a
real pain to get a package that users could just download and run. Would it be
difficult to package a game written with this library in some form of
installer?

~~~
WaxProlix
FWIW, I've used both PyInstaller (bundles python and deps) and nuitka
(actually compiles code to C++) and been super happy with both, though my use
cases are generally simple (lots of networking generally but not much GUI
work).

I've had much worse experiences with py2exe and cx_freeze.

------
lifeisstillgood
I would love to get my kids using something like this - my next question is
they would love to share it - i will go with the "walk upstairs" sharing for
now but are there plans for some kind of ... i'm not sure, download and run
approach.

what would be needed - any thoughts?

~~~
potta_coffee
TBH I'd just try out Pico-8, which inspired this Python project. Pico-8 games
are super easy to share, you can share the png file or embed the game in a
webpage. I'm mainly a Python developer but I got started with Pico-8 about a
week ago and it's a blast. My 7 year old son loves it too.

------
lordxenu
Pretty cool, although most game engines/libraries lack a native gui system.
Does this provide some way of building retro guis, like for game menus or
settings? If not, will it in the future?

------
chrismaltby
This looks like a great project, reminds me a lot of development for GameBoy
using GBDK especially with clipping screen buffers for scrolling.

I ended up writing a rough JS implementation of GBDK and used Emscripten so I
could debug those kinds of things while making GameBoy roms.

[https://www.gbdkjs.com/docs/example-
projects/](https://www.gbdkjs.com/docs/example-projects/)

There's something about working within the limitations of retro systems that's
really fun.

------
tequila_shot
This is fantastic. I always loved retro arcade gaming, and I'm sad that there
are not a lot of games out there that interest me. So these days I came to a
conclusion that I have to build my own games.

Where can learn about general game physics? How are the games designed? How do
we make the games tough so as to make sure it doesn't bore players? Basically
on "how" I should go about building my game.

~~~
mongro1
[https://www.gamedev.net](https://www.gamedev.net) or itch.io (for indie
stuff)

------
azhenley
I have been learning Go lately and would be interested in an engine like Pyxel
but for Go. Does one exist?

~~~
pkaye
I was thinking the same since I have more experience with Go than Python. I
guess one could duplicate this in Go using the SDL library.

~~~
azhenley
Or with Pixel? It looks interesting:
[https://github.com/faiface/pixel](https://github.com/faiface/pixel) . Instead
of SDL I would at least use SFML: [https://www.sfml-
dev.org/](https://www.sfml-dev.org/) .

Maybe I will try replicating it when I have more free time!

------
NanoWar
It reminds me of the BASIC language shipped with the TI-83 calculator!

------
makach
this just looks like a fun way to learn python and game development. the api
resembles very much the basic commands available in the 80s.

~~~
xorcist
I wish we had that kind of api in the 80s...

------
Yuioup

      Run on Windows, Mac, and Linux
    

:-)

------
axiomdata316
Duplicate:
[https://news.ycombinator.com/item?id=17650590](https://news.ycombinator.com/item?id=17650590)

~~~
detaro
Please don't point out "duplicates" on valid reposts. "I posted this before,
but nobody cared" doesn't add anything.

------
xyproto
python-pyxel is now available in AUR, for Arch Linux users.

------
megaman22
This looks real fun, I'll have to play with it when I get a free minute. The
graphics and sound apis remind me a lot of QBasic, where I first learned to
program

