Etcetera

Monday, May 26th, 2008 | News

This week’s program, Shox, is my 3rd program to utalize the curses library, tho only the second one posted here. I’m trying to stagger when I publish a curses program since they are, in my opinion, cooler but also require a little extra setup. I’ve spent the better part of this morning fiddling with my 4th curses program but I’ve only gotten as figuring out how Curses handles mouse, only to discover that it is a part of curses that varies wildly depending on which version of Curses you’re using. Also, I haven’t found a way to switch off the mouse pointer, which could get distracting in a game. So I guess I’ll go back to keyboard input, but if anyone is curious, and because I had to write this example from scratch as it seems there is no example program I could find, here is a minimum program to read the mouse in PDCurses:

#include <curses.h>

int main () {
int input;
MEVENT mouseinput;

initscr();
raw (); nodelay(stdscr,1); noecho(); curs_set(0); nonl(); keypad(stdscr,1);

mousemask (ALL_MOUSE_EVENTS, NULL);
refresh();
mvprintw (0,30, “Press q to quit”);
do {
input = wgetch(stdscr);
nc_getmouse (&mouseinput); // outside of KEY_MOUSE to read xy
mvprintw (11, 30, ” x = %d y = %d “, mouseinput.x, mouseinput.y);
if (input == KEY_MOUSE) {
mvaddch (mouseinput.y, mouseinput.x, ‘X’);
}
refresh ();
} while (input != ‘q’);
endwin ();
}

Strangely enough it seems in this example that the refresh() is unnecessary (in PDCurses). Take it out and the program still functions. Why? Also, I expected to call getmouse(*) inside the if (input == KEY_MOUSE) statement, but apparent the mouse moving is not a KEY_MOUSE event. Again, not what I expected. (Moving the mouse doesn’t count under ALL_MOUSE_EVENTS?) Also I expected to use getmouse(*) not nc_getmouse(*), because that’s what the NCurses documentation said I’d use, meaning I’d have to re-write any programs that use the mouse for linux, and since I don’t have a linux box (yet) I can’t test it.

Anybody out there want ot donate a linux box to Cymon’s Games?

I’m going to buy Cymon’s Games it’s own domain name here soon. I’m kinda wondering if I want to put a dash between cymons and games in the domain. Dash or no dash, that is the question. I’m a huge fan of webcomics, which is naturally where the question comes from.

I’ve been hindered in writing more programs lately due to my brother-in-law getting me a free subscription to GameTap. Now I’m catching up on games that I’ve always wanted to play like Psychonauts, StarScape and Beyond Good and Evil, but not writing programs like I should. In fact at the moment I don’t have any programs queued up for next week. I’d better get on that.

Thanks to everyone who currently checks in on the site from time to time. I’m wracking my brain to find ways to spread Cymon’s Games, and when all my hard work pays off you can say that you were here when Cymon’s Games started, before the explosion. Buy yourself a tee-shirt so you can say you were here first.

Share and Enjoy:
  • StumbleUpon
  • Google
  • del.icio.us
  • Facebook
  • Digg
  • Slashdot
  • Fark
  • Live
  • Spurl
  • TwitThis
  • E-mail this story to a friend!
  • Reddit

2 Comments to Etcetera

sparkes
June 12, 2008

Cracked the refresh() thing.

The buffer is flushed when you call getch which you are doing through wgetch every loop so the refresh isn’t needed in the example above.

Joe
June 12, 2008

Cool. I wonder if that’s an oddity of PDCurses or if NCurses and/or plain vanilla Curses does the same thing?

One day I’ll get a Linux box set up.

Leave a comment

Support Cymon's Games

Search

Sponsored Links

Cymon's Amazon Store