Ejemplo n.º 1
0
static int update_score_level(struct game_score *score, int num_rows, 
        int *timeout)
{
    int has_level_changed = 0;

    //score->score += (score->level + SCORE_CLEAR_ROW) * num_rows * num_rows;
    score->score += score->level * num_rows * num_rows * BASE_SCORE_PER_ROW;
    if (score->score > score->current_highscore)
        score->current_highscore = score->score;

    score->total_rows += num_rows;
    score->rows_cleared += num_rows;

    if (score->rows_cleared >= MAX_ROWS_PER_LEVEL) {
        if (game_options.increase_difficulty &&
                score->level < DIFFICULTY_LEVEL_MAX)
            *timeout -= TIMEOUT_DELTA(score->level);

        if (game_options.clear_on_new_level)
            reset_game_board();

        score->level++;
        score->rows_cleared = 0;
        has_level_changed = 1;
    }

    return has_level_changed;
}
Ejemplo n.º 2
0
int initialize_game_elements(void)
{
    /* initialize the board */
    reset_game_board();

    /* initialize the current and next block */
    srand((unsigned) time(NULL));
    next_block = (block_t)(rand() % TOTAL_BLOCKS);
    next_block_orientation = (degree_t)(rand() % TOTAL_DEGREES);

    return SUCCESS;
}
Ejemplo n.º 3
0
uint8_t *init_game_board() {
  uint8_t *game_board = (uint8_t *) calloc(GAME_BOARD_X * GAME_BOARD_Y, sizeof(uint8_t));
  reset_game_board(game_board);
  return game_board;
}