Esempio n. 1
0
int main(int argc, char** argv)
{
	char outfile[1024];

	struct PList p;
	float centers[5][3]={{57.06108093,  52.61642456,  48.70379639},
	{ 49.64647675,  50.13929367,  49.77927399},
	{ 50.29379654,  50.32624054,  50.51562119},
	{ 60.87985229,  54.10048676,  52.26412964},
	{ 46.0791626,   76.08740997,  66.36212158}};
	float halovels[5][3]={{ 294.80819702,  100.80763245,  -55.95608902},
	{-306.80792236,  -52.49833298,  -24.17752457},
	{ 340.02838135,  403.45211792,  289.01052856},
	{ 517.9788208,   162.09895325,  128.54304504},
	{ 209.11463928, -170.64677429,  274.96737671}};
	char halo_names[6]="ABCDE";
	
	if(argc!=2)
	{printf("usage: %s [halo_id=0~4]\n",argv[0]);fflush(stdout);exit(1);}
	
	int halo_id=atoi(argv[1]);
	char halo=halo_names[halo_id];
	printf("%d,%c\n",halo_id,halo);
	CoM=centers[halo_id];
	VCoM=halovels[halo_id];
	
	load_particles(halo);

	sprintf(outfile,"/gpfs/data/jvbq85/DynDistr/data/%c2star.hdf5",halo);
	collect_particles(&p);
	dump_particles_hdf(outfile,&p);
	free(p.PIndex);

	free_particles();
	return 0;
}
Esempio n. 2
0
// The good old main()
int main(int argc, char *argv[]) {
	// Initialize SDL and OpenGL
	init_sdl_and_gl();

	// Initialize FMOD
	init_mixer();

	// Load fonts
	build_font_list();
	font1 = load_png("fonts.png", true, false, true);

	// Show the loading screen
	loading_screen();

	// Find the level files
	find_levels();

	// Load textures
	font_num = load_png("fonts_num.png", true, false, true);
	load_bgrounds();
	load_players();
	load_enemies();
	load_bonus();
	load_maptex();
	load_bombs();
	load_particles();
	load_teleports();
	load_traps();
	load_wisps();
	load_potatoman();
	load_icons();
	load_menus();


	// Add timer to run 60 fps
	start_timer(60);

	// Menu logic
	int ans = show_menu(MENU_ID_MAIN);
	while(ans != MENU_EXIT) {
		// Start the game?
		if(ans == MENU_SINGLEPLAY)			// Single player
			start_game();
		else if(ans == MENU_MULTIPLAY)		// Two players
			start_game(true);

		// Show the menu again
		ans = show_menu(MENU_ID_MAIN);
	}


	// Destroy timer
	kill_timer();

	// Free stuff
	delete_font_list();
	kill_particles();


	// Kill SDL
	SDL_Quit();

	// Close the pakfile
	pakfile.close_mpk();

	// Close the FMOD
	if(music_mod){
		Mix_HaltMusic();
		Mix_FreeMusic(music_mod);
	}
	Mix_CloseAudio();

	// Save the config
	save_config(get_config_location(true), &config);
	return 0;
}
Esempio n. 3
0
void read_particles(char *filename) {
  int64_t i, j, gadget = 0, gadget_internal = 0;
  int64_t p_start = num_p;
  float dx, ds, z, a, vel_mul;
  double *origin, origin_offset[3] = {0};
  if (!strcasecmp(FILE_FORMAT, "ASCII")) load_particles(filename, &p, &num_p);
  else if (!strncasecmp(FILE_FORMAT, "GADGET", 6)) {
    if (!strcasecmp(FILE_FORMAT, "GADGET_INTERNAL") ||
	!strcasecmp(FILE_FORMAT, "GADGET2_INTERNAL")) gadget_internal = 1;
    load_particles_gadget2(filename, &p, &num_p);
    gadget = 1;
  }
  else if (!strncasecmp(FILE_FORMAT, "ART", 3)) 
    load_particles_art(filename, &p, &num_p);
  else if (!strncasecmp(FILE_FORMAT, "INTERNAL", 8)) {
    load_particles_internal(filename, &p, &num_p);
  }
  else if (!strncasecmp(FILE_FORMAT, "GENERIC", 7)) {
    assert(load_particles_generic != NULL);
    load_particles_generic(filename, &p, &num_p);
  }
  else if (!strncasecmp(FILE_FORMAT, "TIPSY", 5)) {
    load_particles_internal(filename, &p, &num_p);
  }
  else {
    fprintf(stderr, "[Error] Unknown filetype %s!\n", FILE_FORMAT);
    exit(1);
  }

  if (LIMIT_RADIUS) {
    for (i=p_start; i<num_p; i++) {
      for (j=0, ds=0; j<3; j++) { dx = p[i].pos[j]-LIMIT_CENTER[j]; ds+=dx*dx; }
      if (ds > LIMIT_RADIUS*LIMIT_RADIUS) {
	num_p--;
	p[i] = p[num_p];
	i--;
      }
    }
  }

  if (LIGHTCONE) {
    init_cosmology();
    if (strlen(LIGHTCONE_ALT_SNAPS)) {
      for (i=0; i<3; i++)
	if (LIGHTCONE_ORIGIN[i] || LIGHTCONE_ALT_ORIGIN[i]) break;
      if (i<3) { //Same box coordinates, different intended locations
	if (LIGHTCONE == 1) {
	  for (i=0; i<3; i++) origin_offset[i] = LIGHTCONE_ORIGIN[i] - 
				LIGHTCONE_ALT_ORIGIN[i];
	}
      } else { //Offset everything
	for (i=0; i<3; i++) origin_offset[i] = -BOX_SIZE;
      }
      BOX_SIZE *= 2.0;
    }
    origin = (LIGHTCONE == 2) ? LIGHTCONE_ALT_ORIGIN : LIGHTCONE_ORIGIN;
    for (i=p_start; i<num_p; i++) {
      if (LIGHTCONE == 2) p[i].id = -p[i].id; //Make ids different
      for (j=0,dx=0; j<3; j++) {
	ds = p[i].pos[j] - origin[j];
	dx += ds*ds;
	p[i].pos[j] -= origin_offset[j];
      }
      if (!gadget) continue;
      dx = sqrt(dx);
      z = comoving_distance_h_to_redshift(dx);
      a = scale_factor(z);
      vel_mul = (gadget_internal) ? (1.0/a) : sqrt(a);
      for (j=0; j<3; j++) p[i].pos[j+3] *= vel_mul;
    }
  }
  output_config(NULL);
}