Building Wooga’s Pocket Island in Windows

Last week, social/mobile game developer Wooga released the code of one of their HTML5 games as open source.

Unfortunately for Windows users, the whole application was built in a Mac. Because of this, a lot of Unix-y stuff they put in won’t work even if you install minGW e.g. #! executables and egrep/printf.

Normally, I’d just suggest a Windows user to just install Linux on a virtual machine but that would be too easy.

Taking these problems instead as a challenge, I tried to get around them by playing around with the code. After tweaking tasks/build.rake for a bit, somehow things just worked. Yay!

So for those interested, here’s how to build the game on Windows 7 (haven’t tried it on XP but it should work):

  • Install Ruby + DevKit + msysgit. Or just get RailsInstaller to install all of that for you.
  • Install Node.js
  • Add msysgit’s minGW and Node.js to your PATH. e.g ;C:\RailsInstaller\Git\bin;C:\Program Files\nodejs\.
  • Clone my fork and use the win-kludge branch:

    git clone git://github.com/bryanbibat/Pocket-Island.git
    cd Pocket-Island
    git checkout win-kludge
    
    
  • Download and extract the images to the images folder.
  • Follow the installation normally.

    npm install -g less jslint
    gem install spritopia
    rake
    
    
  • (optional) Start the simple static server then open http://localhost:4567/ipad.html.

    gem install sinatra
    ruby -rubygems server.rb
    
    
  • (optional) Install Java and run the rake all.

    rake all
    cd build
    copy ..\server.rb .
    ruby -rubygems server.rb
    
    

Quick Look at Notepad++ as a Windows Ruby/Rails Editor

Last year, I looked at the better Ruby/Rails editors in Windows. With Notepad++ version 6 released recently, I decided to check whether it’s good enough to be an alternative to those two.

Screenshot again with my depressing lotto app:

notepad++

Overall, it’s ok, especially with the Explorer plugin. However, there are still a bunch of stuff I’d nitpick about:

  • Split screen is limited to 2 screens. Which is weird limitation considering both vim and emacs can do an infinite number of them.
  • EOL symbols are ugly and can’t be modified.
  • No Haml support yet.

Free Windows Ruby/Rails Editors: Redcar and Sublime Text 2

Last Saturday was the third time this year I’ve gone to a college to talk about Ruby and Rails. And, as expected, the general lack of experience in developing in Windows was the main cause of problems in that whole day event.

The experience wasn’t as bad as what we would have gotten had we conducted it last year, though. Installation used to be the hardest part about Rails on Windows, but thanks to RailsInstaller and RailsFTW, installing Rails on Windows nowadays is practically easier than installing it on Linux or OSX.

However, another problem still remains: the lack of good text editors for Rails on Windows. The vast majority of Ruby developers don’t use IDEs, while their choice of text editors are either OS X exclusive (TextMate) or has a steep learning curve (vim, emacs). On the Windows side, Notepad++ and Crimson Editor both have dismal Rails support.

Fortunately, there are a couple of good upcoming text editing options for Rails developers on Windows.

Redcar is a text editor written in Ruby running on top of JRuby. It’s cross-platform and free but still in alpha. It’s heavily inspired by TextMate, and it even supports some TextMate bundles.

Redcar only requires Ruby and Java. You don’t need to have JRuby; any combination of JRE and Ruby interpreters should work. Running the installation commands

$ gem install redcar
$ redcar install

will download Redcar and JRuby JAR files and install them in your local user directory. After installation, you could run Redcar just as you would run TextMate

$ redcar PATH/TO/APP

Here’s a screenshot of Redcar viewing my depressing lotto app (click to enlarge):

redcar

Sublime Text 2 is another cross-platform text editor. The original Sublime Text isn’t free, but the upcoming release is still free because it’s still in alpha.

Here’s a screenshot (click to enlarge):

sublime text 2 alpha

Sublime Text 2 doesn’t require Ruby or Java, making it more feasible to be shared around in a coding workshop with spotty internet connections (e.g. last Saturday’s event), but its eventual proprietary nature may prevent long-term development use.

EDIT: Quick write-up on Notepad++ v6.0 here.

Rails FTW!

Second Rails post of the week. I don’t really mind since it’s just going to be a small post and would let me reach my 2 post per week quota this early.

Rails for Windows

Remember that post about Ruby on Windows? Well, one thing led to another and PhRUG thought it was a good idea to fork the RubyInstaller to create an installer which includes everything one needs to create a Rails 3 app (Ruby + Rails + SQLite). Being the sneaky guy I am, I decided to create a proof of concept installer by hacking away at the RubyInstaller source code.

Here’s that installer: Rails For (the) Windows, version 0 (edit: latest version is v0.4. grab it here)

With this installer, you can create Rails apps in just a few steps:

  1. Download and run the RailsFTW installer.
  2. Start Command Prompt with Ruby. If you ticked “Add Ruby executables to your PATH” in the install process, you can simply open a normal command prompt

Command Prompt

From there, you can now create the 5-command rails app:

C:\Users\me> rails new blog 
C:\Users\me> cd blog
C:\Users\me\blog> rails generate scaffold entry subject:string content:text
C:\Users\me\blog> rake db:migrate
C:\Users\me\blog> rails server

You may have to unblock ruby in the firewall prompt to make the server work.

Open http://localhost:3000/entries to see your new app.

blog app

We still have a long way to go before we could supercede InstantRails, but this little hack job looks promising. Luis Lavena, a main contributor to RubyInstaller, even approves of this venture. Maybe later we could move on to other Ruby frameworks… Merb FTW or Sinatra FTW anyone?