Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Curses (Question for Toady)  (Read 1355 times)

scjohnno

  • Bay Watcher
    • View Profile
Curses (Question for Toady)
« on: March 09, 2007, 12:07:00 am »

Toady, I was just wondering what you thought of Curses, the library. I've been thinking about writing my own Roguelike, and the main thing that's been stopping me is deciding what route I want to take in terms of graphics library.

I have my own library (based on SDL), but it's probably too bloated for an ASCII game, so I've been thinking about using Curses. I know you switched from it a while back, but I was hoping your experience with it could shed some light on its pros and cons. Would it be a good choice, or should I go the OpenGL-blitted sprites route from the get-go?

On a related note, I hope you're feeling better now. Dwarf Fortress is a masterpiece as always, and as I'll hopefully be coming into a bit of money soon, I'll be sure to send some your way.

Logged

Toady One

  • The Great
    • View Profile
    • http://www.bay12games.com
Re: Curses (Question for Toady)
« Reply #1 on: March 09, 2007, 12:24:00 am »

I'm sort of feeling better.  The bug has remained in my sinuses for five days now.  It is unwelcome.  It should go.

So, curses.  The display in PDCurses was great (assuming you are using C rather than something like pycurses).  The main issue I had with curses was handling input.  When I used it, PDCurses used something like getch(), and that limits what you can do with other keys it doesn't recognize, or at least it limited me because I couldn't figure out a way around it.  If you feel comfortable with something like your SDL library and events/message loops etc, it really wouldn't take that long to mimic curses in that setting, and the overhead is negligible (unless you are trying to support certain systems).  On the other hand, if your input is going to be limited to things like upper and lower case letters, curses will be easier to handle, and you get started like right now.  It's very quick to get used to and apply.

Let us know how it goes.  The more games we have, the happier everyone here and everywhere else will be.

Logged
The Toad, a Natural Resource:  Preserve yours today!

scjohnno

  • Bay Watcher
    • View Profile
Re: Curses (Question for Toady)
« Reply #2 on: March 09, 2007, 12:44:00 am »

It's been my experience that these bugs are persistent bastards. Five days is a long time to be feeling terrible though; with luck you'll be over it soon.

And yes, I'll almost definitely be using C/C++, so I imagine rigging SDL with Curses purely as an input handler wouldn't be terribly difficult. I've never used getch() before (started myself on C++ before I tried plain old C), but I imagine you're referring to things like the arrow and F1...12 keys, which I would like to have support for.

I'll have to grab PDCurses then and fiddle around with it. At first I considered forking off from something like Angband, but for some reason I like writing things from scratch.

As for my (proposed/imagined/infantile) game: as far as setting goes, I was thinking of something along the lines of Fallout, if you've ever played it. I look left and right and see plenty of high fantasy Roguelikes, but no post-apocalyptic ones. Thanks for the help, and if my game ever manifests itself in a playable form, consider yourself somewhat of an inspiration.  ;)

Logged

Gakidou

  • Bay Watcher
    • View Profile
Re: Curses (Question for Toady)
« Reply #3 on: March 09, 2007, 01:53:00 am »

Toady, what kind of keys could you not get? I haven't played around with Curses too much, but I think that you can get most keys with getch() if you run:
code:

keypad(stdscr,1);


You can, at the very least, get the F# and arrow keys by using that.

A bigger problem with Curses is that you can't always be sure what kind of capabilities your users' terminal will have; you can't always rely on color, extended ASCII characters, and so on. With SDL or GL, any system that is able to run the game will handle things pretty much the same way. And it will be easier to add tilesets later if you decide to with a game that was built on top of SDL or GL in the first place.

(Of course, Curses gives you some nice options, like playing the game on computers without graphical displays, or over ssh or telnet.)

I think SDL is a bit more portable than GL, and I doubt that GL's focus on 3d functions is needed at all for an ASCII game. If you later decide you need GL for something (although I can't imagine for what in a roguelike), it is very easy to get GL to render onto an SDL surface.

(DISCLAIMER: I have never actually succeeded in making a roguelike or any other game, although I have messed around with Curses, SDL and GL a bit.)

Logged

Grue

  • Bay Watcher
  • Fucked Up
    • View Profile
Re: Curses (Question for Toady)
« Reply #4 on: March 09, 2007, 05:05:00 am »

I think SDL actually has more problems with keypad and stuff than PDCurses (judging by threads on rec.games.roguelike.development, never used SDL myself).
Logged

axus

  • Bay Watcher
  • Axe Murderer
    • View Profile
Re: Curses (Question for Toady)
« Reply #5 on: March 09, 2007, 08:38:00 am »

I had this exact same thing, it took over a week for it to finally go, and half my sinus is still stuffy.  One of the few cases antibiotics at the start would have been a good thing
 :(

quote:
Originally posted by Toady One:
<STRONG>I'm sort of feeling better.  The bug has remained in my sinuses for five days now.  It is unwelcome.  It should go.
</STRONG>
Logged