bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setscrreg and scrolling


From: Bryan Christ
Subject: Re: setscrreg and scrolling
Date: Wed, 08 Aug 2007 09:55:26 -0500
User-agent: Thunderbird 2.0.0.5 (X11/20070719)

Scrolling is typically quite fast. One good example is the MyMan project (http://www.geocities.com/bsittler/).

2 suggestions...

IMHO, the best way to do scrolling is to create subwins for all the areas of your game that you expect to need scrolling. Next, set the whole subwin to scrollable by simply doing a scrollok(subwin,TRUE). Then use the function wscroll() to either scroll the subwin contents up or down.

You wont be able to do horizontal scrolling with wscroll(). If you need do do that, here's a different approach...

Create a large pad that has the entire contents of your map. Create a window or subwin that the use will actually see (pads are offscreen work areas). Use copywin() to copy the region your pad which you want to display in your window or subwin. When you scroll, you simply adjust the coords that you pass in to copywin(). It gives the illusion of scrolling but really your are just panning your "viewfinder" window across the larger pad.

Bryan

Da-Breegster wrote:
Hi,

I'm working on several games in Perl with an ncurses interface. One is a
roguelike, where I need a constantly centered map view. The other is an
interactive fiction experiment with a scrolling message queue (it displays the
last X messages). For both I have been manually implementing scrolling, which
is fine. The actual drawing is done with addstr, addch, attron, and standend.
(I am using colors) However, on my machine (which is somewhat old, a 500Mhz AMD
K6 box) the lag is too annoying. Rewriting some parts of the code in C helped
slightly and profiling has shown that the main problem is that I'm forced to
completely redraw the window (with rows of messages or a 2D colored grid) every
move. My algorithm obviously isn't optimal, but it's the best I can think of.

What I'd like is to ask for examples of scrolling with ncurses. I've examined
Cdk (both versions) and other high-level interfaces without much success. In
short, how can fast scrolling (with color) be accomplished with ncurses? I've
read the manpage for setscrreg but can't seem to figure out even a basic way to
use this. Could anybody please help?

Thanks,
Breeg

(I would have posted to help-ncurses, but it seemed dead save the spambots.)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]