The last release, which I announced two weeks ago was a fast release; a snapshot taken on the way to the release candidate build. I had focused on the most important parts of the API (classes/functions most used) to make it the most usable. I’m now pleased to announce that
the update is over and that the binding is
complete,
clean and
stable.
When saying
complete I am referring to a binding containing all classes and functions available in SFML separated in five different modules: system, window, graphics, audio and network. The network module is provided in order to be exhaustive but its use is discouraged since the standard python library already provides one. Documentation, tutorials and the official examples are included to help you with using it. For example; it explains you how to
integrate pySFML2 to PyQt4.
By saying
clean, I mean a binding where error messages are handled
properly and where you don’t have to use byte strings for everything when you use Python 3. The source code is also clean so people who’d like to get involved or want to modify it will find code following conventions, using the right Cython syntax and split into different files.
By saying
stable, I mean a binding where
automatic tests have been performed, hopefully preventing myself from introducing new error later on with changes. Of course I can’t pretend there’s no bugs since it’s the first release and I hope to receive as much feedbacks as possible to fix the remaining issues.
I consider this binding
more pythonic as it doesn’t try to emulate multiple definition function such as in C++ that Python doesn’t support, and you won’t have to deal directly with types, which give
more flexibility to the binding.
This version includes
two more examples: pong.py and shader.py.
Installers for
Windows and packages for
Ubuntu are provided for ease of installation.
To give you an overview, here are four pieces of code that summarize interesting features that you don't find in the official binding.
Import module independently.
from sfml.window import sf # need only the window module ?
from sfml.audio import sf # need only the audio module ?
More flexibility when using vectors.
vector = sf.Vector2()
vector.x = 23 # set an integer
vector.y = 6.42 # set a float
vector.z = Decimal(0.12346578) # set a decimal for advantages over the float datatype
The way you handle events in pySFML2 may surprise you
for event in window.events:
if type(event) is sf.CloseEvent:
window.close()
if type(event) is sf.KeyEvent and event.pressed:
character.fire()
if type(event) is sf.FocusEvent:
if event.lost: music.stop()
elif event.gained: music.play()
sf.Image has an extra method that allows you to view the current image state. Useful for debugging.
image.load_from_file("myimage.png")
image.create_mask_from_color(sf.Color.YELLOW)
image.show() # launch a viewer with the current image state
I’m linking you to the on-line documentation for installation and explanations.
Website:
http://openhelbreath.net/python-sfml2/Documentation:
http://openhelbreath.net/python-sfml2/documentation.htmlBugtracker:
http://openhelbreath.net/python-sfml2/flyspray/Github:
https://github.com/Sonkun/python-sfml2The next release should add the last missing official examples (voip.py, x11.py, cocoa.py and win32.py), fix a lot of issues (if any) and provide installers for
Mac OSX and packages for
Fedora.
I hope there aren’t any major bugs that will prevent you from using the binding.