Ejemplo n.º 1
0
int	event_folder(void *tp, t_event_mouse *action)
{
  t_tek	*tekpaint;
  char	*response;
  char	*path;

  tekpaint = tp;
  if (action && tekpaint)
    {
      my_putstr("Voulez-vous ouvrir un fichier .bmp(0) ou .ini(1) ? > ");
      response = get_next_line(0);
      my_putstr("Quel fichier voulez-vous ouvrir ? > ");
      path = get_next_line(0);
      if (my_getnbr(response) == 1)
	{
	  bunny_delete_clipable(&tekpaint->img->clipable);
	  tekpaint->img = my_load(path);
	}
      else
	{
	  bunny_delete_clipable(&tekpaint->img->clipable);
	  tekpaint->img = my_load_bmp(path);
	}
    }
  return (0);
}
Ejemplo n.º 2
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);
}
Ejemplo n.º 3
0
void			delete_all_clipables(t_visu *visu)
{
  bunny_delete_clipable(&visu->pix->clipable);
  bunny_delete_clipable(&visu->ant->clipable);
  bunny_delete_clipable(&visu->screen->clipable);
  bunny_delete_clipable(&visu->room->clipable);
  bunny_delete_clipable(&visu->room_end->clipable);
}
Ejemplo n.º 4
0
void	free_buttons(t_button *button)
{
  int	i;

  i = 0;
  while (i < 4)
    {
      bunny_free(button[i].name);
      bunny_delete_clipable(&button[i].sprite->clipable);
      bunny_delete_clipable(&button[i].active_sprite->clipable);
      i++;
    }
}
Ejemplo n.º 5
0
void		my_delete_in_list(t_list *list)
{
  list->prev->next = list->next;
  list->next->prev = list->prev;
  bunny_delete_clipable(&list->pix.pix->clipable);
  free(list);
}
Ejemplo n.º 6
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);
}
Ejemplo n.º 7
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);
}
Ejemplo n.º 8
0
int	free_on_musicerror(t_main_menu *data)
{
  bunny_stop(data->win);
  bunny_delete_clipable(&data->pix->clipable);
  bunny_free(data);
  return (1);
}
Ejemplo n.º 9
0
void			my_txt(t_bj *game, int nb, int player)
{
  t_bunny_position	pos;
  t_bunny_position	pos_t;
  t_bunny_pixelarray	*chiffre;
  t_sprites		sprites;

  chiffre = bunny_new_pixelarray(15, 30);
  pos_t.x = 0;
  pos_t.y = 0;
  get_txt_pos(game, &pos, player);
  sprites.width = 15;
  sprites.height = 30;
  sprites.line = 0;
  if ((sprites.state = nb / 10) != 0)
    {
      reset_pix(chiffre, game->pix, pos);
      load_letter(chiffre, game->font, pos_t, &sprites);
      bunny_blit(&game->win->buffer, &chiffre->clipable, &pos);
    }
  sprites.state = nb % 10;
  pos.x += 30;
  reset_pix(chiffre, game->pix, pos);
  load_letter(chiffre, game->font, pos_t, &sprites);
  bunny_blit(&game->win->buffer, &chiffre->clipable, &pos);
  bunny_delete_clipable(&chiffre->clipable);
}
Ejemplo n.º 10
0
t_texture		*pix_array_to_texture(t_bunny_pixelarray *pix,
					      t_ptr_list **pr)
{
  t_texture		*ou;
  t_bunny_position	pos;

  if ((ou = xmalloc(sizeof(t_texture), pr)) == NULL)
    return (NULL);
  ou->width = pix->clipable.clip_width;
  ou->height = pix->clipable.clip_height;
  if ((ou->color = xmalloc(sizeof(t_color *) * (ou->height + 1), pr)) == NULL)
    return (NULL);
  pos.y = 0;
  while (pos.y < ou->height)
    {
      if ((ou->color[pos.y] = xmalloc(4 * (ou->width + 1), pr)) == NULL)
	return (NULL);
      pos.x = 0;
      while (pos.x < ou->width)
	{
	  ou->color[pos.y][pos.x].full =
	    ((t_color *)pix->pixels)[pos.y * ou->width + pos.x].full;
	  pos.x++;
	}
      pos.y++;
    }
  bunny_delete_clipable(&pix->clipable);
  return (ou);
}
Ejemplo n.º 11
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);
}
Ejemplo n.º 12
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;
}
Ejemplo n.º 13
0
void	free_data(t_data *data)
{
  int	i;

  i = -1;
  free_buttons(data->menu->buttons);
  while (++i < 14)
    {
      bunny_free(data->tab[i].name);
      bunny_delete_clipable(&data->tab[i].front->clipable);
      delete_item(data->tab[i].item);
      if (i == 0 || i == 1 || i == 4 || i == 9)
	bunny_delete_clipable(&data->tab[i].back->clipable);
      else if (i == 3 || i == 5 || i == 6)
	{
	  bunny_delete_clipable(&data->tab[i].back->clipable);
	  bunny_delete_clipable(&data->tab[i].middle->clipable);
	}
    }
}
Ejemplo n.º 14
0
void	kala_end_fade(t_kala *data)
{
  if (data->intro.state == 5)
    {
      bunny_fill(&data->bg->buffer, data->intro.black.full);
      bunny_blit(&data->win->buffer, data->bg, NULL);
      bunny_display(data->win);
      data->intro.black.argb[3] += 1;
      if (data->intro.black.argb[3] >= 70)
	data->intro.state = 6;
    }
  if (data->intro.state == 6)
    {
      bunny_delete_clipable(data->logo);
      bunny_delete_clipable(data->shard);
      bunny_sound_stop((t_bunny_sound *)data->draa);
      bunny_delete_sound((t_bunny_sound *)data->draa);
      bunny_set_loop_main_function((t_bunny_loop)kala_loop);
    }
}
Ejemplo n.º 15
0
void	paste_bmp(t_tekpaint *tekpaint, t_bunny_position *pos)
{
  pos->y -= tekpaint->tool.bmp_buffer_tmp->clipable.clip_height / 2;
  pos->x -= tekpaint->tool.bmp_buffer_tmp->clipable.clip_width / 2;
  blit_pixelarrays(tekpaint->workplan.buffer,
		   tekpaint->tool.bmp_buffer_tmp,
		   pos);
  bunny_delete_clipable(&(tekpaint->tool.bmp_buffer_tmp->clipable));
  tekpaint->tool.bmp_buffer_tmp = NULL;
  tekpaint->tool.current_tool = 0;
  my_putstr("Image copiée sur l'écran\n");
}
Ejemplo n.º 16
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);
}
Ejemplo n.º 17
0
Archivo: main.c Proyecto: 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));
}
Ejemplo n.º 18
0
int			median_filter(t_bunny_pixelarray **pix,
				      const int value)
{
  t_bunny_pixelarray	*save;

  (void)value;
  if (!(save = bunny_new_pixelarray((*pix)->clipable.clip_width,
				    (*pix)->clipable.clip_height)))
    return (1);
  apply_median(*pix, save, (*pix)->clipable.clip_width,
	       (*pix)->clipable.clip_height);
  bunny_delete_clipable(&(*pix)->clipable);
  *pix = save;
  return (0);
}
Ejemplo n.º 19
0
int			oil(t_bunny_pixelarray **pix,
			    const int value)
{
  t_bunny_pixelarray	*save;
  t_oil			oil;

  (void)value;
  if (!(save = bunny_new_pixelarray((*pix)->clipable.clip_width,
				    (*pix)->clipable.clip_height)))
    return (1);
  calculate_oil(*pix, save, &oil);
  bunny_delete_clipable(&(*pix)->clipable);
  *pix = save;
  return (0);
}
Ejemplo n.º 20
0
void	delete_item(t_item *item)
{
  int	i;

  i = 0;
  if (!item)
    return ;
  while (item->sprite[i])
    {
      bunny_delete_clipable(&item->sprite[i]->clipable);
      bunny_free(item->pos);
      bunny_free(item->selected);
      i++;
    }
}
Ejemplo n.º 21
0
t_bunny_pixelarray	*resize_picture(t_bunny_pixelarray *pix,
					t_bunny_position pos)
{
  t_bunny_pixelarray	*new_pix;
  t_my_scale		s_one;

  if ((new_pix = bunny_new_pixelarray(pos.x, pos.y)) == NULL)
    return (NULL);
  pix_initialize(new_pix);
  s_one.scale_x = (double)new_pix->clipable.clip_width /
    (double)pix->clipable.clip_width;
  s_one.scale_y = (double)new_pix->clipable.clip_height /
    (double)pix->clipable.clip_height;
  full_new_pix(pix, new_pix, &s_one);
  bunny_delete_clipable(&pix->clipable);
  return (new_pix);
}
Ejemplo n.º 22
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);
}
Ejemplo n.º 23
0
void			disp_elems(t_params *params, t_lst *element)
{
  t_bunny_pixelarray	*glitched;

  glitched = NULL;
  while (element)
    {
      if (element->hover)
	glitched = glitch(element->background);
      blit(&params->window->buffer,
	   glitched,
	   element,
	   params->config.oculus);
      if (element->hover)
	bunny_delete_clipable(&glitched->clipable);
      element = element->next;
    }
}
Ejemplo n.º 24
0
int	set_vga_size(t_data *data)
{
  if (data->rt.img != NULL)
    bunny_delete_clipable(&data->rt.img->clipable);
  else
    return (0);
  data->rt.width = VGA_WIDTH;
  data->rt.height = VGA_HEIGHT;
  if ((data->rt.img = bunny_new_pixelarray
       (data->rt.width, data->rt.height)) == NULL)
    return (1);
  data->rt.pos = center_rt(&data->rt);
  live_display(&data->rt);
  if (data->rt.img != NULL)
    bunny_blit(&data->win->buffer,
	       &data->rt.img->clipable, &data->rt.pos);
  return (0);
}
Ejemplo n.º 25
0
void	my_free_board(t_board *board)
{
  int	i;

  i = - 1;
  while (board->button[++i] != NULL)
    bunny_free(board->button[i]);
  i = - 1;
  while (board->obj[++i] != NULL)
    {
      bunny_free(board->obj[i]->calque);
      bunny_free(board->obj[i]);
    }
  bunny_delete_clipable(&board->calque->pix->clipable);
  bunny_free(board->calque);
  bunny_free(board->button);
  bunny_free(board->obj);
  bunny_free(board);
}
Ejemplo n.º 26
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);
}
Ejemplo n.º 27
0
void			status8_text_x(t_bunny_pixelarray *pix,
				       t_bunny_window *win, int i)
{
  t_bunny_pixelarray	*letter;
  t_bunny_position	pos;
  t_bunny_position	shift;

  if ((letter = bunny_new_pixelarray(174, 79)) == NULL)
    return ;
  pos.x = 1101;
  pos.y = 566;
  shift.x = 240;
  shift.y = 13;
  transparency_letter(pix, letter, &pos);
  if (i == 0)
    write_text(letter, "X", &shift);
  else
    write_text(letter, "OK", &shift);
  bunny_blit(&(win->buffer), &(letter->clipable), &pos);
  bunny_delete_clipable(&letter->clipable);
}
Ejemplo n.º 28
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);
}
Ejemplo n.º 29
0
t_button		*init_bt(t_bunny_pixelarray *buffer,
				 t_bunny_pixelarray *design_buffer,
				 char (*event)(t_tekpaint*))
{
  t_button		*button;
  t_bunny_pixelarray	*buffer_bt;
  static unsigned int	x_position = 10;

  if (NULL == (button = bunny_malloc(sizeof(*button))))
    return (NULL);
  if (!buffer)
    return (NULL);
  button->width = 50;
  button->height = 50;
  button->pos.x = x_position;
  x_position = x_position + 65;
  button->pos.y = 5;
  button->on_click = event;
  buffer_bt = design_buffer;
  blit_pixelarrays(buffer, buffer_bt, &button->pos);
  bunny_delete_clipable(&buffer_bt->clipable);
  return (button);
}
Ejemplo n.º 30
0
void				display_button(void *buttone, t_data *data)
{
  t_bunny_pixelarray            *pix;
  t_button			*button;

  button = (t_button*)buttone;
  if ((data->crs.pencil_pos.x - 64 <= button->pos.x && data->crs.pencil_pos.x >= button->pos.x)
      && (data->crs.pencil_pos.y - 64 <= button->pos.y && data->crs.pencil_pos.y >= button->pos.y) &&
      data->crs.left_click == 1)
    {
      traverse(data->tool, disable);
      button->active = 1;
      dtraverse(data->tool, check_action_button, data);
    }
  if (button->active == 1)
    {
      pix = shade_of_grey(button->pix);
      bunny_blit(&data->window->buffer, &(pix)->clipable, &button->pos);
      bunny_delete_clipable(&(pix)->clipable);
    }
  else
    bunny_blit(&data->window->buffer, &button->pix->clipable, &button->pos);
}