You can actually do this with another add-on library to ncurses. I believe it is called "panel", as in /usr/include/panel.h and /usr/lib/libpanel.a (-lpanel). I've never tried it, but it looks quite useful.My one complaint about WINDOWS*s is the admonition in the documentation NOT to overlap windows.
I have a few comments about your code:
- I don't know what you think about single-line comments, but the fact is that they aren't part of C89. You might want to consider not using them.
- Your indentation on the whole is pretty good, but there are some hiccups (wfillrect() for example).
- Whenever you see code like this
you should immediately think "ctype.h". It makes things a lot easier.Code:do {ch = getch();} while ((ch != 'q') && (ch != 'Q') && (ch != 'n') && (ch != 'N') && (ch != 'y') && (ch != 'Y')); if ((ch == 'y') || (ch == 'Y')) return 1; Those break statements are unnecessary, of course. And you might be able to implement a fancier version like this . . .Code:switch (r) { case 0 : return x; break; case 1 : return y; break; case 2 : return 3 - x; break; case 3 : return 3 - y; break; }
Just a thought.Code:n = (r % 2 ? y : x); if(r / 2) n = 3 - n;- Please, please never have a variable called 'l' (lowercase L). It's annoying, and stupid, and hard to read, in my opinion.
Also, maybe it's just my ncurses implementation, but I do not see any text at all. (Again, this is a 64-bit Debian GNU/Linux lenny system.)
Something I implemented in my tetris a while back that I always miss in other tetrises is a "shadow" underneath the main block area that shows where the block will land. It helps avoid alignment errors, if you know what I mean. And you could also blink lines before making them disappear if you felt adventurous.
I'd post my tetris3 game, but I think it would be too embarrassing.