Saturday, February 14, 2009

Playing Spelunky in Ubuntu with Wine and Compiz

Spelunky is an awesomely addictive indie game, which I highly recommend checking out. It is sort of like Mario meets Nethack. As a side-scrolling, cave-adventuring character, you must venture deeper into the cave, defeating enemies, saving damsels, and collecting money and other fun items. A unique aspect that it takes from roguelike games is that there is really no concept of saving; each "play" typically lasts only a few minutes (much less at first), but you can get shortcuts to different zones to skip ahead once you get better. Also like Nethack, it is a surprisingly rich, detailed, and polished game for all its simplicity.



The unfortunate thing about Spelunky is that only runs in Windows. My initial attempts at running it in Wine proved unsuccessful, but after a while (and playing it on a friend's machine which gave me enough to interest to keep trying), I figured out just the right combination of tricks to make it quite playable in Ubuntu. Here's what you need to do:

  • download Spelunky, make sure you are using compiz, and install wine and compizconfig-settings-manager.
  • set wine to run in an emulated desktop window. To do this, run "winecfg", go to the Graphics tab, and check "Emulate a virtual desktop". The size isn't really important; I use 800x600.
  • extract Spelunky and create a file (if it doesn't exist) called "settings.cfg" and put these contents in it:

1
1
0
0
1
15
15


This is the default settings, tweaked to the only setting that allows it to run in Wine. You can't configure it normally since it only works in this way, so I had to have my friend change settings on his Windows box and watch what numbers changed. Thankfully for you I have done the hard work.

  • Run Spelunky! Double-clicking it should probably work, but if you want it to play nicely with other applications using audio at the same time, force it to use pulseaudio by running "padsp wine spelunky_0_99_5.exe". It should show a configuration window, but you can't really interact with it. Just click in it and hit enter.
  • Now you can play Spelunky, but it is at a 1x zoom level, the only one that plays nicely with Wine. This isn't very usable! Run "ccsm" (System -> Preferences -> CompizConfig Settings Manager") and enable "Enhanced Zoom Desktop" from the second group, "Accessibility". Now you can zoom in by holding your Super key (Windows/Apple/Ubuntu key) and scrolling your mouse wheel in or out. Using this technique you can make Spelunky effectively full screen and if you sit it right in the corner, you will forget you are doing anything strange within a few minutes.

Okay, that's it! Some initial setup is involved but once you've gotten it to work the first time, all you need to do in the future is run Spelunky and zoom in. As for help playing Spelunky, navigate over to the tutorial area once in the game, and you'll learn everything you need to know! Let me know if it works for you and how much you love Spelunky (it's worth it, I promise!) and don't forget to check out more fun indie games on tigdb.

18 comments:

Anonymous said...

Please contribute this information to the WineHQ AppDB!

Anonymous said...

You should try Cave Story:
http://www.miraigamer.net/cavestory/

It's the best platform game so far.

It's not FLOSS, but there's a Linux port that actually works.

Anonymous said...

Just another reminder to contribute this fix to http://appdb.winehq.org ^.^

And thanks for the link! Now I'm browsing through all their Linux games.

Anonymous said...

Hehehe it's like Fred for ZX Sinclair in the mid-80s!

http://www.mobygames.com/game/zx-spectrum/fred

http://www.mobygames.com/game/zx-spectrum/fred/screenshots

Anonymous said...

To make the size issue better, set the size to fit your monitor, then in appearance change the Desktop to black

Also disable 'Allow Window Manager to decorate windows' but let it be controlled

Now in compiz enable the 'Legacy fullscreen support' and run it

Widescreen users keep reading...
Make the wine virtual desktop have a 4:3(w:h) ratio, do the same steps above, then make a black image(call it ~/black.png), in the decoration plugin, change 'all' to '(all) & !(title=Default - Wine desktop)' in the shadows option, in the window rules plugin add a rule for 'title=Default - Wine desktop' and keep the y 0, but put ('width of monitor'-'width of virtual desktop')/2 as the x value

now when running the app use the following script

#!/bin/bash
IMG=`gconftool-2 -g /desktop/gnome/background/picture_filename`
gconftool-2 -s /desktop/gnome/background/picture_filename --type string $HOME/black.png
CMD TO START APP
gconftool-2 -s /desktop/gnome/background/picture_filename --type string `echo $IMG | sed 's| |\ |g'`

curious.jp said...

Michael,
Which build of Wine are you using? I only get music and severe graphical distortion (as well as graphics inverted on the y axis to boot).

Cheers,
Bryn

Michael said...

Hi bryn,

I have been using Wine from the PPA: http://launchpad.net/~ubuntu-wine/+archive/ppa

Currently this is 1.1.17 which is an improvement over 1.0.1 in Ubuntu by default.

Luca said...

Doesn't work for me. i tried what you said. I have Ubuntu 9.04 on a P4 with nvidia 8400 GS
i wonder why...
oh, and i have wine 1.01

Luca said...

oh whoops i forgot to say what it does :P
well the window opens and i get to the configurations screen (which btw you can interact with you just have to click about 100-150 pixels below the actual button). i hit ok and it just closes.

Luca said...

oh never mind upgraded to wine 1.1.20 and it works fine now. thanks!

Anonymous said...

Thank you so much for posting this...now I don't have to borrow my wife's laptop to play Spelunky!

cyberix said...
This comment has been removed by the author.
cyberix said...

I can't get the game running by following this guide, I get the following error instead.

err:dmloader:IDirectMusicLoaderImpl_
IDirectMusicLoader_SetObject : could
not attach stream to file

relet said...

I get either of the following errors using spelunky 1.0 and wine 1.0.1:

When using the new settings file:
X Error of failed request: GLXBadDrawable
Major opcode of failed request: 128 (GLX)
Minor opcode of failed request: 11 (X_GLXSwapBuffers)
Serial number of failed request: 3528
Current serial number in output stream: 3530

When using the old settings file (a window opens, stays black, and repeats the message on console):

fixme:d3d:IWineD3DSwapChainImpl_Present Unhandled present options 0x32fcbc/0x32fccc

I'll try a newer version of wine next.

Anonymous said...

I used this guide and I was able to play the game, but it goes really slow and it takes forever to do anything. is there any way to fix this?

Michael said...

Relet, make sure to be using a newer version of wine from the PPA I mentioned in comment #7.

As far as slowness, I only tend to experience slowness if running another Wine app at the same time, but it is otherwise quite smooth, so unfortunately I have no other advice besides minimizing other tasks using the CPU.

jcwilk said...

Thank you!!!!

cyberix said...

This now works for me with Ubuntu Karmic and my ATI video card using latest proprietary driver. Setting the zoom level to a bigger one worked as well, but for some reason the window is bigger than the picture.

I did not try the compiz trick as the size is already rather good and I don't want to mess it up.