[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Roguelike project?

Tim Mcd

10/30/2008 6:17:00 PM

Anyone interested in a Roguelike game written in Ruby/Ncurses project?
Email me/post here!

(tmcdowell@gmail.com)
--
Posted via http://www.ruby-....

40 Answers

Matthew Moss

10/30/2008 6:42:00 PM

0

> Anyone interested in a Roguelike game written in Ruby/Ncurses project?
> Email me/post here!

Interested in playing? Testing? Developing?
I've considered writing one at some point, but I've yet to make time
and figure out ncurses.


Tim Mcd

10/30/2008 7:24:00 PM

0

Matthew Moss wrote:
>> Anyone interested in a Roguelike game written in Ruby/Ncurses project?
>> Email me/post here!
>
> Interested in playing? Testing? Developing?
> I've considered writing one at some point, but I've yet to make time
> and figure out ncurses.

Sorry: That would be interested in developing. I am novice-intermediate
when it comes to Ruby code, but I thought it would be fun to create a
Ruby roguelike.
--
Posted via http://www.ruby-....

Nit Khair

10/31/2008 4:26:00 AM

0

Tim Mcd wrote:
> Matthew Moss wrote:
>>> Anyone interested in a Roguelike game written in Ruby/Ncurses project?
>>> Email me/post here!
>>
>> Interested in playing? Testing? Developing?
>> I've considered writing one at some point, but I've yet to make time
>> and figure out ncurses.
>
> Sorry: That would be interested in developing. I am novice-intermediate
> when it comes to Ruby code, but I thought it would be fun to create a
> Ruby roguelike.

It would be fun, certainly. Recently, i wrote my first ncurses program,
a snakes game and it was great fun. Since then, I am working on a much
larger ncurses project - would have loved to work with you.

ncurses is pretty easy and fun - one problem i occasionally face is
getting the refreshes correct - otherwise its cool. Remember to wrap
your windows in panels, and its better not to use stdscr if you intend
having multiple pages/windows/levels - use panels.
--
Posted via http://www.ruby-....

Tim Mcd

10/31/2008 2:27:00 PM

0

Nit Khair wrote:
> Tim Mcd wrote:
>> Matthew Moss wrote:
>>>> Anyone interested in a Roguelike game written in Ruby/Ncurses project?
>>>> Email me/post here!
>>>
>>> Interested in playing? Testing? Developing?
>>> I've considered writing one at some point, but I've yet to make time
>>> and figure out ncurses.
>>
>> Sorry: That would be interested in developing. I am novice-intermediate
>> when it comes to Ruby code, but I thought it would be fun to create a
>> Ruby roguelike.
>
> It would be fun, certainly. Recently, i wrote my first ncurses program,
> a snakes game and it was great fun. Since then, I am working on a much
> larger ncurses project - would have loved to work with you.
>
> ncurses is pretty easy and fun - one problem i occasionally face is
> getting the refreshes correct - otherwise its cool. Remember to wrap
> your windows in panels, and its better not to use stdscr if you intend
> having multiple pages/windows/levels - use panels.

Yeah, it's tough finding proper ruby documentation on Ncurses. I've just
been using the Ncurses book linked at the ruby-ncurses site. That is
written for C coding tho, so it's a bit hard porting it over. Panels?
Enlighten me please!
--
Posted via http://www.ruby-....

Nit Khair

10/31/2008 4:09:00 PM

0

Tim Mcd wrote:
> Nit Khair wrote:
>> Tim Mcd wrote:
>>> Matthew Moss wrote:
> Yeah, it's tough finding proper ruby documentation on Ncurses. I've just
> been using the Ncurses book linked at the ruby-ncurses site. That is
> written for C coding tho, so it's a bit hard porting it over. Panels?
> Enlighten me please!
1. The only documentation on ncurses-ruby is the README file the author
gives.
2. The only documentation on ncurses is a large file with sample C
program by one
Pradeep Padala which comes up on searching google. It is pretty
comprehensive but mainly examples - no real-world stuff.
3. Usually, I just grep thru the source, esp form_wrap.c and ncurses.rb.
4. Another useful source is "man" (if you are using *nix). This can give
you
explanations of methods. I use it quite a bit.

Forgive my cut-pasting from "man panel" - will explain after:
----
Panels are curses(3X) windows with the added feature of depth.
Panel functions allow the use of stacked windows and ensure the
proper portions of each window and the curses stdscr window are hidden
or displayed when panels are added, moved, modified or removed. The set
of currently visible panels is the stack of panels. The stdscr
window is beneath all panels, and is not considered part of the stack.

A window is associated with every panel. The panel routines
enable you to create, move, hide, and show panels, as well as position
a panel at any desired location in the stack.

Panel routines are a functional layer added to curses(3X),
make only high-level curses calls, and work anywhere terminfo curses
does.
----

Basically, in my app i have a main menu, which calls various programs
and when you return from any program, you come back to the main menu -
its precisely like "alpine". So when Menu calls Contracts, and you
return from Contracts, you want your Menu screen like it was, not with
stuff from Contracts all over. This is best done using panels. A window
gives you a panel. When you remove the panel whats below is
automatically there without your repainting etc.

Pretty neat and efficient compared to many apps I have seen recently
that used windows or stdscr and had to do all this jugglery themselves.
Here's some snips of code to make it clear:

my_form_win = WINDOW.new(rows_to_show,0,startrow ,0)
my_panel = my_form_win.new_panel
Ncurses::Panel.update_panels

In line 2, I create a panel from my window. Pls note that these will go
into instance variables so the caller can destroy them later - V IMP.

Finally, I have a method "free_all" which frees the fields etc. It also
has:

Ncurses::Panel.del_panel(@panel) if !@panel.nil?
@window.delwin if !@window.nil?

The rest of the time, you actually can forget you created a panel, and
just keep writing on the window.

====
Now in your game, i can guess when you jump levels you really don't want
the user to come back (like a stack). However, you could be popping up a
help screen, or a screen where the user can select weapons ... and then
come back to the main screen. So its best to wrap those windows in
panels as shown above. The freeing can be put/called in an ensure block.

Also, you may have some side or bottom panels showing scores, weapons,
time, lives etc. These are best implemented by putting a panel at the
bottom or side.

The snakes game i made was based on the sample code from the Pickaxe and
used only stdscr -- quite ugly if you ask me and it was only one screen
anyway. However, some folks have actually managed to build an entire app
using stdscr only ("sup", iirc). "raggle" otoh uses windows but not
panels, so he has to implement some kind of global array of windows, so
he can pop and push. I don't know their experience in implementing it -
was it clean or did they lose a lot of hair. i can tell you panels
*are* a clean way to implement layered windows.
--
Posted via http://www.ruby-....

Michael Fellinger

10/31/2008 4:32:00 PM

0

On Fri, Oct 31, 2008 at 3:42 AM, Matthew Moss <matt@moss.name> wrote:
>> Anyone interested in a Roguelike game written in Ruby/Ncurses project?
>> Email me/post here!
>
> Interested in playing? Testing? Developing?
> I've considered writing one at some point, but I've yet to make time and
> figure out ncurses.

http://github.com/m...

esp:
http://github.com/m.../tree/master/lib/ver/keyboard.rb
http://github.com/m.../tree/master/lib/ver/window.rb
http://github.com/m.../tree/master/lib/ver/ncurses.rb

I wrote a rougelike in ruby+ncurses, but the source isn't online
anymore, i can send you if you like :)

^ manveru

Nit Khair

10/31/2008 4:46:00 PM

0

Michael Fellinger wrote:

>
> http://github.com/m...
>
> esp:
> http://github.com/m.../tree/master/lib/ver/keyboard.rb
> http://github.com/m.../tree/master/lib/ver/window.rb
> http://github.com/m.../tree/master/lib/ver/ncurses.rb
>
> I wrote a rougelike in ruby+ncurses, but the source isn't online
> anymore, i can send you if you like :)
>
> ^ manveru

Thanks manveru - could you tell me what keyboard.rb does in a nutshell.
I simply bind keys using the "?\C-a" kind of notation to symbols or
procs.

I read your comment in window.rb of the bug that doesnt let you subclass
window. I had a long discussion on this here, i was trying to subclass
Form, iirc. Finally, someone said that the constructor was "shadowed",
so one cannot make another one (I cannot recall the exact words), or
maybe it was private. So i too had wrapped and delegated like you have.

--
Posted via http://www.ruby-....

Michael Fellinger

10/31/2008 5:51:00 PM

0

On Sat, Nov 1, 2008 at 1:46 AM, Nit Khair <sentinel.2001@gmx.com> wrote:
> Michael Fellinger wrote:
>
>>
>> http://github.com/m...
>>
>> esp:
>> http://github.com/m.../tree/master/lib/ver/keyboard.rb
>> http://github.com/m.../tree/master/lib/ver/window.rb
>> http://github.com/m.../tree/master/lib/ver/ncurses.rb
>>
>> I wrote a rougelike in ruby+ncurses, but the source isn't online
>> anymore, i can send you if you like :)
>>
>> ^ manveru
>
> Thanks manveru - could you tell me what keyboard.rb does in a nutshell.
> I simply bind keys using the "?\C-a" kind of notation to symbols or
> procs.

It allows me to make any object the receiver of keystrokes, simply by doing
Keyboard.focus = something
the object has to respond to the #key method and take the name of the
key (as string) as argument.
So, in my code, once i show or hide a window/pane/view that is
interactive, i simply let it take over the focus of Keyboard and don't
have separate dispatching or some kind of main loop.

keybindings are handled by
http://github.com/m.../tree/master/lib/ver/keymap.rb
but that's a lot more complicated, building a tree structure and
descends down into it until a matching keybinding is found. that
allows emacs-like keybindings like [C-x C-c].

> I read your comment in window.rb of the bug that doesnt let you subclass
> window. I had a long discussion on this here, i was trying to subclass
> Form, iirc. Finally, someone said that the constructor was "shadowed",
> so one cannot make another one (I cannot recall the exact words), or
> maybe it was private. So i too had wrapped and delegated like you have.

Yeah, it was quite a pain... ncurses.rb already does method_missing,
and then this wrapping introduces another layer, not very nice at all.

Nit Khair

10/31/2008 6:21:00 PM

0

Michael Fellinger wrote:
> http://github.com/manveru/ver/tree/master/lib/ver...
> but that's a lot more complicated, building a tree structure and
> descends down into it until a matching keybinding is found. that
> allows emacs-like keybindings like [C-x C-c].
>
I am interested in doing key mappings like Vi and emacs. Did look
through the code a bit

Michal Suchanek

11/1/2008 3:54:00 PM

0

On 30/10/2008, Tim Mcd <tmcdowell@gmail.com> wrote:
> Anyone interested in a Roguelike game written in Ruby/Ncurses project?
> Email me/post here!
>
> (tmcdowell@gmail.com)
>
There's one downside to ncurses in Ruby - they do not support
multibyte characters. So your internationalization possibilities are
limited, and so are things like PC names.

In ruby 1.9 you could possibly set LC_CTYPE and use ncursesw but you
would still have to hack the extension.

I have posted a patch for 1.8 some time ago but that would likely
break stuff in Time or the like because ruby 1.8 does not play well
with setting locale.

Thanks

Michal