first impressions: PyGame

So, I’ve decided that every time I use a new language or framework for the first time, I will write a little first impressions post about it.

This spring term I am taking a computer graphics class, CS 455 at BYU for anyone interested. It has been a really interesting class, and the projects so far have been both fun and informative. The latest project we were assigned to do was an Inverse Kinematics solver. If you don’t know what Inverse Kinematics means and you want to, you can read about it on wikipedia, but that’s not the point of this post.

We were given a framework, basically a starting point, using XNA that we could use for the project. Well, I ran into a little hitch there when the CPU in my nice gaming machine died. My gaming computer was also my only windows machine (I run Fedora on my school laptop). So… now what?

I decided I would need to learn and use a different environment, language and library to do the assignment. Being a big fan of Python I decided to try out PyGame, a library designed to help make 2d games.

This is, of course, a first impression, I have only spent about 8 hours total working with the system, but here are some initial thoughts after completing my first project in PyGame. First, a screenshot:

Screenshot from 2013-05-23 00:27:06

Syntax

Well, considering that this is a library for Python the syntax is, well, Python. That is a huge plus. Even if you are not familiar with Python syntax it is pretty simple to learn (unless you are an experienced C-related language programmer, then the lack of brackets and semi-colons might drive you nuts). It is a library that is simple to use for both experienced an inexperienced programmers. The entirety of the IK solver took only 155 lines of code.

PyGame itself plugs into Python like any other module. It provides a bunch of classes, methods and constants that make interacting with the game window really simple. Here is my displayPlanks method, which is used to draw all of the planks that make up the arm.

Before calling this method we already know where each plank is located as well as how much to rotate the image of the plank. We also know the position of the end-effector (represented graphically as a baseball). This method simply takes the image of the plank, scales and rotates it for each segment, and then prints all the planks and the baseball to the screen. All of that happens quickly and without a lot of code.

Documentation

The PyGame module is pretty well documented, and everything I needed was pretty easy to find as well. However, I must say that the color scheme used for their online documentation is pretty hard on my eyes.

Additionally, I was able to find some examples of some of my problems easily enough on google. There is also this free online book that is a pretty good resource to learn how to use PyGame, I only read chapter 2 and half of chapter 3, but it is easy to understand and is a pretty good resource for anyone interested to learn PyGame.

Power and Capability

This was a simply project, and I haven’t done a lot of research on this subject yet, but as far as I’m aware, PyGame is not designed to be a heavy-duty game development environment, so I doubt we’ll be seeing any best seller’s coming from it, but it’s simplicity definitely makes it worthwhile and capable of being a good way to prototype and make smaller games.

Conclusion

Again, this is a first impression, so if I have preached false doctrine, I claim ignorance as my defense. That being said, though, I was impressed at how simple it was to learn and build something with PyGame, and I plan to use it in the future for personal projects.

Here is a demo of the IK solver in action:

You can check out the source code for my IK solver on github.

on changing one’s identity

Okay, first some background. My birth name is Isaac. However, about 18 months ago (it may have actually been 2 years, but the specifics are not important, what is important is it was a while ago) I changed and started to go by Ike. The reasons for this are a little complex, but one is I don’t like who I was in high school (then again, who did? We were all terrible people in high school) and since starting college I had been trying to reinvent myself. (Freshman year I thought about starting to go by my middle name, Grant, but that never panned out.) The name Ike started off as a lazy moment, where I typed my name as TAIke on a chat forum. I was working as a teaching assistant at the time. And yes, Ike is only two letters shorter than Isaac, but that’s how it was. The chat room was used by the students to ask the TA’s questions without having to come into our office, which was helpful on both sides. However, all the students started calling me Ike because I had never bothered to change the name on the chat. After a while I grew to like it.

The name Ike is unique. Well, Isaac is also, at least among people my age, I only know a handful of Isaac’s around my age (however, it is a really popular name among 10-12 year old boys), and I personally don’t know anyone that goes by Ike. The name Ike does come with it’s problems, though. One is that most of my introductions happen something like this:

“Hi, I’m Ike.”

“Mike?”

“No, Ike”

But that I can deal with.

The name also brings with it two associations. One is with president Dwight D. Eisenhower (which, by the way, baffles me, how is ‘Ike’ derived from that name) and the other is ‘Ike from Super Smash Brothers’. For the record, he is not from Super Smash Brothers, he is from Fire Emblem, and he is bad-ass.

However, changing your identity is not that easy. There are a lot of people that still know me as, and prefer to call me, Isaac. I even get confused myself as to what name to put on forms, and on rare occasions I still slip up and introduce myself as Isaac. Transition is proving more difficult than simply deciding to introduce myself as Ike and sign my name as “Ike Ellsworth”.

But there’s a reason why it’s important to me. It’s about reinventing myself. Don’t get me wrong, there is nothing wrong with the name Isaac, it’s a good name, and I’m grateful to my parents for naming me that. However, at the same time, changing the way I identify myself is part of changing who I am.