Re: real-time curses?
- From: Gerry Quinn <gerryq@xxxxxxxxx>
- Date: Wed, 12 Mar 2008 15:44:42 -0000
In article <47d6c339$0$36353$742ec2ed@xxxxxxxxxxxxxx>, bear@xxxxxxxxx
says...
The effect of calling halfdelay is that when Curses is waiting for input
(ie, most of the time) it never waits more than your set interval. After
that interval, your getch or whatever returns ERR. You'll need to
structure the game as a loop around input, but that's probably what you
were doing anyway if you wanted to make a real-time game.
To make a real-time game, I would structure it around a timer. In fact,
I would do that with any game, including my roguelike Lair of the Demon
Ape.
There are two possibilities for input - either act immediately, or cache
it and wait for the timer. Both work.
In Lair, player instructions, such as a mouse-up event signalling the
selection of a player action, are sent immediately to the game logic
class (called 'Level'). It processes the action, and sends messages
back to the rendering class (called LevelWnd); these typically include
'animation' objects such as a sequence of squares the player character
moved through, or text messages to be output.
(LevelWnd also looks after input - obviously it checks that Level is
waiting for player input before accepting any instructions.)
The LevelWnd processes and renders these animations every timer call (25
times per second). A given animation such as a long move might take a
number of frames. When the animation buffer is empty it signals the
Level to proceed - in this case the Level processes pets or monsters in
sequence, until one of them generates one or more animations. The
animations are sent to LevelWnd, and Level does no more until it
receives a 'process next creature' message from LevelWnd (which it will
send as soon as it has finished rendering them).
- Gerry Quinn
--
Lair of the Demon Ape (a coffee-break roguelike)
<http://indigo.ie/~gerryq/lair/lair.htm>
.
- References:
- real-time curses?
- From: copx
- Re: real-time curses?
- From: Ray Dillinger
- real-time curses?
- Prev by Date: Re: real-time curses?
- Next by Date: Re: real-time curses?
- Previous by thread: Re: real-time curses?
- Next by thread: Re: real-time curses?
- Index(es):
Relevant Pages
|