Posts

Showing posts from 2018

๐Ÿฑ‍๐Ÿ — the first pygame 2 community game. Starting now! Are you in?

What is a ๐Ÿฑ‍๐Ÿ? *[0]. There was this email thread on the pygame mailing list. " About Pygame development ". One topic of that conversation was doing a community game in there for reasons(see below). I would like to do a pygame 2 community game to submit in the: - https://ldjam.com/ - https://itch.io/jam/game-off- 2018 (GameOff github jam) Ludumdare(ldjam) starts in 3 days, 7 hours. Theme not selected yet. GameOff finishes in 4 days 2 hours. Theme is "Hybrid ", Jam already started. So, the Jams finish in 4.1 days.   Are you in?  If so join the web based chatroom (discord) in the "#communitygame" channel. Our repo: https://github.com/pygame/stuntcat I'm trying to form a team now. ... read more?... click.... loading... loading... buffering... loading... refresh... loading... So why do this? My reasons for doing this are to push me to get pygame 2 features done that are actually u

pygame 2 update - the examples all work

Image
  ๐ŸŽฎ๐Ÿ‘พ๐Ÿ‘ฝ๐ŸŽฎ๐Ÿ‘พ๐Ÿ‘ฝ๐ŸŽฎ๐Ÿ‘พ๐Ÿ‘ฝ๐ŸŽฎ๐Ÿ‘พ๐Ÿ‘ฝ examples/ chimp.py works ๐Ÿ‘ฝ๐ŸŽฎ๐Ÿ‘พ๐Ÿ‘ฝ๐ŸŽฎ๐Ÿ‘พ๐Ÿ‘ฝ๐ŸŽฎ๐Ÿ‘พ๐Ÿ‘ฝ๐ŸŽฎ๐Ÿ‘พ That's a nice milestone for pygame 2 development. (and also, now these examples also work...     python -m pygame.examples.aliens     python -m pygame.examples.scroll ) I'm pretty sure all the examples are now working with SDL2/pygame 2. New SDL2 functionality. Also we have some new SDL2 functionality exposed     (experimentally, the APIs are not done yet). Multitouch, and AudioDevice, along with an example of recording audio. @dlon has been fixing a number of bugs(implementing key repeat, fixing unicode issues) and also prototyped some Window/Renderer classes (using ctypes and python). The new events are done in a backwards compatible way, so that games using them with pygame 1/SDL1 will still work. You just won't get the events. if event.type == pg.AUDIODEVICEADDED:     print('a new sound card plugged in... let's offe

Drawing data. With #flask, and #matplotlib.

Image
Here's a pretty simple example of using the Flask microweb framework, and matplotlib together. Matplotlib is a graphing library used by a lot of people in python. But how to serve your graphs up in a web browser as a png or an SVG image? Code is in this gist: flask matplotlib . Serving svg and png images with Flask and matplotlib. here is what it looks like Code is in this gist: flask matplotlib .

Josh Bartlett — pygame Artist in Residence

Image
The pygame Artist in Residence grant celebrates the Python arts community and lends a tiny bit of support to someones art practice. Josh Bartlett was the first recipient. An artist residency usually works something like; a person spends some time in either a gallery making something to present or in a music club doing a weekly spot. The pygame artist in residence will do it in their own space, but be present on the top of the pygame website in the form of a thumbnail and a link to their patreon/blog/artist statement/website/whatever. Josh Bartlett was the first recipient, and has been featured on the pygame website in October.  Please see the pygame artist in residence profile page for more info. What has he been up to?  Go to his blog to find out. ps. Thank you to everyone who applied, and those who helped with selection. Hopefully the next one will go more smoothly as the process is improved.

pygame artist in residence grant

Image
An artist residency usually works something like; a person spends some time in either a gallery making something to present or in a music club doing a weekly spot. Artist in residence. The first "pygame artist in residence" grant will be for a small amount of money (€512). It is for someone who is already doing stuff with pygame or python in their arts practice. There will be a little thumbnail on the website linking towards an artist statement/patreon page/blog or some such. The residency won't be in a physical space. It lasts for a month, from October 1st - November 1st. At the end of the month the website 'exhibition' will take the form of a small update from the artist — in whatever form that takes . If you'd like to apply(or nominate someone) please write something short with a link about the arts practice and how python or pygame is used in it. Email: residency@pygame.org Applications close: September 15th. Announced: October 1s

Draft of, "How to port and market games using #python and #pygame."

This is a collaborative document, and a really early draft. Please feel free to add any tips or links in a comment here or on the reddit post https://www.reddit.com/r/pygame/comments/9aodt7/collaborative_doc_lets_write_pygame_distribution/ You've spent two years making a game, but now want other people to see it? How do you port it to different platforms, and make it available to others? How do you let people know it is even a thing? Is your game Free Libre software, or shareware? All python related applications are welcome on www.pygame.org . You'll need a screenshot, a description of your game, and some sort of URL to link people to (a github/gitlab/bitbucket perhaps).  But how and where else can you share it? a few platforms to port to itch.io and windows windows store? mac (for itch.io) mac store steam linux 'flatpack' (latest fedora/ubuntu etc use this like an app store). pypi (python packages can actually be installed by lots of people

pygame 1.9.4 released

Image
pygame 1.9.4 has been released into the wild! TLDR; Some highlights. python 3.7 support. beta pypy support. See Are we pypy yet? . pygame.draw fixes pygame.math is not experimental anymore. Speedups and bugfixes. Debian, Mac homebrew, mac virtualenv, manylinux and other platform fixes. documentation fixes, jedi support for type ahead in editors like VSCode and VIM. Surface.blits for blitting many surfaces at once more quickly. Thanks A very special thanks to the people who have volunteered commits to pygame since the last release. In alphabetical order... Adam Di Carlo ( @adicarlo ) | Christian Bender ( @christianbender ) | Don Kirkby ( @donkirkby ) | endolith ( @endolith ) | hjpotter92 ( @hjpotter92 ) | Ian Mallett ( @imallett ) | Lenard Lindstrom ( @llindstrom ) | Mathias Weber ( @mweb ) | Matti Picus ( @mattip ) | Nicholas Tollervey ( @ntoll ) | ( @orangudan ) | Raymon Skjรธrten Hansen ( @raymonshansen ) | Renรฉ Dudfield ( @illume ) | Stefan Bethge ( @kjyv ) | Stu

Berlin to Copenhagen by bike.

Image
There's a bike path running from the north of Europe all the way to the south. Well, it's not completely finished yet, but it goes most of the way. It's part of the EuroVelo project, which aims to have a high quality cycling network made of 15 routes all around Europe completed by 2020. All my clothes and possessions for a seven day trip from Berlin to Copenhagen. I was just going to tie a sack under my seat... but was convinced that perhaps these special bags are a good idea after all. One part that's done well is the Berlin to Copenhagen leg(I guess not so surprising since they are two cities that are really into supporting bikes). Scroll down on these photos someone took, if you want a look. http :// www . slowtravelberlin .co m/ in - photos - berlin - copenhagen - cycle - route / Except, I'm going to do it at the end of April, not in winter like them. Which is usually the most dry time of year, and with a temperature that's not so hot or

pygame.Surface.blits

Drawing many things at once is faster than drawing things one thing at a time. So, today I made a function to do this with pygame. It seems to take between 82%-85% of the time it takes to draw things one at a time. Which considering blit is often the bottleneck in many pygame apps is a pretty nice improvement. It will be landing in the pygame 1.9.4 release. More info in the blits Pull Request .

Moss box

Image
I've been looking to get more greenery into my studio, and I kind of like moss. It reminds me of when the times in my childhood running around rain forests barefoot. Luckily, a good friend has a whole bunch of it growing out the back of her apartment. And it's likely to be destroyed soon by workers. Which made me not feel so bad about digging some up. I scavenged some egg cartons First I found some egg cartons to use as a base. Underneath the moss is a good few centimeters of dirt. Unlike most of the wall moss I've seen around the place, this moss is alive. I was sort of horrified to learn that people buy dead preserved moss, and glue gun it into place. But this stuff is alive. Sometimes looking stuff up on Youtube kills the magic. Now I don't think wall moss is anywhere near as cool as I once thought it was. Thanks internet. Here it is sitting on my standing desk. Next I found an old wooden box. I lined the bottom of this with some plastic I had abo

Investigating pypy frame drop

Image
pypy has spikes in time it takes occasionally when using cpyext, otherwise known as pauses. This is because it's deallocating lots of CPython objects all in one frame, rather than incrementally. This is likely to be addressed in a future release of pypy. Mainly it's a problem when creating and deleting lots of CPython objects (like pygame.Rect). Not pure python objects. To work around it for now, the src/rect.c has been changed to have a free list of python objects, so it doesn't alloc and dealloc them. Instead it maintains it's own list of rect PyObject pointers, and reuses them. This is done in PR #431 Use PYPY_GC_NURSERY=1m incminimark environment variables when running pypy. Below are timings of the default pygame, and default pypy (at time of writing). Then a benchmark showing the improvement with the rect freelist implemented in rect.c inside pygame. Then we also improve things by setting PYPY_GC_NURSERY=1m environment variable to change the

Windows pypy pygame build for testing.

Image
How to install pypy (fast python written in python) on windows and use the pygame dev build. pypy running pygame.examples.aliens on Windows 1) Get pypy. It's just a zip folder with all the stuff inside. https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.10.0-win32.zip Unzip, and put into C:\pypy, so C:\pypy\pypy.exe exists. OR get the pypy3.exe from https://bitbucket.org/pypy/pypy/downloads/pypy3-v5.10.1-win32.zip Unzip, and put into C:\pypy3, so C:\pypy3\pypy3.exe exists. 2) Set the PATH environment variable, so that pypy.exe is found in your command prompt. https://www.opentechguides.com/how-to/article/windows-10/113/windows-10-set-path.html Or you can just do this each time you run a new cmd prompt. set PATH=%PATH%;C:\pypy\;C:\pypy3\ Or just cd C:\pypy to test it out. 3) Ensure pip is installed (pip is a weirdly named tool for installing things). pypy.exe -m ensurepip 4 ) Install a dev build of pygame. pypy.exe -m pip install pygame --pre 5

pygame on pypy usable

Image
Hi, TLDR; I'm at the pypy sprint, and working through the remaining pygame-on-pypy-cpyext issues. https://youtu.be/WN1slc5O8os Surprisingly to me... it's already usable. That is pygame (same one that runs on cpython), works on pypy through its C extension API. pypy has good support for the CPython API (through a recompile) now. PyPy is the python language with a fast JIT, so your code can approach C speeds. And in some cases it can be faster than C. There was an issue with events stopping keyboard/mouse/etc from working. Lots of details in this issue describing the changes needed, so I hope other extensions encountering this will find it useful. https://github.com/pygame/ pygame/issues/419 But now that's fixed, every pygame app I tried on it has worked. Cat sitting in the fog and snow of Switzerland Why is this exciting? This is exciting to me because: pure python code being fast on pypy(after warmup), also mixed with the fast bit

Drawing sound (as a waveform in pygame).

Image
I recently gave an example of pygame sound generation examples , and a few people asked for more. So... here we go! There's an infinite number of ways to visualize sound. A classic way is to draw it as a waveform . Sound samples drawn as a Waveform. Scaled into a 320x200 sized Surface. A sound could be made up of 44100 samples per second. Where each sample is often a 16 bit number (or 8bit or a 32bit floating point). Python comes with a built in array for efficiently storing numbers. We can store samples in there, with integers between -32768 and 32768. This is a signed 16bit(2 byte) number. Two to the power of 16 is 65536, and if we divide that by two we see the minimum and maximum value that can hold. pow(2, 16) / 2 == 32768. Below is the annotated code, also with an example of an array of samples representing a square wave. We loop over the samples and draw a line from the previous sample to the current one. 0 to 1, 1 to 2, 2 to 3, ... N-1 to N. You can also fin

Sound generation pygame examples.

Here's a few sound generation examples with pygame (and no numpy/scipy). If there's interest I'll expand this into a bigger example? Let me know. All the basics for making a music program (sampler/synth). some sample rate conversion, bit rate conversion tone generation using generators (square wave) python arrays used as buffers for pygame.Sound (zero copy). """ Some examples for generating and converting sounds for pygame. Python 2.7, 3.6 Shows: - a simple 'square wave' generated - resampling sample rates (eg, 8363 to 44100) - using built in python array for making pygame.Sound samples. - samples at different bit sizes - converting from signed 8 to signed 16bit - how initializing the mixer changes what samples Sound needs. - Using the python stdlib audioop.ratecv for sample rate conversion. Square Wave https://en.wikipedia.org/wiki/Square_wave MOD (file format) https://en.wikipedia.or