Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Is it possible to make a 2D game with this and pymunk 'compiled' with cython?  (Read 5416 times)

0 Members and 1 Guest are viewing this topic.

Szabo

  • Newbie
  • *
  • Posts: 3
    • View Profile
Hello there.

Gamedev wannabe here :).

I'm wondering... since python is such a simple and 'rapid' language, and SFML is such a multimedia powerhouse with awesome performance, and cython is compatible with python but delivers much better performance... is it possible to mix all of these ingredients with 'pymunk' and a little bit of pepper to achieve the 'ultimate 2d game engine' for desktops?

I mean, generally python (cpython) is fast enough (not for my game though) but there's the problem with distributing the stuff, you have to use things like pyinstaller to distribute for win/mac and it's not a very good approach imho.

Cython can build native binaries on all platforms it supports, I'm not sure how is the procedure and if it's more 'failsafe' than pyinstaller, but it does provide a hell of a improvement in performance (even in pure python sometimes i get 5x the performance) in the tests I did compiling a 'library' with cython (I don't know how to compile the entire shebang (aka, the 'entry point') itself, but afa it's possible it's okay)...

So... any ideas? I've been using some 'alternatives' like Unity and Monkey-X but they all have a lot of caveats and I really need a decent 2d physics engine (yes, unity has 2d physics but the API is soooo limited and monkey-x has only some slow ports) which certainly pymunk provides, I just need a way to program the thing in cython and distribute it in a relatively fail-safe way.

Any help is appreciated.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
I'm not quite sure what the main question you're asking is (and I probably can't answer it), but since you asked/implied you needed a 2D physics engine, I've heard a lot of good things about Box2D.

Szabo

  • Newbie
  • *
  • Posts: 3
    • View Profile
I'm not quite sure what the main question you're asking is (and I probably can't answer it), but since you asked/implied you needed a 2D physics engine, I've heard a lot of good things about Box2D.
Thank you for your reply... I wasn't expecting a reply so quickly.
Box2D is good, pybox2D not so much... for python pymunk is by far the best 2d physics engine, both in terms of stability and usability.

My question is actually quite simple... lemme reword it:

Can I use the python bindings with cython? (cython is a kinda 'restrict' python that compiles into C- bytecode)

And I was just telling that if it's possible to do that, then certainly SFML+pymunk programmed in Cython are surely the best way to make a 2d game for desktops by far, since cython is such an amazing language (it's just python actually) with amazing performance (faster than mono, slower than java), and it even scratches the itches of people wanting some code protection (pro-tip: compiled!=protected).

I always wondered why there's no game engine that allows you to code in cython since it's much faster than lua (not sure about luajit, but I'd guess it's faster), 'simpler' than any other scripting language and still much more powerful, plus it's well documented and proven to work properly... Just look at Unity for example... instead of implementing two 'funky' languages that no-one uses (unityscript has some users, boo scared them all :) ) why not simply implementing cython? Of course for simpler games unityscript is okay and most people are satisfied with c# but cython is so much better... i can literally write one thousand lines in python without testing them.

Szabo

  • Newbie
  • *
  • Posts: 3
    • View Profile
Little update:

It's possible to compile a cython program using python-sfml into c-compiled native executable binaries, however, how can I use ctypes for python-sfml, for example, a 'texture' object, how can i declare a variable of 'texture' type that uses the "C" object and not the python one (cdef)?