Beispiel #1
0
int	main(int ac, char **av)
{
  t_data		data;
  /*  t_color		color[2];

  color[0].full = BLACK;
  color[1].full = RED;*/
  if (ac != 2)
    return (-1);
  data.ini = av[1];
  if (data.win == NULL)
    return  (-1);
  if ((data.wolf = init_map(data.ini)) == (t_wolf *)-1)
    return (EXIT_ON_ERROR);
  data.win = bunny_start(1200, 800, false, "Wolf3D");
  data.pix = bunny_new_pixelarray(1200, 800);
  data.color[0].argb[0] = 100;
  data.color[0].argb[1] = 100;
  data.color[0].argb[2] = 100;
  data.color[0].argb[3] = 255;
  init_value(data.wolf);
  bunny_set_loop_main_function((t_bunny_loop)main_loop);
  bunny_loop(data.win, 22, &data);
  bunny_free(data.wolf);
  bunny_delete_clipable(&data.pix->clipable);
  bunny_stop(data.win);
  return (0);
}
Beispiel #2
0
int		main(int ac, char **av)
{
  t_data	data;

  set_max_heap_size(30);
  data.sup = bunny_malloc(sizeof(struct s_support));
  if (ac == 2)
    data.sup->name = av[1];
  else
    data.sup->name = NULL;
  data.sup->pos.x = 0;
  data.sup->pos.y = 0;
  if (init_button(&data) == 1)
    return (1);
  init_main_variables(&data);
  init_all_pixarray(&data);
  data.window = bunny_start(WIN_WIDTH, WIN_HEIGHT, 0, "Chroma");
  display_it(&data, data.pixbg, 0, 0);
  display_it(&data, data.pixbgtool, WIN_WIDTH - 255, 150);
  display_it(&data, data.pixbgcalc, WIN_WIDTH - 255, WIN_HEIGHT - 282);
  bunny_set_loop_main_function(mainloop);
  bunny_set_key_response(key_actions);
  bunny_set_click_response(click_actions);
  bunny_loop(data.window, 60, &data);
  bunny_stop(data.window);
  delete_all_clipables(&data);
  empty_list(data.tool, free_calc);
  bunny_free(data.tool);
  return (0);
}
Beispiel #3
0
int			main(int ac, char **av)
{
  t_ray			*ray;

  if (ac < 2)
    {
      my_putstr_err("Error : No .ini file.\nAborting...\n");
      return (0);
    }
  if ((ray = bunny_malloc(sizeof(t_ray))) == NULL)
    return (1);
  if ((init_my_struct(ray)) == 1)
    {
      my_putstr_err("Fatal error ! Malloc failed\n");
      return (1);
    }
  ini_loader(ac, av, ray);
  if ((ray->pix = bunny_new_pixelarray(ray->width, ray->height)) == NULL)
    return (1);
  ray->win = bunny_start(ray->width, ray->height, false,
			 "Raytracer 1 | uberti_l");
  bunny_set_loop_main_function(main_loop);
  bunny_loop(ray->win, 60, ray);
  bunny_delete_clipable(&ray->pix->clipable);
  bunny_stop(ray->win);
  bunny_free(ray);
  return (0);
}
Beispiel #4
0
int	free_on_musicerror(t_main_menu *data)
{
  bunny_stop(data->win);
  bunny_delete_clipable(&data->pix->clipable);
  bunny_free(data);
  return (1);
}
Beispiel #5
0
int			main(void)
{
  int			w;
  int			i;

  assert((win = bunny_start(800, 600, false, "The Lapins Noirs")) != NULL);
  assert((pic[0] = bunny_new_picture(NORM(800, 600), NORM(800, 600))) != NULL);
  assert((pic[1] = bunny_new_picture(NORM(800, 600), NORM(800, 600))) != NULL);
  assert((bunny = bunny_load_picture("bigbunny.png")) != NULL);

  bunny->origin.x = bunny->buffer.width / 2;
  bunny->origin.y = bunny->buffer.height / 2;
  pic[0]->origin.x = pic[0]->buffer.width / 2;
  pic[0]->origin.y = pic[0]->buffer.height / 2;
  pic[1]->origin.x = pic[1]->buffer.width / 2;
  pic[1]->origin.y = pic[1]->buffer.height / 2;
  bunny_clear(&pic[0]->buffer, 0);
  bunny_clear(&pic[1]->buffer, 0);
  for (i = 0, w = 50; i < pic[0]->buffer.width; i += 100)
    {
      square(pic[0], i, 0, w, pic[0]->buffer.height, ALPHA(150, rand()));
      square(pic[1], i, 0, w, pic[1]->buffer.height, ALPHA(150, rand()));
    }
  reset(pic[0]);
  reset(pic[1]);
  bunny_set_loop_main_function(loop);
  bunny_set_key_response(key);
  bunny_loop(win, 50, NULL);
  bunny_delete_clipable(pic[0]);
  bunny_delete_clipable(pic[1]);
  bunny_stop(win);
  return (EXIT_FAILURE);
}
Beispiel #6
0
t_bunny_response	my_fct_free(t_data *data, int error_true)
{
  bunny_delete_clipable(&data->pix->clipable);
  bunny_stop(data->win);
  bunny_free(data);
  if (error_true == 1)
    return (EXIT_ON_ERROR);
  return (EXIT_ON_SUCCESS);
}
Beispiel #7
0
char	explorer_reset(t_tekpaint *tekpaint, t_explorer *explorer)
{
  bunny_stop(explorer->win);
  bunny_set_key_response(NULL);
  bunny_set_loop_main_function((t_bunny_loop)main_loop);
  bunny_delete_clipable(&explorer->buffer->clipable);
  explorer->buffer = NULL;
  tekpaint->tool.explorer->win = NULL;
  tekpaint->tool.explorer = NULL;
}
Beispiel #8
0
int			main(void)
{
  inc = 0;
  visible = true;
  puts("Appuyez sur espace pour faire apparaitre ou disparaitre la souris.");
  win = bunny_start(800, 600, false, "");
  bunny_set_key_response(key);
  bunny_set_loop_main_function(loop);
  bunny_loop(win, 25, NULL);
  bunny_stop(win);
  return (0);
}
Beispiel #9
0
int				main(void)
{
  t_bunny_loading_screen	loading_screen;
  t_bunny_window		*win;
  int				i;

  memset(&loading_screen, 0, sizeof(loading_screen));

  for (i = 0; i < 10; ++i)
    {
      char			*s;

      asprintf(&s, "./picture%d.png", i);
      gl_pictures_to_load[i].file = s;
      gl_pictures_to_load[i].target = (void**)&gl_pictures[i];

      asprintf(&s, "./snd%d.wav", i);
      gl_effects_to_load[i].file = s;
      gl_effects_to_load[i].target = (void**)&gl_effects[i];
    }

  loading_screen.head.main_structure = &loading_screen;
  loading_screen.head.subcontext.display = &display;
  loading_screen.head.subcontext.async_computation_response = &async;
  assert(loading_screen.head.screen =
	 (t_bunny_buffer*)(win = bunny_start(400, 300, false, "Loading screen")));

  assert(bunny_init_loading_context(&loading_screen));
  assert(bunny_add_to_ressource_list
	 (loading_screen.pictures, &gl_pictures_to_load[0], NBRCELL(gl_pictures))
	 );
  assert(bunny_add_to_ressource_list
	 (loading_screen.effects, &gl_effects_to_load[0], NBRCELL(gl_effects))
	 );

  bunny_clear(loading_screen.head.screen, BLACK);
  bunny_display((t_bunny_window*)loading_screen.head.screen);

  bunny_set_context(&gl_bunny_loading_context);
  bunny_loop(win, 25, &loading_screen);

  bunny_clear_all_loaded_ressources(&loading_screen);

  bunny_stop((t_bunny_window*)loading_screen.head.screen);

  for (i = 0; i < 10; ++i)
    {
      free((char*)gl_pictures_to_load[i].file);
      free((char*)gl_effects_to_load[i].file);
    }
  return (EXIT_SUCCESS);
}
Beispiel #10
0
int				main(int		argc,
				     char		**argv)
{
  /* Static in order to put the structure on the heap, in case it is big */
  static t_bunny_project	project;
  const t_bunny_position	*screen;
  t_bunny_response		response;

  (void)argc;
  binary_directory(argv[0]);
  screen = bunny_get_screen_resolution();
  if ((project.window = bunny_start(screen->x, screen->y, true, BUNNY_TITLE)) == NULL)
    {
      bunny_printlerr("Failed to open the window.");
      return (EXIT_FAILURE);
    }
  if ((project.bunny = bunny_load_picture("lapin_noir.png")) == NULL)
    {
      bunny_printlerr("Failed to load bunny.png");
      bunny_stop(project.window);
      return (EXIT_FAILURE);
    }

  project.bunny->scale.x = project.bunny->scale.y = 16.0;
  project.bunny->origin.x = project.bunny->buffer.width / 2;
  project.bunny->origin.y = project.bunny->buffer.height / 2;
  project.bunny_position.x = project.window->buffer.width / 2;
  project.bunny_position.y = project.window->buffer.height / 2;

  do
    {
      bunny_set_context((t_bunny_context*)&bunny_project_context[project.context]);
      response = bunny_loop(project.window, BUNNY_FREQUENCY, &project);
    }
  while (response == SWITCH_CONTEXT);
  bunny_stop(project.window);
  return (EXIT_SUCCESS);
}
int			main()
{
  t_bunny_window	*window;

  window = bunny_start(800, 600, 0, "Ma fenêtre");
  if (!window)
    {
      return (1);
    }
  bunny_display(window);
  sleep(2);
  bunny_stop(window);
  return (0);
}
int			main()
{
  t_bunny_window	*window;

  window = bunny_start_style(800, 600, TITLEBAR | CLOSE_BUTTON, "Ma fenêtre");
  if (!window)
    {
      return (1);
    }
  bunny_display(window);
  sleep(2);
  bunny_stop(window);
  return (0);
}
Beispiel #13
0
Datei: main.c Projekt: plean/CPE
static void	destroy_windows(t_struct a)
{
  bunny_set_loop_main_function(&refresh_princeofbelair);
  bunny_set_key_response(&my_exit);
  bunny_set_click_response(&mouse_click);
  bunny_loop(a.win, 30, (void*)&a);
  if (a.music != NULL)
    {
      bunny_sound_stop(&a.music->sound);
      bunny_delete_sound(&a.music->sound);
    }
  bunny_stop(a.win);
  bunny_delete_clipable(&(a.pix->clipable));
}
Beispiel #14
0
int			main(void)
{
  t_bunny_window	*win;
  t_bunny_music		*music;

  printl("Click on the window to stop this insanity.");
  assert(win = bunny_start(800, 600, false, "Never gonna give you up!"));
  assert(music = bunny_load_music("music.ogg"));
  signal(SIGINT, SIG_IGN);
  bunny_sound_play(&music->sound);
  bunny_set_click_response(click);
  bunny_set_loop_main_function(loop);
  bunny_loop(win, 5, win);
  bunny_sound_stop(&music->sound);
  bunny_stop(win);
  return (EXIT_SUCCESS);
}
Beispiel #15
0
int	main(int ac, char av)
{
  t_bunny_window *win;
  t_bunny_position pos;
  t_bunny_pixelarray *pix;
  
  pos.x = 0;
  pos.y = 0;
  win = bunny_start(1000, 1000, 0, "yolo");
  pix = bunny_new_pixelarray(1000,1000);
  fdf_base(100, 100, 3, 1, pix);
  bunny_blit(&win->buffer, &pix->clipable, &pos);
  bunny_display(win);
  usleep(100000000);
  bunny_delete_clipable(&pix->clipable);
  bunny_stop(win);
}
Beispiel #16
0
int			main()
{
  t_bunny_window	*window;

  window = bunny_start(800, 600, 0, "Ma fenêtre");
  if (!window)
    {
      return (1);
    }
  while (1)
    {
      bunny_display(window);
      print_size(window);
      sleep(1);
    }
  bunny_stop(window);
  return (0);
}
Beispiel #17
0
char			open_palette(t_tekpaint *tekpaint)
{
  t_bunny_position	pos;
  t_palette		*palette;

  palette = &tekpaint->tool.palette;
  palette->win = bunny_start_style(PALETTE_WIDTH, PALETTE_HEIGHT,
				   TITLEBAR | CLOSE_BUTTON,
				   "Palette de couleurs");
  if (NULL == (palette->buffer = load_bmp("res/palette.bmp")))
    return (0);
  pos.x = 0;
  pos.y = 0;
  bunny_blit(&palette->win->buffer, &palette->buffer->clipable, &pos);
  bunny_set_click_response(on_palette_event_click);
  bunny_set_loop_main_function((t_bunny_loop)main_loop_palette);
  bunny_loop(palette->win, 50, tekpaint);
  bunny_stop(palette->win);
  palette_reset(palette);
  return (1);
}
Beispiel #18
0
int	main(int ac, char **av)
{
  t_win	win;

  if ((win.win = bunny_start(W_X, W_Y, false, "wolfd3d")) == NULL)
    return (1);
  if ((win.array = bunny_new_pixelarray(W_X, W_Y)) == NULL)
    return (1);
  if (ac == 2 && set_data(av[1], "level1", &win) == -1)
    return (1);
  else if (ac != 2 && set_def_map(&win) == 1)
    return (1);
  set_cols(&win);
  bunny_set_key_response(&press_key);
  bunny_set_loop_main_function(mainloop);
  bunny_loop(win.win, 60, &win);
  free_map(&win.map);
  bunny_delete_clipable(&win.array->clipable);
  bunny_stop(win.win);
  return (0);
}
Beispiel #19
0
int		main()
{
  t_data	data;

  if ((data.map = bunny_malloc(sizeof(t_map))) == NULL)
    return (-1);
  if ((data.pl = bunny_malloc(sizeof(t_player))) == NULL)
    return (-1);
  data.music_play = 0;
  data.ini = bunny_load_ini("ress/map/level0.ini\0");
  initialisation(&data);
  if (data.ini == NULL)
    return (0);
  if ((get_map(&data)) == -1)
    return (-1);
  bunny_set_loop_main_function(mainloop);
  bunny_loop(data.win, 25, &data);
  bunny_stop(data.win);
  clean(&data);
  return (0);
}
Beispiel #20
0
int			main(int		argc,
			     char		**argv)
{
  const char		*key_content = "abcdef";
  size_t		len = strlen(key_content);
  t_bunny_cipher_key	*key = bunny_alloca(sizeof(*key) + len + 1);

  strcpy(&key->key[0], key_content);
  key->length = len;

  gl_bunny_ressource_ciphering = ashiciph;
  gl_bunny_ressource_data = key;

  if (argc != 2)
    {
      printf("%s picture_file\n", argv[0]);
      return (EXIT_FAILURE);
    }

  if ((pic = bunny_load_picture(argv[1])) == NULL)
    return (EXIT_FAILURE);
  if ((win = bunny_start
       (pic->buffer.width, pic->buffer.height, false, "Picture cipher")) == NULL)
    {
      bunny_delete_clipable(pic);
      return (EXIT_FAILURE);
    }

  bunny_set_key_response(keyexit);
  bunny_set_loop_main_function(loop);

  bunny_blit(&win->buffer, pic, NULL);
  bunny_loop(win, 20, NULL);

  bunny_delete_clipable(pic);
  bunny_stop(win);

  return (EXIT_SUCCESS);
}
Beispiel #21
0
char			loadmap(char *file)
{
  t_head		head;
  t_bmp			bmp;
  int			ret;
  int			fd;
  t_loop		loop;

  if ((fd = open(file, O_RDONLY)) < 0 ||
      (ret = read(fd, &head, sizeof(t_head))) < 0 ||
      (ret = read(fd, &bmp, sizeof(t_bmp))) < 0 ||
      lseek(fd, head.offset, SEEK_SET) < 0 ||
      read_pixels(&loop, fd, bmp.height, bmp.width) ||
      (loop.win = bunny_start(bmp.width, bmp.height, 0, file)) == NULL)
    return (1);
  bunny_set_key_response(my_esc);
  bunny_set_loop_main_function(main_loop);
  bunny_loop(loop.win, 24, &loop);
  bunny_delete_clipable(&loop.pix->clipable);
  bunny_stop(loop.win);
  close(fd);
  return (0);
}
Beispiel #22
0
int main(void)
{
  t_main_data main_data;

  main_data.win = bunny_start(600, 600, false, "Dancing lines and circles");
  main_data.step = 1.0;

  // key_event_response will be called on key pressed and key released events
  bunny_set_key_response(key_event_response);

  // loop_function will be called regulary at 25Hz (see bunny_loop call)
  bunny_set_loop_main_function(loop_function);

  // display_function will be called when the program need to refresh the display
  bunny_set_display_function(display_function);

  // The third parameter will be sent as last parameter of every functions called by bunny_loop.
  bunny_loop(main_data.win, 25, &main_data);

  // When getting out of bunny_loop, close the window
  bunny_stop(main_data.win);
  return (EXIT_SUCCESS);
}
Beispiel #23
0
int			main()
{
  t_box			data;
  t_bunny_loop		main_loop;

  main_loop = &loop;
  if (!(data.graph = malloc(sizeof(*data.graph))))
    return (ERROR);
  if (!(data.maillon = malloc(sizeof(*data.maillon))))
    return (-1);
  data.maillon->pos.x = -1;
  data.maillon->pos.y = -1;
  data.pause = 0;
  data.graph->pix = bunny_new_pixelarray(1000, 1000);
  data.graph->win = bunny_start(1000, 1000, false, "BoxPop");
  if (init_board(&data) == ERROR)
    return (ERROR);
  bunny_set_loop_main_function(main_loop);
  bunny_loop(data.graph->win, 10, &data);
  bunny_stop(data.graph->win);
  bunny_delete_clipable(&data.graph->pix->clipable);
  return (SUCCESS);
}
Beispiel #24
0
int			main(int ac, char **av)
{
  t_bunny_window	*win;
  t_bunny_pixelarray	*img;
  t_bunny_position	pos;
  t_bunny_position	pos_tab[8];
  t_bunny_position	pos_tab_line[2];
  int			x[8];
  int			y[8];
  int			z[8];
  int			i;

  i = 0;
  /*
  ** Window starting
  */
  win = bunny_start(WIN_WIDTH, WIN_HEIGHT, 0, "__AMAZING_3D__");
  /*
  ** Img initializing
  */
  img = bunny_new_pixelarray(WIN_WIDTH, WIN_HEIGHT);
  img->clipable.clip_x_position = 0;
  img->clipable.clip_y_position = 0;
  img->clipable.clip_height = WIN_HEIGHT;
  img->clipable.clip_width = WIN_WIDTH;
  pos.y = 0;
  while (pos.y < WIN_HEIGHT)
    {
      pos.x = 0;
      while (pos.x < WIN_WIDTH)
  	{
  	  tekpixel(img, pos, BLACK);
  	  pos.x += 1;
  	}
      pos.y += 1;
    }
  /*
  ** INITIALISATIONS
  */
  /* A */
  x[0] = 300;
  y[0] = 0;
  z[0] = -300;
  /* B */
  x[1] = 900;
  y[1] = 0;
  z[1] = -300;
  /* C */
  x[2] = 900;
  y[2] = 0;
  z[2] = -800;
  /* D */
  x[3] = 300;
  y[3] = 0;
  z[3] = -800;
  /* E */
  x[4] = 300;
  y[4] = 200;
  z[4] = -300;
  /* F */
  x[5] = 900;
  y[5] = 200;
  z[5] = -300;
  /* G */
  x[6] = 900;
  y[6] = 200;
  z[6] = -800;
  /* H */
  x[7] = 300;
  y[7] = 200;
  z[7] = -800;
  /*
  ** CONVERSION -> PARALLEL
  */
  tekllproject(pos_tab + 0, x[0], y[0], z[0]);
  tekllproject(pos_tab + 1, x[1], y[1], z[1]);
  tekllproject(pos_tab + 2, x[2], y[2], z[2]);
  tekllproject(pos_tab + 3, x[3], y[3], z[3]);
  tekllproject(pos_tab + 4, x[4], y[4], z[4]);
  tekllproject(pos_tab + 5, x[5], y[5], z[5]);
  tekllproject(pos_tab + 6, x[6], y[6], z[6]);
  tekllproject(pos_tab + 7, x[7], y[7], z[7]);
  /*
  ** LINES !!!!
  */
  pos_tab_line[0] = pos_tab[0];
  pos_tab_line[1] = pos_tab[1];
  tekline(img, pos_tab_line, WHITE);
  pos_tab_line[0] = pos_tab[1];
  pos_tab_line[1] = pos_tab[2];
  tekline(img, pos_tab_line, WHITE);
  pos_tab_line[0] = pos_tab[2];
  pos_tab_line[1] = pos_tab[3];
  tekline(img, pos_tab_line, WHITE);
  pos_tab_line[0] = pos_tab[3];
  pos_tab_line[1] = pos_tab[0];
  tekline(img, pos_tab_line, WHITE);
  pos_tab_line[0] = pos_tab[4];
  pos_tab_line[1] = pos_tab[5];
  tekline(img, pos_tab_line, WHITE);
  pos_tab_line[0] = pos_tab[5];
  pos_tab_line[1] = pos_tab[6];
  tekline(img, pos_tab_line, WHITE);
  pos_tab_line[0] = pos_tab[6];
  pos_tab_line[1] = pos_tab[7];
  tekline(img, pos_tab_line, WHITE);
  pos_tab_line[0] = pos_tab[7];
  pos_tab_line[1] = pos_tab[4];
  tekline(img, pos_tab_line, WHITE);
  pos_tab_line[0] = pos_tab[0];
  pos_tab_line[1] = pos_tab[4];
  tekline(img, pos_tab_line, WHITE);
  pos_tab_line[0] = pos_tab[1];
  pos_tab_line[1] = pos_tab[5];
  tekline(img, pos_tab_line, WHITE);
  pos_tab_line[0] = pos_tab[2];
  pos_tab_line[1] = pos_tab[6];
  tekline(img, pos_tab_line, WHITE);
  pos_tab_line[0] = pos_tab[3];
  pos_tab_line[1] = pos_tab[7];
  tekline(img, pos_tab_line, WHITE);
  /*
  ** Drawing img on win->buffer
  */
  pos.x = 0;
  pos.y = 0;
  bunny_blit(&win->buffer, &img->clipable, &pos);
  /*
  ** Finally showing our hard work
  */
  bunny_display(win);
  bunny_loop(win, 42, NULL);
  bunny_delete_clipable(&(img->clipable));
  bunny_stop(win);
  return (0);
}
Beispiel #25
0
int	free_on_pixerror(t_main_menu *data)
{
  bunny_stop(data->win);
  bunny_free(data);
  return (1);
}