Phil Hassey - games, tech, web, stuff, biz, and bilge
Phil Hassey as Snidely Whiplash
"You can't buy awesomeness.
You're born that way."

Archive for the 'crazy' Category

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

Elephants! First python + pygame game submitted to App Store :)

Saturday, December 19th, 2009

So, I managed to submit a “python” app to the App Store — “Elephants!” Here’s a few crazy things I had to work out to get things going:

  • I found that ObjC doesn’t care much for C++ objects that do their own reference counting.  To have a “Game” object at all, I had to use a pointer to my object instead of using my reference counting object.  It seems that during some of the “magic” of ObjC it copies objects without calling any of the C++ copying methods, so reference counting gets killed.
  • I ported a basic subset of pygame to tinypyC++ and made it work under openGL.  I don’t have this available in my tinypyC++ repository because it takes a good deal of prep-work to use (isn’t out-of-the-box) so it wouldn’t be generally useful to anyone yet.
  • I was able to get pause on call / resume working by saving the game state to a text file.  Since tab-separated files are so easy to create and parse in python this seemed to be the easiest route to getting the project done.
  • I learned a ton about C++ templates.  I still haven’t even touched the tip of the iceberg, and I’m not sure I want to, but at least I’m getting the basics down and that seems to be enough for me to stumble through this project with.

You can check out my current progress at svn://www.imitationpickles.org/tinypy/branches/tinypy2 (in the tinypy/example folder you can check out a julia fractal demo.  It also includes a mini pygame module that depends on SDL not OpenGL, so it actually works out-of-the-box.)

Here are some things I’ve been adding this week in preparation for my next project:

  • I’ve added “weak pointers” .. Since reference counting has the problem of cyclic references never getting collected, I had to do this for some use-cases.  In tinypyC++ weak pointers are just normal pointers, and if the object is collected, the pointer will be invalid, so be careful.  They are created by doing stuff like “x = ptr(GameData())”
  • I’ve added more C style types.  I’ve got uint16, cstr, Array, etc.  This all makes it possible for me to have a different kind of object – a struct in tinypyC++.  The struct is meant to be a C oriented type that can be saved directly to disk.  In Elephants I serialized via saving CSV data.  In the future, if I keep all the game state in C struct type data, I can just use a single simple line like “open(’data.txt’,'wb’).write(struct_dump(game_data)”
  • I found that STL extensions include a “hash_map” which turns out to be about 2x as fast as the normal “map”.  I’m using that now.

I’m not entirely sure how useful this project is going to be for anyone else, or even for me for that matter.  But I think after my next game project I’ll have a much better feel for what the situation is.  TinypyC++ has some real tradeoffs in terms of being a bit of a hybrid of C++ and of python.  It doesn’t offer the full power of either language.  But I’m doing my best to capture a middle ground between them that will make my life easier.

Galcon pricing experiment

Monday, November 23rd, 2009

Two weeks ago, the price of Galcon @ $3, Labs @ $2, and Lite @ $0.  This past week, I changed them to Galcon @ $5, Labs @ $3, and Lite at $1.  I wanted to see how this would impact revenue.

And the big surprise is …

It didn’t!  Much.  Best I can calculate, revenue was down 10%.  The most dramatic change was Lite, which went from $0 revenue to a few bucks a day, and from a few hundred downloads to almost none.  So this week I’m changing the prices back to Galcon @ $3, Labs at $1, and Lite at $0.  What have we learned?  It seems that people who want a free game want a free game, and people who are willing to buy would rather spend less.  Since I’m not going to run this sale for a month I can’t say for sure what the long term effects will be, but I’d guess word-of-mouth would be reduced as the pool of Lite players shrunk.  Who knows ;-)

Cheers!
-Phil

I can has flash?!

Thursday, March 12th, 2009

So .. who thinks flash + Galcon = win?  I don’t know yet, but I’m giving it a try.  I’m not actually developing the flash version.  An awesome friend of mine has been doing the time on this one.  Though I’ll probably be doing the LAMP end of the deal.  At present the game is non-networked, but we’re been considering the possibilities.  A TCP/IP edition of the game could be made, but I wonder if that would end in tears.  TCP/IP isn’t ideal for gamedev IMO.  Flash doesn’t support UDP as-of-yet.

This isn’t the first time Galcon has reared it’s head from within the browser window.  (See my earlier blog posts …)

I haven’t decided exactly what I’m going to do with this once it’s completed.  Probably a few things.  Throwing it on facebook is an obvious one.  Throwing it on galcon.com is another one.  Maybe mixing it with something like The Maze of Madness is another one.  Or maybe something else!

One idea that I have that would be really cool would be if the tinypy vm were ported to ActionScript using Alchemy* .. and then somehow people would be able to script Galcon on the web and share it with their friends..

*I don’t know if you caught that .. but I think my weekend just got booked :)

From python to C++

Saturday, February 14th, 2009

I think I wrote an article a few months ago comparing C and python.  I’m doing some new iPhone games now, and this time I’m using C++.  I found not having classes was getting to be too painful for me, so I’m trying out C++.  Here are a few things I’ve observed:

(As a side note – I’m writing my games /almost/ the same way I’d write them in python.  So if you’ve seen my game code, I’m doing almost the same stuff, except in C++.)

  • As usual, not having memory management is a bit of bother.  Fortunately, I’ve found there are only a few places where I actually need it.  The main thing I had to do was write some basic reference counting code for my state engine class.
  • I’m using structs instead of classes, since I have no use for private variables or methods.
  • Having separate .h and .cpp files is a drag.  But them’s the breaks .. It sure would be swell if C++ was a wee bit smarter about that.
  • For my in-game objects, I just define a single struct that has all the possible variables I need.  This is pretty much how I did things in python anyways.  I’ve never been a big fan of using much inheritance.
  • For writing my GUI classes, in python I was able to get lots of magic into them.  In C++ it isn’t so easy to get magic, so I’m doing without most of it.  It seems that most of the magic was gold-plating anyways.
  • Having written all this code in python before, getting clean C++ code seems pretty natural.  I know what I WANT my code to look like, so I try to get my C++ to be as close as possible to that. 
I think the bottom line of this post, is that my code is coming out pretty pythonic.  Maybe?

Running OpenGL Apps on a Linux guest in VMWare Fusion

Monday, January 26th, 2009

Here’s my “tip of the day” for running OpenGL Apps on a Linux / Ubuntu guest in VMWare Fusion.  The problem is that while running VMWare Fusion on OSX, your guest Ubuntu system doesn’t have 3D acceleration.  Bummer!  I really like doing my game-dev under linux .. so after a bit of searching I found this neat trick:

1. Open a Terminal in OSX (host OS)

2. ssh -Y ip.address.of.guest.OS
(You can find out the IP address of your guest OS via ifconfig.)

3. run the game you are working on 

4. OSX pops up a window with your game running at full speed!

Via that SSH session I can run my games under linux, but the OpenGL stuff is forwarded to my OSX host, which renders it at full speed.  This is called X11 forwarding, which I had heard of before, but I didn’t know it included OpenGL :)

I’d love it if Fusion included 3D acceleration of linux-based Guest OSs, but in the meantime, this will get me by.  One thing to note, this isn’t perfect.  I tried running tux racer, and although it seemed to run at full speed, the view wasn’t centered and so I only saw the top left 25% of the game.

-Phil

Stuff-n-maintenance-n-stuff stuff stuff ..

Wednesday, November 26th, 2008

So this past week or so was pretty wild. I was doing all “behind the scenes” stuff mainly. Sometimes these sorts of things are kind of weird to do, because the main goal is to do them in such a way that nobody really notices that I did them (so the point of this blog post is to point out the invisible so I can FEEL like I accomplished something in the last two weeks) … Anyway, they (supposedly) had to get done so that everything can keep moving along without collapsing.

  • Fixing up the themes on galcon.com so that all the pages actually use the same header/footer and everything. I also restyled the whole site so that all the pages use the same style.css file. (Previously each part of galcon.com had its own stylesheet. Weirdness.)
  • Moved to using a real mailing list (it took me forever to decide!) But in the end yourmailinglistprovider.com seemed to be the ticket. This is a pretty big step. Previously I was running some script which took a very long time to send out the newsletter and made me very nervous.
  • Updated my game server with init.d scripts so that should my server get rebooted, the game servers will automagically restart. Previously, well, if the server got rebooted, no games would come up.
  • I also migrated www.imitationpickles.org/galcon/ to point to www.galcon.com .. So now all the “classic” Galcon customers get to see my new swell site. This is also good for search engine stuff, so galcon.com has a nice position now.
  • While I was at it, I set up google mail for galcon.com .. So now I can e-mail in style!
  • Upgraded the maze so that each user’s “save state” is a single database record. Previously I saved the full history of a user’s game, so a single user could have hundreds of records if they were wandering around. This table got to around 362,525 records and it was making those pages go pretty slow! With a single record per user, I’ve only got 1371 records in the table and things are nice and fast again. (BTW – Maze 2.0 is up, you can create your own separate adventure mazes now!)

On a more “in your face note” I did add in a games section to galcon.com. I’m sort of excited about this, because it makes it look like I’ve actually made more than one game :) More importantly, it makes it really easy for me to put up a quick page for small games. I’m always making new mini-games for game-dev compos or whatever that don’t necessarily deserve their own “special custom website” but I still want people to be able to get at them. This will make that possible. It also makes it easy for me to link to some of my game-dev friend’s games.

Laters!
-Phil

The Maze of MADNESS!!

Tuesday, November 11th, 2008

Hey, so I just put up a new game on my website called “The Maze of MADNESS.”  Check it out.

The interesting thing about it is that I didn’t create any of the game.  I just created a web based interface for people to create this adventure game on.  I made it for a 48 hour contest this past weekend, and the other contest people have already created 45 rooms, 40 new items, and 152 actions.

It should be interesting to see how long the game lasts before it caves under the weight of itself.  I’m quite interested in trying out user-content games.  So if this even marginally works out, there is a good chance I’ll be doing more in the future.

On another tech note, I used AS3 for the pixel art editor in the game.  I decided on this instead of haxe, because it seemed there was a lot more random bits of information on the internet about AS3.  I managed to get it to work without using a .mxml file.  The tutorial I followed was this.  I also got lots of random snippets from the internet.

-Phil

PAX’08 Pics

Thursday, September 4th, 2008

Hey, I attended PAX’08. It was a pretty crazy ride! I gotta say, if I go again, I’m going to make sure I get more than 4 hours of sleep per night though :)

Some of the highlights of the trip were:

  • Stacking cans for the Brawndo booth
  • taking pictures of costumery
  • Listening to the musicians panel
  • meeting Mike and Sol of hamumu.com fame
  • watching and hearing some gameboy street musicians

I’ll let you work out which pics go with which highlight.

Repeat: I am going to be at PAX!

Wednesday, August 27th, 2008

Yeah, this is basically a repeat of last week’s message.  But I am going to be at PAX.  I am going to be wearing Galcon t-shirts the whole time.  I will be there Friday, Saturday, and Sunday.  I will be helping out at the Brawndo booth from time to time.  I will probably be hanging out with the Garage Games folks a bit too.  If you can’t find me, ask one of those booths :)

See you at PAX’08 !!


Galcon   Watermelons   Dynamite   The Hairy Chestival
All content of imitation pickles (c) 1999-2008 - Phil Hassey  "we care"