Phil Hassey - game dev blog
Phil Hassey as Wolverine
"What kind of
arrogant jerk
has a website like this?"

Archive for the 'pygame' Category

Dynamite Jack: The second prototype, post-post mortem

Monday, April 23rd, 2012

So about six months after I created “Escape from Anathema Mines” during the Ludum Dare game jam, I created a game called Dynamite in the PyWeek game jam.

Theme

So the theme of PyWeek #1 was “Power” .. I worked with my brother-in-law Tim on this game, and we spent a fair amount of time working with the idea of using a “mind control power” over the characters in game. So I wrote some A* code to navigate things around and whatnot. This was boring. So I made it so you could blow something up. This was exciting. We decided “the power of dynamite” was what the game was about, since the dictionary definition of dynamite said something about “a powerful explosive.” Not my best “theme compliance” for a game jam, I’ll admit.

Gameplay

The best way to see the gameplay is to PLAY THE GAME if you have Windows 🙂 (Download the post-compo version, it’s a little shinier.) But short of that, watch me play through one of the levels. There’s a ton of interesting differences between this and Dynamite Jack. The most significant one is that in Dynamite you can “fail” really easily. You can block yourself into a corner by destroying the floor, and you can run out of bombs. Those are both design decisions I changed for Dynamite Jack.

Fun facts

Tim created all the music for this game, one of the tracks is based on a fiddle tune as well. You may be able to tell that the character art in this game is the same character art I ended up using in Dynamite Jack. It’s all from Reiner’s Tilesets. It definitely helped a ton to have that art work. It ends up looking really sharp in Dynamite Jack because I scale things down so small.

I also brought the “dynamite drop” sound effect from this game into Dynamite Jack. It just sounds so cool.

Post-Mortem

I think one of the big gameplay mechanics I like in that game is that when you sneak along the walls you are invisible to the guards. It kinda leaves the “lighting effects” to your imagination. But one of the problems with that is that it’s not very obvious. I used the different colored cursor to help the player be able to know where the safe zones were.

This game introduced the fun of having guards running to check out whatever you just exploded. I did the voice acting in this prototype of the game.

The idea of this game really stuck with me for a long time, so for the next several years I always talked about going back and re-making it.

TO BE CONTINUED …

(Dynamite Jack is coming to PC / Mac in mid-May. Check out the trailer to see the difference from the original shown here.)

Ludum Dare 2010 Keynote (starring Cuzco the Goat!!!)

Friday, April 23rd, 2010

See the Ludum Dare 2010 Keynote:

Inviting all python game-devs! Even if this notice is coming too late, we’ve got a compo coming in August, December, and mini-compos every month! Just check out the website and join the fun!

-Phil

xkcd “Self-Description” solved with python+pygame

Wednesday, January 13th, 2010

Well, something about this xkcd comic drew me in …

The 3rd panel reminded me of a study I did in college on iterated function system fractals.  These fractals are known for creating ferns, trees, and the Sierpinski triangle.  There are a number of ways of creating these fractals, but one of them is called (something like) the reducing photo copier method.  Where you can start with ANY starting image on your photo copier, and just shrink the images, make a few copies, position them on the copier, and repeat.  Eventually your image converges towards the fern / triangle / whatever if you are precise.  (This can be done with a ‘Real Life’ photo copier for simple IFS like the Sierpinski triangle.)

So as a way to avoid work that I’m supposed to be doing this evening, I figured I’d see how “accurate” this comic was.  Here’s my pygame code that checks it out.  If you run main.py it will start with an image (the xkcd logo) and each time you press a key it will do an iteration of re-creating the comic.  You can see it flashing between the current iteration and the original strip.  After about 4-5 iterations the images converge (pretty closely.)

The most interesting bit was trying different starting images and seeing how long it took to converge.  Starting with all black  it takes 6 iterations.  Starting with all white takes 5 iterations.  And starting with the xkcd logo takes 4 iterations.  The logo probably goes the quickest because it has some black and white in it (like this image) so it converges faster.  (You can edit main.py towards the bottom page to try these different starting points.)

So .. there ya go!  Enjoy!

-Phil

Seahorse Adventures – Loading TGAs (and more)

Tuesday, January 5th, 2010

Here’s a screenshot.  This is my Ubuntu desktop of my work on a new iPhone game.  Take a look at it nice and big.  Below I’ll explain all of what is going on …

bsa_dev1

In short, I’m working on porting my pyweek#3 team entry to the iPhone.  Here’s the details:

  • Top left, you see Kate, my text editor.  You’ll notice I’ve got -what appears- to be python.  But that’s actually tinypyC++ code!  My converter still has some rough edges, but it’s starting to get pretty good.  If you weren’t looking to closely you might mistake that for ordinary python code!  (In fact, it should be 100% python parser friendly.)  You can see how I have to use a touch of annotation to make it all go.  But for the most part, the types get inferred.  (The C++ outputted is about 2x as long, so I’m saving a ton of keystrokes!)
  • Top right, you see the level being painted.  It isn’t all working yet, but those are the basic tiles.  Interesting bit about loading the level, when I created this game I used my own level editor and library I made with pygame.  To save on disk and time I save all the levels to .tga files.  Since I’m targeting the iPhone I need an easy way to read the data from .tga files.  I don’t have SDL_image available, so a friend pointed me towards this great site.  It appears to have some awesome bits of code, including very simple and easy to use image loader that can load tga/png/jpg/etc.  I think it has the most painless interface I’ve ever seen for a C-based image-loader.
  • Bottom right you can see me working on tinypyC++.  As I’m working on BSA, I’m always finding new bugs in it.  Lately most of the bugs have been of the “add more graceful error handling” nature.  tinypy will point out what line (and character) an error happened on, but with a bit of extra work I’m able to add in some coherent error messages to tell the user what is going on.  In this case it was to inform the user of an undefined module name.
  • Bottom left you can see the startup of the game.  I’m using irrKlang for all my  game audio now.  It is not open source, but it’s “free” to use for free games, and the price is quite reasonable for commercial projects.  irrKlang is not portable to the iPhone yet, so I have to have a separate driver for my iPhone audio.

And that’s it for today’s report!

-Phil

Restricted tinypy to C++ compiler

Tuesday, December 1st, 2009

elephant1I’ve spent the last week working on a tinypy to C++ converter.  It works!  See the screenshot to the right – I’ve managed to port a pygame game over to C++.

Here’s how (and some of the catches):

  • I require type annotation of all the functions and methods.  “def test(x:str)->str: return x”
  • I do two passes on each file, the first pass to catch all the function types and class members, and the second pass to generate the code.
  • I generate C++ code that has automagic reference counting.  So you have to code your script so it won’t have any cyclic references if you want garbage collected for you.

How is this different from shedskin (really cool project!)?

  • Built-in reference counting, instead of using libgc.
  • I require the user to type annotate everything.
  • It only supports a subset of the tinypy subset of python.  Shedskin supports a much larger subset of python.

So what’s the point?

  • Well, I learned a lot about STL and C++.
  • I know it will produce iPhone friendly code, I’m pretty sure libgc isn’t iPhone friendly?  (At least, I haven’t found anything via a few searches…)
  • Way less magic.  Since everything is annotated, there are no surprises.
  • Implementing C++ modules is pretty easy – the code can be inlined within the python code and it just works.
  • This will make it easier for me to develop C++ games.

Anyway, if you’re super brave, you can check out svn://www.imitationpickles.org/tinypy/branches/tinypy2 .. I don’t have the elephants example in there, but the pygame.py that I include gives you a pretty good example of a complex module.

I’m going to chat with the tinypy folks to see if we’ll merge this into the tinypy trunk or have it as a separate project.  I’m not quite sure what makes sense to everyone else 🙂  The nice bit about merging this in is that I could unify the test suites nicely.  And tinypy would still function as normal, just better tested, and with function annotation parsing supported.  All that said, I should make a tinypy module for tinypyC++ so that I can do some code evals!

Watermelons for the iPhone / iPod Touch

Wednesday, September 10th, 2008

Watermelons is the ultimate fruit rescue mission game! The local watermelon tree has gone berserk and is producing fresh watermelons at an amazing rate.

You must move your trampoline at high speed in order to save the melons from splattering horribly on the ground. You get ten slip-ups before you lose your job as the Melon Master.

Includes high scores, realistic watermelon sound effects and authentic watermelon bouncing soundtrack.

Watermelons was first created in several hours using python+pygame.  I then ported it to haxe.  And then last of all, I ported it to the iPhone / iPod touch using C code.  I suppose the dev lesson learned is .. rapid prototyping stuff in python is really quick and easy.  So when I port a game from python to something else, I’ve got the whole game concept down, so it’s fairly straight forward to switch to a static language like C.  If say, the problem was not well defined, I suspect it would be harder to implement the games in C first.  (I think my statement here was particularly true for porting Galcon to the iPhone.)

Anyway, check out the flash version, and if you think it’s worth your 0.99, you can get it on the App Store now 🙂

Phil’s pyGame Utilities (pgu) project up for grabs!

Wednesday, May 21st, 2008

Well, I developed pgu several years ago .. and I’ve sort of moved onto other things.  And now I really feel like I’m not doing a great job maintaining pgu anymore.  I get occasional contributions which I don’t handle and I don’t really have any direction I want to take pgu, so I think it’s time for me to step down as maintainer of that project.

I’ve got a project page on pygame.org that has a pretty good description of what it does.  I’ve also got a project page on sourceforge that has the mailing list.  Really, it would probably do better all hosted with google code and google groups.   (tinypy has been doing *great* with those!)

Anyway, it’s been fun, but it’s time for me to let someone else take the torch!  Good luck to whoever that ends up being!  I guess I’m sort of taking applications here, so .. tell me why you’d be the best maintainer for pgu 🙂

did someone say “galcon in the browser” ??

Saturday, April 5th, 2008

Hmn .. maybe someone did ..

ggconn.jpg

Yep, that’s python+pygame alright .. 🙂

Fun with the OLPC!

Wednesday, March 19th, 2008

Yesterday and today I worked with Mike Fletcher and had a great time porting a couple of my games to the OLPC 🙂

Watermelons

olpc-melons.jpg

Elephants (pic taken with an XO!)
blah.jpg

I had a great time working on this – though a couple of odd bugs in the dev. environment proved to be a bit bothersome, we were able to get through them. The main product of this effort was the creation of the “port your pygame game to the OLPC” tutorial.

On a side note, I also gave an impromptu talk on networking games to help an OLPC group get some good ideas on how to write an easy to use networking API for their games. A fair portion of it explained how I implemented networking in Galcon. The other portion explained how “I did it wrong – and you should do it some other way such as _____.” Richard Jones and Mike Fletcher also attended and chipped to help explain the bits that I glazed over.

Galcon Tournament at pycon!

Friday, March 7th, 2008

There will be a Galcon Tournament at PyCon on Saturday night from 8:00pm – 11:00pm in Ballroom II.

201.pngGalcon is an awesome high-paced multi-player galactic action-strategy game. You send swarms of ships from planet to planet to take over the galaxy.

Feel free to come even if you don’t have a Galcon license – they will be provided 🙂 It’ll be a great time to hang out and play one of the top 10 indie games of 2007 – built with python and pygame, of course!

Hope to see you there! If anyone wants to talk game development or Galcon or whatever, just look for the guy wearing a Galcon t-shirt 🙂

P.S. Just to be on the safe side, try to download and install Galcon well before the tourney so we don’t swamp the conference network.