Brainfold On Python, game development and everything

16Mar/10Off

PyEigen

I have a new project called PyEigen, a wrapper for the C++ linear algebra library Eigen. I just submitted the first batch of code and progress is good, at least so far. :) I'm hoping for an initial release within a month or so.

The whole thing started when I profiled my shooter project and found that matrix calculations take up a huge amount of time. Apparently NumPy isn't really fast enough for 3D games, and I couldn't find any replacements. While otherwise looking good, euclid and vectypes are pure Python so they aren't going to make performance any better. cgkit is C++ with a Python wrapper so looking better already, but... it's using Boost.Python, which apparently isn't very fast. Also, it's lacking SSE instrumentation and other optimizations included in Eigen. So I decided to wrap Eigen.

As I already found out, Boost.Python is slow and looked too complex for such a simple library anyway. I tried Cython next, but its C++ support is (still) very limited and the lack of support for C++ references destroyed any hope of wrapping Eigen, which relies heavily on them. My final option before resorting to manual wrapping using the Python C API was SWIG, but I had problems getting even a simple wrapper to compile. Besides, I don't really like how SWIG generates function wrappers and a separate Python module that calls those wrappers instead of generating a Python C module directly.

So I was left with only the final option: Python C API. I feared it at first because I've never worked with it and it seemed really complex. It is complex, but not nearly as bad as I though, especially as Eigen has such a simple API. For Bullet, I'm sure I'll use Cython or some other wrapper generator, but for Eigen the Python C API is just fine.

Anyway, since there doesn't seem to be anything like this out there, I decided to make it an open source project so hopefully other people in the same situation won't have to jump through the same hoops as I did. I'll post progress reports, releases and especially benchmarks against the other options as soon as I have them.

http://launchpad.net/pyeigenI h
29Nov/09Off

Stealth prototyping

Yes, I know, I have been quiet on this blog for over half a year now. That doesn't mean I'm dead; quite the opposite, since I have been really busy with Real Life and professional game development. :) However, as some of you might have noticed from my Twitter feed, I have been working on a new game. It started as a vertical-scrolling shoot'em'up but has transformed into something else entirely. At the moment I have just a load of ideas and an early prototype, so I don't want to write too much about it yet, but more on the project later. And yes, it's in Python. :)

As for Artillery Brawl, the code became a mess and destroyed my motivation to continue the project, which is why I started the new game to begin with. I might start Artillery Brawl again based on this new codebase, but for now I'm working on the shooter.

I hope to write more about the new project and its progress again in the near future, but in the meantime, the best way to follow the project is my Twitter feed.

4Mar/09Off

Moving on

I haven't updated for a while again. Let's get gamedev news out of the way first. I haven't worked on Artillery Brawl for a couple of weeks; instead, I have tried to get the card game ready for testing. I made some prototype cards by putting pieces of paper in sleeves that are opaque on one side. This has the advantage that I don't have to go through the trouble of making the back sides of the cards look identical, so it's much easier to make changes. Unfortunately, while the rules are basically ready for testing, I ran out of card sleeves, and when I bought some more I accidentally bought a different size... Now I'll have to wait until next week to buy some more, sigh.

Anyway, about next week... I have a job interview at a game company (wish me luck!) and I'll be moving back to Helsinki where I used to live four years ago before I moved here to Tampere. I also have a couple of deadlines looming for university courses, so I'll be quite busy for the next week or two! At least I already have internet connection at the new apartment, so my connection to civilization won't be severed. ;) See you in a couple of weeks!

13Feb/09Off

Good news, bad news

The good news is, suddenly I got a whole lot more free time for game development.

The bad news is, I don't have a job anymore (yay for the economic situation).

I didn't just freeze and panic though; instead, I called a friend at a game company I was applying to for the summer, and told I might be available for work a bit earlier after all... I hope to hear more from them next week, so wish me luck!

As for other news, I have been working on Artillery Brawl a lot, though still no particle effects... I think they might be cursed, since every time I get close to implementing them, I run into problems or some other thing I just have to fix. Anyway, the good thing about this is that the entity system and a lot of the code in general is starting to look really good and reusable. This is how I should have approached building a reusable codebase to begin with; writing a game, then generalizing the solutions that work.

9Feb/09Off

Triggering (explosive) payloads

As part of my effort to integrate Lepton for particle effects, I have been implementing a system of triggers and payloads to make projectiles more interesting in general. The system is heavily inspired by the similar payload system for my old artillery game, Arty, which I wrote about earlier, but of course redesigned and modernized to make it more generic and cleaner. I haven't settled on an interface yet, and looks like I'll have to make yet more changes to the entity system, but every change is a step closer to perfection, right? Anyway, about triggers and payloads...

Any number of triggers and payloads can be attached to entities. For now, they will only be used for projectiles (artillery shells), but later they could be used for many other gameplay applications. Triggers can react to collisions, height from ground, proximity to units, or they could activate after a delay. Almost anything is possible, really, but I'm starting with just collision triggers. Payloads are triggered, well, by triggers; they are the "meat" of the projectile system. Again, I'm starting simple with just kinetic (contact damage based on mass, velocity and an armor piercing multiplier) and explosive (yay, particle effects and shrapnel projectiles) payload, but almost anything would be possible. For example, it would be easy to make a cluster bomb that explodes above ground (height trigger attached to directed explosive payload) into many small bomblets (individual projectiles with contact triggers attached to explosive payloads).

More on the triggers and payloads when I get the system implemented.

30Jan/09Off

Lepton

Remember when I said "if I don’t hit any further roadblocks", I would add particle effects to Artillery Brawl this week? Well, guess what...

The bad news is, I had to spend a whole evening porting lepton to Windows so Visual C++ would compile it.

The good news is, I'm now the maintainer and tester of the Windows port of lepton, so hopefully this doesn't happen to anyone anymore. The first Windows installer for Python 2.6 has been released; check the lepton home page. Unfortunately, I couldn't get it compiling for Python 2.5, since I don't own Visual C++ 2003 and building extension modules with the free Visual C++ Toolkit 2003 compiler is a pain in the arse. I might try it again later, but for now, I'm considering myself defeated.

Anyway, you should all check out lepton, it's an awesome library for creating fast particle effects in Python games and other applications, and works out of the box with Pyglet, Pygame and any OpenGL-based applications. It's also easily extensible so you can add your own custom effects to particles. I'll be sure to post any further experiences (and the video I promised) as soon as I get it properly integrated with Artillery Brawl.

PS. note the new link category – "Cool Python modules" – at the sidebar.

23Jan/09Off

Quickie

Just a quick update... I have been fixing all the stuff that was broken since the change to multi-part units and then some, and everything should be ready for finally implementing particle effects. I even implemented fake sweeping collisions for shells by making them face their velocity vector and making their collision rectangle longer than the shell "sprite." There are still some collision problems when the shooting unit is next to a steep cliff, but it's acceptable for now, pending a real solution.

I'm going away for the weekend, but if I don't hit any further roadblocks, next week should see Artillery Brawl with some kind of particle effects, and of course, a second video of the game! :)

30Dec/08Off

Last of 2008

I just wrote my last lines of Python for this year. I haven't got to particle explosions (I'm going to try lepton for those) or other interesting bits yet, and the code doesn't actually even run at the moment... as usual, one thing led to another while working on small fixes, and I'm just about to finish a huge reorganization and cleanup of the entity system. The good thing is, even if I decide to ditch Artillery Brawl, this code will be useful for other projects, as it's starting to come together really nicely.

One of the biggest changes has been the move of messaging from individual components to the entity itself. I might write about the details later when I've finished my changes and actually used the system for a while, but I can already tell it has reduced dependencies between parts of the code; always a good thing. The biggest test for my entity system will come when I start to implement some more complex gameplay, but so far, so good.

See you next year, happy 2009 everyone!

27Dec/08Off

Holiday coding

As promised (to myself and readers), I have continued game development during the holidays. Not much, mind you, I've mostly been enjoying the chance of being lazy for a change, but it's something, and I hope I don't get any more months-long breaks in the near future. :)

I have been working on Artillery Brawl, with stuff that was left incomplete when I stopped working on it in July. I haven't started on prototyping shooting yet, because I have some related stuff to do first. I have completely changed the units are represented in the code. Instead of a single entity for a unit, there are now several entities for the different parts of a unit; body, turret, later tracks and wheels. To keep all these together, I made a component (an entity is composed of components) that groups several entities together, so I can still essentially handle the unit as a single entity. At least to me, it's a very clean solution, as all these features are in self-contained components, with the entity only containing components which it doesn't know about. At some point, I'm going to have to write about my final entity system in detail, but first I need to actually finish it...

After this change is complete, I will probably work on fixing shell collisions and then move on to particle systems, camera improvements and other stuff related to trying to make shooting fun.

Happy belated holidays, everyone!

10Dec/08Off

Business as usual

It's time to poke a hole in the wall of silence. I just finished selecting university courses for the next semester, which is going to be a bit special. Special, because if I pass every course, I will have finished all the courses needed for my Master's degree! I still have a thesis to write, but it's still a great – and strange – feeling. I have some interesting courses coming up, including pattern recognition, digital image processing and knowledge discovery (which is about data mining, visualization and such).

Since this will hopefully be my last year at the university, and for other reasons, I have been quite busy. As such, I have had to make some sacrifices, such as game development (as evidenced by the lack of updates to this blog). Again. But since I will be less busy after I finish my studies for this Autumn, which should happen next week, I will be free to continue working on Artillery Brawl, and hope I will be at least slightly less busy during the next semester! After all, it would be nice to have something in my portfolio to show when I start applying for jobs to write my thesis at. ;) I also promise to try and get the card game I wrote about playable in the near future.

In other news, Python 3.0 was released while I was away. The improvements, especially to Unicode handling, look really interesting and I would really like to switch, but unfortunately, I can't... None of the libraries I'm using for Artillery Brawl - setuptools, pyglet and pymunk – have been updated for Python 3.0 yet. There's not much I can do except wait, so for now, I'm sticking with Python 2.6.