void check_collision(void) { int i; for(i=0;i<10;i++) { if(egg_pos[i][0]<=(bask_x+25)&&egg_pos[i][0]>=(bask_x-30)&&egg_pos[i][1]<95&&egg_pos[i][1]>80&&eggs[i]==1) { eggs[i]=0; score+=s[egg_color[i]].score; printf("%d \n",score); draw_score_board(score); //score+=eggs } else { if(egg_pos[i][1]<50&&egg_pos[i][1]>0&&eggs[i]==1) { eggs[i]=-1; } } } /*for(i=0;i<10;i++) { if(eggs[i]==1&&egg_pos[i][1]<80) crack(i); }*/ }
static void *worker_thread_fn(void *arg) { int i; int status; int timeout = INITIAL_TIMEOUT; struct game_score game_score = { game_options.initial_level, 0, 0, 0, global_highscore }; struct thread_data *data = (struct thread_data *)arg; /* setup the initial timeout (by reducing all deltas upto initial_level */ for (i = 1; i <= game_options.initial_level; i++) timeout -= TIMEOUT_DELTA(i); draw_score_board(&game_score); /* main game loop */ while (1) { /* wait till timeout */ snooze(timeout); /* acquire the lock */ pthread_mutex_lock(&data->lock); if (data->game_over) { pthread_mutex_unlock(&data->lock); break; } if (!data->current) { data->current = update_current_block(NULL); status = move_block(data->current, ACTION_PLACE_NEW); if (status == FAILURE) { data->game_over = 1; pthread_mutex_unlock(&data->lock); break; } draw_next_block(next_block, next_block_orientation); } else { /* try moving the block downwards */ status = move_block(data->current, ACTION_MOVE_DOWN); if (status == FAILURE) { int ret, num_rows; /* freeze this block in the game board */ freeze_block(data->current); data->current = NULL; /* reset the current block pointer */ data->block_dropped_ignore_input = 0; /* reset this now */ num_rows = clear_even_rows(); if (num_rows) { ret = update_score_level(&game_score, num_rows, &timeout); draw_score_board(&game_score); /* see if the level has changed */ if (ret) { draw_game_board(data->current); draw_level_info(game_score.level); } } } } draw_game_board(data->current); pthread_mutex_unlock(&data->lock); } if (game_score.score > global_highscore) { global_highscore = game_score.score; data->new_highscore = 1; } return arg; }