Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2D animation in Python

I'm writing a simulator in Python, and am curious about options and opinions regarding basic 2D animations. By animation, I'm referring to rendering on the fly, not displaying prerendered images.

I'm currently using matplotlib (Wxagg backend), and it's possible that I'll be able to continue using it, but I suspect it won't be able to sufficiently scale in terms of performance or capabilities.

Requirements are:

  • Cross-platform (Linux, MacOS X, Windows)
  • Low complexity overhead
  • Plays well with wxpython (at least won't step on each other's toes unduly)
  • Interactivity. Detect when objects are clicked on, moused over, etc.

Note that high performance isn't on the list, but the ability to handle ~100 bitmap objects on the screen would be good.

Your thoughts?

like image 247
Dan Homerick Avatar asked Oct 04 '08 05:10

Dan Homerick


3 Answers

Arcade works on any platform with OpenGL 3.3+ (i.e. not the Raspberry Pi, but most other platforms). Although it's intended for simple games, Arcade offers great bitmap and sprite handling, as well as simple graphics primitives such as rectangles, arcs and circles.

like image 136
AlDante Avatar answered Oct 16 '22 15:10

AlDante


I am a fan of pyglet which is a completely self contained library for doing graphical work under win32, linux, and OS X.

It has very low overhead, and you can see this for yourself from the tutorial on the website. It should play well with wxpython, or at least I seem to recall posts to the mailing list about wxpython and pyglet being used together.

It however does not offer selection of objects via mouse clicks - this you will have to handle yourself. Generally speaking for a 2D application this is not too difficult to do.

mactorii is an OS X application of mine written in pure python+pyglet, and has some basic animation (scrolling) and click detection. It doesn't use wxpython, but perhaps it will give you an idea of what is involved. Note however mactorii is using the old pyglet api, so the run loop I have in there is obsolete. I will get around to updating it one day... :P

like image 13
freespace Avatar answered Oct 16 '22 17:10

freespace


You can try pygame, its very easy to handle and similar to SDL under c++

like image 3
Jesús Flores Avatar answered Oct 16 '22 15:10

Jesús Flores