This is a tiny game we made more than 2 years ago as part of Perplex City. Many people are unaware that the tilt-sensors inside the iPhone are also available (or something very similar) inside every apple laptop (all Macbooks/most Powerbooks/some iBooks); we made a game that made use of this.
Unfortunately, this feature of the laptops is undocumented, and so Apple has changed the specs a few times, so the original files no longer work. With a small bit of mangling, I’ve fixed the very simple input script, and it all works fine on my Macbook Air.
Links:
- Info on how this tiny minigame fitted-in to the overall Perplex City game
- (mirror of) The original in-game website that holds the original download files (note: Mindcandy is hosting this for now, but I don’t know for how much longer they’ll keep this stuff up)
- UPDATED version (0.34) of the hardware driver that you need on Macbook / Macbook Air to make this work (current homepage for that software is here)
Instructions:
- Download the file “maze-inertial.zip” from the second link above, and unzip it
- Download the AMStracker dmg from the third link above, and open it, and put all the contents in the Maze subdirectory of wherever you just unzipped to; it will want to overwrite a file – say “yes”
- Make a new file in that directory using a text editor, call it e.g. “start.pl”, and copy/paste the lines below (bottom of this post)
- Run the file start.pl; you might be able to double click on it, you might have to go to the directory in Terminal and type “./start.pl” to make it run
- Wait for the java app to load, you should see a ball on a chequered background
- Pick up your laptop and start tilting it to make the ball roll around
- NB: the lack of graphics was deliberate! the idea was to close your laptop lid and play just using the sound (this requires you to disable OS X’s auto-suspend feature though)
- You will get cryptic messages as you complete levels; there are hundreds of levels, and no save feature (!). Read the website links above to find out why…
PS: if you read the source and think “ugh, what a brutal and inelegant way to make this work” then congratulations – this whole game was done start to finish in something like 2 weeks (part-time; if we’d all been working full-time on it it was probably more like 4 days). We had to cut a lot of corners…
Source of file start.pl – copy/paste everything below this line
#!/usr/bin/perl -w
use IO::Socket::INET;
use Getopt::Long;$| = 1;
my $flipx = 0;my $flipy = 0;my $port = 5399;my $ams = “./amstracker”;my $maze = “./maze.jar”;my $scale = 5;
GetOptions(“flipx” => \$flipx, # –flipx flip x axis
“flipy” => \$flipy, # –flipy flip y axis
“port=i” => \$port, # –port 5399 port to talk to
“ams=s” => \$ams, # –ams ./amstracker location of amstracker
“maze=s” => \$maze, # –maze ./tiltmaze.jar location of tiltmaze.jar
“scale=f” => \$scale); # –scale 3.0 tilt scaling factor# Needs AMStracker v0.34 or above, currently at:
# http://www.osxbook.com/software/sms/amstracker/print STDERR “Starting amstracker ($ams)…\n”;
open AMS, “$ams -s -u 0.1 |” or die “Can’t start amstracker: $!”;
my $line =;
print “$line”;if ($line =~ /software/) {print STDERR “No tilt sensor found.\n”;exit 1;}
print STDERR “Starting maze ($maze)…\n”;
system “open $maze”;print STDERR “Connecting to game…”;
my $sock;my $count = 0;while (1){
$sock = IO::Socket::INET->new(PeerAddr => ‘localhost’,PeerPort => $port,Proto => ‘tcp’);
last if defined $sock; # success!
$count++;
if ($count > 20){die “Can’t connect to game: $!”; }
print “.”;sleep 2;}
print “\n”;while (
) {
my ($x,$y,$z) = split;
next unless $x =~ /\d+/;
$x = -$x unless $flipx; $z = -$z if $flipy; $x = int($x * $scale); $z = int($z * $scale);
last unless $sock->print(“[$x,$z]”); }