Beispiel #1
0
int main (int argc, char * argv[]) {
  bool restart;
  unsigned long int particles_n;

  if (argc < 2) {
    particles_n = NUMBER_OF_PARTICLES;
  } else {
    errno = 0;

    particles_n = strtoul(argv[1], NULL, 0);

    if (errno) {
      perror(__func__);
      exit(EXIT_FAILURE);
    }
  }

  n = particles_n;

  px =
    align_padded_malloc(ALIGN_BOUNDARY, n*sizeof(value), ALLOC_PADDING);
  py =
    align_padded_malloc(ALIGN_BOUNDARY, n*sizeof(value), ALLOC_PADDING);

  vx =
    align_padded_malloc(ALIGN_BOUNDARY, n*sizeof(value), ALLOC_PADDING);
  vy =
    align_padded_malloc(ALIGN_BOUNDARY, n*sizeof(value), ALLOC_PADDING);

  m  =
    align_padded_malloc(ALIGN_BOUNDARY, n*sizeof(value), ALLOC_PADDING);

  if (px == NULL || py == NULL ||
      vx == NULL || vy == NULL || m == NULL) {
    perror("main");
    exit(EXIT_FAILURE);
  }

  draw_init(SCREEN_WIDTH, SCREEN_HEIGHT, FRAME_RATE, n);
  physics_init(n);
  rng_init();

  do {
    draw_reset(n);
    physics_reset(n);
    restart = main_loop();
  } while (restart);

  rng_free();
  physics_free();
  draw_free();

  align_free(m);
  align_free(vy);
  align_free(vx);
  align_free(py);
  align_free(px);

  exit(EXIT_SUCCESS);
}
Beispiel #2
0
int		expose_listener(void *param)
{
	t_world		*world;

	world = (t_world*)param;
	draw_reset(world);
	draw_map(world);
	draw_stats(world);
	return (0);
}
Beispiel #3
0
static int		loop_listener(void *data)
{
	t_world		*world;

	world = (t_world*)data;
	draw_reset(world);
	do_move(world);
	draw_map(world);
	draw_stats(world);
	return (0);
}
Beispiel #4
0
void draw_init(void) 
{
    draw_lock = OSSemCreate(1);
    draw_reset();
}
Beispiel #5
0
	//初期化画面
	void game_reset()
	{
		controll_reset();
		draw_reset();
	}