December 23, 2007

ruby

Filed under:technology — ryan @ 3:16 am

Ruby is a great language. It’s object-oriented in all the right ways, and the syntax is so simple, it reads like pseudocode.

I’ve been creating my very own roguelike using ruby. It took me a few false starts, but I am now using ruby’s built-in curses bindings. Click here to see the window setup I have decided to stick with. The big blank spot in the upper left is where the actual gameplay map will show up. The bottom is for narration/log of encounters and whatnot. The upper right is for character status, hp/mp/poisoned/hungry, that sort of thing. The lower right is for inventory, and the contents of chests/bags/etc.

For those interested in how I got that stuff to appear, it was as easy as this:

def draw_windows
    @map_win = Window.new(16, 60, 0, 0)
    @map_win.refresh
    
    border_win = Window.new(12, 20, 0, 60)
    border_win.box(0,0)
    border_win << ‘Status’
    border_win.refresh
    @stat_win = Window.new(10, 18, 1, 1)
    @stat_win.refresh
    
    border_win = Window.new(12, 20, 12, 60)
    border_win.box(0,0)
    border_win << ‘Stuff’
    border_win.refresh
    @stuff_win = Window.new(10, 18, 13, 61)
    @stuff_win.refresh
    
    border_win = Window.new(8, 60, 16, 0)
    border_win.box(0,0)
    border_win << ‘Travel Log’
    border_win.refresh
    @log_win = Window.new(6, 58, 17, 1)
    @log_win.scrollok(true)
    @log_win.refresh
end

zero comments so far »

Please won't you leave a comment, below? It'll put some text here!

Copy link for RSS feed for comments on this post or for TrackBack URI

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required)