Two loops in different threads const float rFrameRate 200 unsigned cha

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Two loops in different threads
const float rFrameRate = 200.;
...
unsigned char bGameOver = false;
unsigned int iKey;
...
// Keyboard scan + physics loop
while ( ! bGameOver )
{
/* 1. Scan keyboard code. */
if ( kbhit () )
{
if ( (iKey = getch()) != 0 )
{
/*
* 2. Process key combination, setup variable values
* ( such as direction vector, interaction options, dialogs and so on ).
*
* 3. Process key-dependent level properties.
*/
}
}
/* 4. Process key-independent level properties. */
}
...
// Main draw loop.
while ( ! bGameOver )
{
/*
* Redraw level.
*/
delay ( rFrameRate );
}