Author Topic: Mech combats roguelike in Ruby  (Read 7765 times)

kipar

  • Rogueliker
  • ***
  • Posts: 105
  • Karma: +0/-0
    • View Profile
    • Email
Mech combats roguelike in Ruby
« on: March 19, 2011, 12:19:37 PM »
The best way of learning a new language is to write a game in it. So it's my first attempt to create something in Ruby and my first attempt to use Curses library.
I've used algorithms from roguebasin page about ruby (permissive FOV and Bresenham). At first I've used recommended at roguebasin library NCurses, but there is no compiled version of this module for ruby 1.9, so i migrated to standard curses module (sadly it doesn't support some keypresses (arrows and numpad without Numlock)).

The link is
http://www.mediafire.com/?19q577h9flfkzbf

You need a Ruby (www.ruby-lang.org) to run it though. I have only tried it in Windows, but it should works in linux too (at least i hope so).

Psiweapon

  • Rogueliker
  • ***
  • Posts: 334
  • Karma: +0/-0
  • Im in ur rougeliekz, pixelling ur tielz!
    • View Profile
    • I Lovemaking Tiles
Re: Mech combats roguelike in Ruby
« Reply #1 on: March 20, 2011, 06:43:33 PM »
Downloading Ruby. Let's give this a shot =)
The invisible hand is a lie, the fiendish dogma of the market cultists. Lest the apostasy grows strong, their blood god will devour each and everyone, pious and infidel alike.

Psiweapon

  • Rogueliker
  • ***
  • Posts: 334
  • Karma: +0/-0
  • Im in ur rougeliekz, pixelling ur tielz!
    • View Profile
    • I Lovemaking Tiles
Re: Mech combats roguelike in Ruby
« Reply #2 on: March 21, 2011, 10:51:20 PM »
Man, I've downloaded Ruby, and ran your game, but my laptop has no keypad =< I'll have to try it on my desktop.

They look nice, though =D Both your game and Ruby.
The invisible hand is a lie, the fiendish dogma of the market cultists. Lest the apostasy grows strong, their blood god will devour each and everyone, pious and infidel alike.

TSMI

  • Rogueliker
  • ***
  • Posts: 65
  • Karma: +0/-0
    • View Profile
    • Email
Re: Mech combats roguelike in Ruby
« Reply #3 on: May 06, 2011, 08:48:06 AM »
Doesn't work on linux (and won't work on mac either probably) because you've used ".\" to specify filepaths. I think the cross-platform way is to use the unix "./", but I'm not sure.

Anyway I edited them all myself. Looks good so far. Two things that would make it a lot more playable would be to display all the keybindings when "?" is pressed, and to have Enter confirm a target for Missles *AND* Lasers.

I dunno if it's worth mentioning but it's quite slow on my (decade old) machine. Ruby is very nice but also very slow - thankfully extending it with C is relatively easy (I added a bit about that to ruby page on roguebasin)

Jolly Roger

  • Newcomer
  • Posts: 48
  • Karma: +0/-0
    • View Profile
Re: Mech combats roguelike in Ruby
« Reply #4 on: May 06, 2011, 09:02:54 AM »
Mech Combat was kipar's side project, to test Ruby and so on. I don't know would he continue development.

kipar

  • Rogueliker
  • ***
  • Posts: 105
  • Karma: +0/-0
    • View Profile
    • Email
Re: Mech combats roguelike in Ruby
« Reply #5 on: May 06, 2011, 11:38:43 AM »
Well, under Ruby 1.9 it will be slightly faster than under Ruby 1.8. But there will be more problems with compatibility (require".\zzz" sholud be replaced with require_relative "zzz"). I'll post updated version tomorrow.

I've found a lot of problems (performance and compatibility) when using curses under ruby so perhaps in my next ruby roguelike I'll use pascal code for gui and use Ruby only for the game logic.

BTW, there are Ruby bindings for FreePascal (for fans of pascal): https://github.com/shikhalev/ppruby

TSMI

  • Rogueliker
  • ***
  • Posts: 65
  • Karma: +0/-0
    • View Profile
    • Email
Re: Mech combats roguelike in Ruby
« Reply #6 on: May 07, 2011, 01:05:04 AM »
I ran it under 1.9, but like I said I am on some seriously ancient hardware.

I am currently attempting an RL in ruby myself, though it makes use of a C "engine" I am concurrently writing. I feel this is a pretty good combination, and it's blazing fast.