Showing posts with label pyglet. Show all posts
Showing posts with label pyglet. Show all posts

Thursday, December 5, 2013

kivy - alternative to Pygame

 

I looked at pyglet two years ago in October of 2011.    Since that time, I haven't gone back to it.  I've been focused on Pygame Subset for Android.  As far as I know, Pyglet doesn't work on Android phones.  I also like the Pygame documentation more than the Pyglet documentation.

Another library, kivy, does work on Android.  It should also work on iOS.  I haven't tried it myself on either Android or iOS.  My son and I have used it on Linux and it does work great on Linux.

My son was able to build a pong game from the tutorial in one session.  Kivy has a lot of potential and I want to go back to it.

The reason I'm still using Pygame for my lessons is that my son is still getting used to object oriented programming.  With Pygame, the program is can be made more easily with one long block of code.  He can then go back to change the program components into functions or classes.

With kivy, he has to immediately start using classes.

Here's the basic "Hello, World" in Kivy.




While this is actually shorter than a Hello World program in pygame, it does require class instantiation, which is a bit difficult to understand for a young teenager.

The kivy documentation is also considerably weaker than the pygame documentation.  Since kivy is a younger project, I've also experienced more problems with getting the libraries to work all the time on my Linux system.  For example, when I updated Ubuntu 12.04 to the beta NVIDIA Driver, 325, kivy stopped working.  However, pygame was still working.  This may be due to an error with the NVIDIA driver GL implementation and have nothing to do with Kivy.  However, it does show that with less people using Kivy, more things can go wrong.

The advantages I can see for kivy are:

  • multi-touch support.  This is huge.  Pygame only supports a single point.  Although there are some hacks to use the joystick module to detect multiple inputs, it's not that clean a solution.  Getting multi-touch support is a major draw.
  • iPhone, iPad support.  It doesn't look easy to do and I've never done it.  There are some apps on the Apple Store.  So, it's possible to get it to work.  I'm sure it will get easier as the platform matures.
  • GPU acceleration.  The fancy OpenGL ES 2 support makes it easier to do cool 3D effects
  • Android and iPhone support is provided by the core maintainers.  For Pygame, we need to rely on the separate pygame subset for android project (which probably won't support multi-touch since the key developer wants to keep the feature set similar to what is on the base pygame library.)
  • The development community around adding features to the platform seems to be more active than the pygame development community.
The downsides for the purpose of teaching:
  • Pygame documentation is better
  • More people use Pygame and there are more examples of Pygame code
  • The larger pygame community means that most problems have already been solved by other people.  Much more answers on stackoverflow
  • Kivy uses the KV Design language in a separate file.  It gets a bit like JavaScript where you have multiple languages for one application.  There's upsides and downsides to this approach.  The main downside is that there's a slightly steeper learning curve for the kids.
Despite the shortcomings, I'm most likely going to revisit kivy in my curriculum after my son gets through his 2D Maze games.    This assumes that I don't start on django.



Friday, October 21, 2011

Pyglet - Alternative to Pygame

I've been reading more about Pyglet, an alternative to Pygame based on OpenGL.  Although there seems to be more documentation around Pygame, it might be because Pyglet is newer.  From looking at the documentation, it doesn't seem like Pyglet support joysticks or gamepads.  Since, I've been planning to have the next project be a first person shooter with joystick support, I will probably stick with Pygame for now.

When I have more time, I plan to check out PyOpenGL and cocos2d.

Update Dec 2013: Check out this post on kivy.