ncurses and kbhit

G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

I know this isn't quite roguelike related, but at the same time it is,
because this project is a cousin. I'm working on what is basically a
MMO roguelike with a friend, and right now we're in the early stages.
I'm working on the client, and since this is realtime, I need to be
able to listen to the keyboard for a keypress, not wait for one. As
far as I'm seeing, there is nothing like kbhit() in the Windows conio
library. Am I mistaken, or am I just missing it because I have no clue
what the name might be?
Thanks.

Brian
 

Thomas

Distinguished
Jun 27, 2003
449
0
18,780
Archived from groups: rec.games.roguelike.development (More info?)

Um. I dont know what "curses" is as far as i can tell its somekind of
text library but i know that conio.h for c(++) in windowz has a
function

int /*bool*/ kbhit();

that is true when the key is pressed. You can use it like the following
for something like a simple pong game or something (but because you're
on rgrd i doubt thats what you're making ;) ) :

#include <conio.h>

do {
// draw paddel
While(!kbhit()) {

// draw/redraw/move balls

}
//erase paddel
nkey = getch();
// move or something based on the keypress (nkey)
} while (nkey != VKESCAPE)

//exit

i have no clue if you wanted an example but examples seem to make
everything easier dont they! ;)

have fun!

-Thomas
RL: CHAZM
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

I think I forgot to clarify something. I'm using the ncurses library
(5.4) in linux, and I'm looking for something like kbhit either in that
library, or another way to do something like it.
 

Thomas

Distinguished
Jun 27, 2003
449
0
18,780
Archived from groups: rec.games.roguelike.development (More info?)

hmmm, Sorry

never used linux...

Could someone explain to me what curses is. Have i heard of it under
another name or something. This group is the only place i have ever
heard of it. pdcurses, ncurses, *curses. What are all these. Thanks.

Sorry i couldn't be of more help. I have only ever used WinDoWZ :p...

Thanks.

-Thomas
RL: CHAZM
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

I did do a google search, but that's one page I didn't find actually.
And I think it might answer my question. Thanks.
 

Thomas

Distinguished
Jun 27, 2003
449
0
18,780
Archived from groups: rec.games.roguelike.development (More info?)

Great!

Thanks for teh lesson in Curses! I have no experiance with anything but
windows which makes me all the worse a coder for it but i figure i will
learn more about it when i go to college next year....

Wow, PdCurses sounds like a great way to write a program. Portablility
is great!


I am writing my program in windows by using a maximized, and frameless,
black form to immitate a Classic DOS environment and of course using
ASCII to print my map. I will also be using black stylized RichEdits
for the messages and stats bars... I think it should be conveniant and
classic looking. I love ASCII and think that once someone get past how
odd it is to look at a grid of characters it is much easier to
understand.... i understand a g is gnome and a blue G is a Gnome
Warrior or soemthing but having virtually the same 20x20 tile with the
sword a little longer just isn't clear enough for me!

I am writting my RL, as i have said, in windows! YAY.... or not....

But i am concerned about its portablility. I have read many times on
this forum that linux and windows are the best to write RLs for because
many-all RL gamers have linux and many-all humans (sadly) have
windows.... So both work....

I do not want to limit my program to this so i have separated my
program into

1 module for output and input
~25 modules for the game
1 module to communicate between the interface and the engine

is this a good way to make it portable later... say if a friend of mine
learned linux and offered to port CHAZM... would this system make it
~easy~ enough. Is there anything else general i can do to support
future porting?... (remembering that i only know windows right now...)

Thanks!

-Thomas
RL: CHAZM

P.S. What is MMO? is it Multiplayer?... or...
P.P.S Tell me if it is inapropriate to ask a side question... i can
start a new topic ;) Thanks!
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

paladin.rithe@gmail.com <paladin.rithe@gmail.com> schrieb:
> I'm working on what is basically a
> MMO roguelike with a friend, and right now we're in the early stages.

If every time that someone mentions their MMO roguelike I point out the
pitfalls of such an idea, would it be troling?

--
Jim Strathmeyer
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Jim Strathmeyer wrote:
> paladin.rithe@gmail.com <paladin.rithe@gmail.com> schrieb:
>
>>I'm working on what is basically a
>>MMO roguelike with a friend, and right now we're in the early stages.
>
>
> If every time that someone mentions their MMO roguelike I point out the
> pitfalls of such an idea, would it be troling?

Pitfalls? In an MMORL? Bah! ;-)
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

paladin.rithe@gmail.com wrote:
> I know this isn't quite roguelike related, but at the same time it is,
> because this project is a cousin. I'm working on what is basically a
> MMO roguelike with a friend, and right now we're in the early stages.
> I'm working on the client, and since this is realtime, I need to be
> able to listen to the keyboard for a keypress, not wait for one. As
> far as I'm seeing, there is nothing like kbhit() in the Windows conio
> library. Am I mistaken, or am I just missing it because I have no clue
> what the name might be?
> Thanks.

Attempting to make a MMORL is no easy task, and, if you're planning on
using curses for it, I think you'll run into even more trouble. You'd
be better off using SDL, and just blitting bitmaps of ASCII characters
to the screen. With SDL, you'd have a system that is fully intended to
be used realtime, plus powerful keyboard/mouse input, and, with SDL_net,
crossplatform networking code. I have nothing against curses, and have
used it for years, but it's not the best choice for a realtime game.
 

Thomas

Distinguished
Jun 27, 2003
449
0
18,780
Archived from groups: rec.games.roguelike.development (More info?)

> Yeah, you really should start a new topic.

Ok, Thnx Anyway...!

Sometime I will start a topic on portability to adress my personall
issues. Actually i am probably writing awful porting code but doing the
best i can to make it portable inside the framework i am useing
(Borland Builder 4) so i hav e windows forms... I'll bet with a week or
two of evening coding i could port it to linux if i knen how so its not
a disaster..!

-Thomas
RL: CHAZM
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Thomas wrote:
> hmmm, Sorry
>
> never used linux...
>
> Could someone explain to me what curses is. Have i heard of it under
> another name or something. This group is the only place i have ever
> heard of it. pdcurses, ncurses, *curses. What are all these. Thanks.

Curses is a library that allows control of the cursor (hence the
name) in a text-mode window on unix boxes. You can use it to write
text to particular positions on the screen, create colored text,
read the keyboard without blocking, etc.

Ncurses is "new curses", the version of this library that is currently
popular on Linux. It also runs on apple's OS-X. Pdcurses is "public
domain curses", which implements the curses interface in the most
portable style possible, and versions of it also run on windows and
DOS machines and apple OS'es prior to OS-X.

Most RL developers prefer curses to conio because (1) it is faster;
and (2) you can write code using curses that is portable to Apple,
Linux, and Windows, whereas code using conio is windows-only.

Bear
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

paladin.rithe@gmail.com wrote:
> I think I forgot to clarify something. I'm using the ncurses library
> (5.4) in linux, and I'm looking for something like kbhit either in that
> library, or another way to do something like it.
>

I think what you want to read up on are the delay modes for
input. There are three modes available.

"no delay mode" means input doesn't block. You try to read a
keystroke, and if there's not one waiting, you get an ERR
code. You can go off and do something else for a little while,
then try to read a keystroke again. If there is one waiting,
you get the character, or curses keycode for non-character keys.

"half-delay mode" means input blocks for a limited time. When
you try to read a keystroke, it will sit there waiting for a
given length of time (and you can set the length of time).
If there's no keystroke waiting, it times out and gives you
ERR, again. I use half-delay input in my own code.

And full delay mode does just what you'd think. You tell it
read a keystroke, and the call doesn't return until there's
a keystroke to read.

Bear
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

> I think I forgot to clarify something. I'm using the ncurses library
> (5.4) in linux, and I'm looking for something like kbhit either in that
> library, or another way to do something like it.

Google is your friend:
http://www.apmaths.uwo.ca/~xli/ncurses.html#input

--
For email remove _no_spam_