コード例 #1
0
ファイル: dialog.c プロジェクト: posva/msnake
// display a table containing the highscores of the players
void show_highscores() {
  int num, i;
  char *highscore_table;
  // read all the submitted highscores from a file
  HIGHSCORE *highscore = read_highscore(&num);

  // limit the highscore display to (at the moment 14) entries
  if(num > DIALOG_HEIGHT - 6) {
    num = DIALOG_HEIGHT - 6;
  }

  // create a char array for the content of the highscore table
  highscore_table = calloc((num + 2) * CONTENT_WIDTH, sizeof(char));

  // create a simple table heading inside of the dialog
  snprintf(highscore_table, CONTENT_WIDTH, "POS            NAME  PTS   SEC  SCORE");
  snprintf(highscore_table + CONTENT_WIDTH, CONTENT_WIDTH, "-------------------------------------");

  // insert the highscores
  for(i = 0; i < num; i++) {
    // insert a highscore record
    snprintf(highscore_table + (i + 2) * CONTENT_WIDTH, // the position on the highscore table array
      CONTENT_WIDTH, // do not allow the line to be longer than 38 chars
      "%2i. %15s %4i  %4li  %5i", // the format of the line
      i + 1, // the rank
      highscore[i].name, // the data
      highscore[i].points,
      highscore[i].time_sec,   
      highscore[i].highscore);
  }

  // create a dialog and display the data
  create_enter_dialog("HIGHSCORES", highscore_table, num + 2);

  // free the resources
  free(highscore_table);
}
コード例 #2
0
ファイル: interface.c プロジェクト: wader/gtktetris
void game_over_init()
{
	int high_dummy;
	read_highscore();
	if(current_score && (high_dummy = addto_highscore((char *)getenv("USER"),current_score,current_level,current_lines)))
	{
		write_highscore();
		show_highscore(high_dummy);
	}
	
	game_over = TRUE;
	game_play = FALSE;
	gdk_draw_rectangle(game_area->window,
		game_area->style->black_gc,
		TRUE,
		0,0,
		game_area->allocation.width,
		game_area->allocation.height);

	gdk_draw_rectangle(next_block_area->window,
		next_block_area->style->black_gc,
		TRUE,
		0,0,
		next_block_area->allocation.width,
		next_block_area->allocation.height);
	game_set_pause(GTK_WIDGET(menu_game_pause),NULL);
	gtk_label_set(GTK_LABEL(Start_stop_button_label),start_stop_str[0]);
	gtk_widget_set_sensitive(menu_game_quick,TRUE);
	gtk_widget_set_sensitive(menu_game_start,TRUE);
	gtk_widget_set_sensitive(menu_game_stop,FALSE);
	gtk_widget_set_sensitive(Start_stop_button,TRUE);
	gtk_widget_grab_default(Start_stop_button);
	gtk_label_set(GTK_LABEL(Pause_button_label),pause_str[0]);
	gtk_widget_set_sensitive(Pause_button,FALSE);
	
	gtk_timeout_remove(timer);
}
コード例 #3
0
ファイル: main.c プロジェクト: oamldev/msnake_oaml
int main() {

  if (oamlInitAudioDevice(44100, 2) != OAML_OK) {
    fprintf(stderr, "Unable to open audio device!\n");
    exit(1);
  }
  oamlInit("oaml.defs");

  // for some better random numbers (and not always the same)
  srand(time(NULL));

  init_curses();

  main_menu();

  oamlShutdown();
  end_curses();

  // free the allocated memory for the highscore
  read_highscore(NULL);
  // close the logfile
  glog(NULL);
  return EXIT_SUCCESS;
}
コード例 #4
0
ファイル: interface.c プロジェクト: wader/gtktetris
void show_highscore_wrapper(GtkMenuItem     *menuitem,
			    gpointer         user_data)
{
	read_highscore();
	show_highscore(0);
}