/* Returns a pseudo-random integer in the range [0, 255]. */
unsigned char
prng_get_octet (void)
{
  if (!seeded) 
    prng_seed_time ();

  s_i = (s_i + 1) & 255;
  s_j = (s_j + s[s_i]) & 255;
  SWAP_BYTE (s + s_i, s + s_j);

  return s[(s[s_i] + s[s_j]) & 255];
}
Example #2
0
/**
 * Resets the game state. Used at the start of games, or after losing.
 */
void init_game(void) {
    unsigned i;

    prng_seed_time(timer_tick);

    pipespawn = PIPE_TIME;
    for (i = 0; i < NUM_PIPES; i++) {
        Pipe pipe;
        pipe.position = -1;
        pipe.height = -1;
        pipes[i] = pipe;
    }

    bird_height = 4;
    bird_direction = 1;
    bird_countdown = 0;
    game_lost = 0;
    score = 0;
}