コード例 #1
0
ファイル: get_map.c プロジェクト: kotra97/wolf3D
int     get_map(t_data *data)
{
  int   curs;

  if ((bunny_ini_get_field(data->ini, "level", "width", 0)) == NULL)
    return (-1);
  data->map->height = mygetnbr(bunny_ini_get_field
			      (data->ini, "level", "height", 0));
  data->map->width = mygetnbr
    (bunny_ini_get_field(data->ini, "level", "width", 0));
  if ((data->map->data =
       bunny_malloc(sizeof(int *) * data->map->height)) == NULL)
    return (-1);
  curs = 0;
  while (curs < data->map->height)
    {
      if ((data->map->data[curs] = bunny_malloc
	   (sizeof(int) * data->map->width)) == NULL)
        return (-1);
      curs++;
    }
  fill_the_data(data->ini, data->map->data, data->map->width);
  if ((data->map->spawn = bunny_malloc(sizeof(float) * 3)) == NULL)
    return (-1);
  all_start_here(data->ini, data);
  return (0);
}
コード例 #2
0
ファイル: ini_file.c プロジェクト: lokoum/wolf
int		load_data_field(t_all *all, int i, int j, int count)
{
  char		*b;

  get_width_map(all);
  get_height_map(all);
  b = malloc(sizeof(char) * all->width);
  if ((all->map = bunny_malloc(sizeof(int *) * all->height)) == NULL)
    return (-1);
  while (i < all->height)
    {
      if ((all->map[i] = bunny_malloc(sizeof(int) * all->width)) == NULL)
	return (-1);
      while (j < all->width)
	{
	  b[j] = *(char *)bunny_ini_get_field(all->ini, INI_NAME, "data", count);
	  all->map[i][j] = (b[j] == 49) ? 1 : 0;
	  count++;
	  j++;
	}
      b[all->width] = '\0';
      j = 0;
      i++;
    }
  free(b);
  return (0);
}
コード例 #3
0
ファイル: main.c プロジェクト: ubertil/my_projects
int			init_my_struct(t_ray *ray)
{
  if ((ray->obj = bunny_malloc(sizeof(ray->obj))) == NULL)
    return (1);
  if ((ray->cam = bunny_malloc(sizeof(ray->cam))) == NULL)
    return (1);
  return (0);
}
コード例 #4
0
ファイル: button.c プロジェクト: PierreBougon/Chroma
t_button	*create_button(t_bunny_pixelarray *pix, t_bunny_position pos,
				const char *linke)
{
  t_button	*s;
  char		*link;

  s = bunny_malloc(sizeof(t_calc));
  link = bunny_malloc((strlen(linke) + 1) * sizeof(char));
  strncpy(link, linke, strlen(linke) + 1);
  s->pix = pix;
  s->link = link;
  s->pos = pos;
  s->active = 0;
  return (s);
}
コード例 #5
0
ファイル: bmploader.c プロジェクト: PierreBougon/RayTracer
char			read_pixels(t_loop *loop, int fd, int h, int w)
{
  int			x;
  int			y;
  t_col			*col;
  t_color		*pixels;

  if ((col = bunny_malloc(32)) == NULL)
    return (1);
  if ((loop->pix = bunny_new_pixelarray(w, h)) == NULL)
    return (1);
  pixels = (t_color *)loop->pix->pixels;
  y = h;
  while (--y >= 0)
    {
      x = -1;
      while (++x < w)
	{
	  if ((read(fd, col, 4)) < 0)
	    return (1);
	  pixels[x + y * w].argb[0] = col->alpha;
	  pixels[x + y * w].argb[1] = col->b;
	  pixels[x + y * w].argb[2] = col->r;
	  pixels[x + y * w].argb[3] = col->a;
	}
    }
  return (0);
}
コード例 #6
0
ファイル: tekline.c プロジェクト: faille76/Raytracer1
t_color		*tekline_colorconvert(int len, int coord, t_color *color)
{
  int		i;
  float		aug[3];
  t_color	*col;

  i = 1;
  aug[0] = 0;
  aug[1] = 0;
  aug[2] = 0;
  if ((col = bunny_malloc(sizeof(*col))) == NULL)
    return (NULL);
  while (i <= len)
    {
      aug[0] += ((float)color[1].argb[0] - (float)color[0].argb[0])
	  / (float)coord;
      aug[1] += ((float)color[1].argb[1] - (float)color[0].argb[1])
	  / (float)coord;
      aug[2] += ((float)color[1].argb[2] - (float)color[0].argb[2])
	  / (float)coord;
      col->argb[0] = color[0].argb[0] + (int)aug[0];
      col->argb[1] = color[0].argb[1] + (int)aug[1];
      col->argb[2] = color[0].argb[2] + (int)aug[2];
      i++;
    }
  return (col);
}
コード例 #7
0
ファイル: main.c プロジェクト: mairesb/my_epi_work
int			main(int ac, char **av)
{
  t_lapin		*lapin;
  t_bunny_pixelarray 	*tmp;

  set_max_heap_size(30);
  lapin = bunny_malloc(sizeof *lapin);
  if (lapin == NULL)
    return (84);
  lapin->format = parse(ac, av);
  if (lapin->format == 1)
    tmp = load_bitmap(av[1]);
  else if (lapin->format == 2)
    tmp = load_ftn(av[1]);
  if (lapin->format == -1)
    return (1);
  if (lapin->format != -1 && tmp == NULL)
    tmp = NULL;
  lapin->pixelarray_2 = tmp;
  lapin = set_lapin(lapin);
  lapin->str = av[1];
  if (lapin )
    bunny_set_loop_main_function(&refresh_my_game);
  bunny_loop(lapin->window_1, 250, lapin);
  free_all(lapin);
  return (0);
}
コード例 #8
0
int		load_faces(t_triangle *tri, char **tab)
{
  t_face	*tmp;
  unsigned int	i;

  i = 0;
  if ((tmp = bunny_malloc(sizeof(t_face) * (tri->nb_face + 1))) == NULL)
    return (my_perror(MALLOC_F));
  while (i != tri->nb_face)
    {
      tmp[i] = tri->face[i];
      i = i + 1;
    }
  if (((tmp[i].f = my_getnbr(tab[1])) == 0) ||
      ((tmp[i].s = my_getnbr(tab[2])) == 0) ||
      ((tmp[i].t = my_getnbr(tab[3])) == 0))
    return (-1);
  if (tmp[i].f > tri->nb_vertices ||
      tmp[i].s > tri->nb_vertices ||
      tmp[i].t > tri->nb_vertices)
    return (my_perror(W_VERTC));
  tri->face = tmp;
  tri->nb_face += 1;
  if (my_tablen(tab) == 5)
    if (load_second_face(tri, tab) == -1)
      return (-1);
  return (0);
}
コード例 #9
0
ファイル: setnbr.c プロジェクト: PierreBougon/Chroma
char    *cleanstr(char *nbr)
{
  char  *clean;
  int   p;
  int   i;

  if ((clean = bunny_malloc(sizeof(char) * 10)) == NULL)
    return (NULL);
  clean = set_line_null(clean, 10);
  p = 0;
  while (nbr[p++] == '0' && p < 10);
  if (p == 10)
    {
      clean[0] = '0';
      clean[1] = 0;
      bunny_free(nbr);
      return (clean);
    }
  i = 0;
  p--;
  while (nbr[p] != 0)
    clean[i++] = nbr[p++];
  bunny_free(nbr);
  return (clean);
}
コード例 #10
0
ファイル: main.c プロジェクト: DarmaN1/Wolf3D
t_wolf	*init_map(char *av)
{
  t_wolf	*wolf;
  t_bunny_ini_scope	*scope;
  t_bunny_ini	*ini;

  if ((wolf = bunny_malloc(sizeof(t_wolf))) == NULL)
    return ((t_wolf *)-1);
  if ((ini = bunny_load_ini(av)) == NULL)
    return ((t_wolf *)-1);
  scope = bunny_ini_first(ini);
  scope = bunny_ini_next(ini, scope);
  wolf->s_name = bunny_ini_scope_name(ini, scope);
  wolf->width = 0;
  wolf->height = 0;
  wolf = get_dim(wolf, ini);
  if (check_air(wolf, ini) == -1)
    return ((t_wolf *)-1);
  wolf = get_map(wolf, ini);
  wolf = get_player(wolf, ini);
  if (init_error(wolf) == -1)
    return ((t_wolf *)-1);
  bunny_delete_ini(ini);
  return (wolf);
}
コード例 #11
0
ファイル: save.c プロジェクト: MeixDev/gfx_tekpaint_2015
int			import_format_fox(int 		fd,
					  t_tekpain 	*paint)
{
  t_format_fox_header	header;
  t_layer		*cur;
  char			name[1024];
  unsigned int		*pixels;

  if (read(fd, &header, sizeof(t_format_fox_header)) == -1)
    return (my_printf(2, "Erreur read import_format_fox\n"));
  paint->workzone = header.workzone;
  if ((pixels = bunny_malloc(sizeof(unsigned int) * header.workzone.x
		   * header.workzone.y)) == NULL)
    return (-1);
  while (header.count--)
    {
      read(fd, &name, sizeof(char) * 1024);
      layer_add(paint, layer_new(name,
				 bunny_new_pixelarray(header.workzone.x,
						      header.workzone.y), 0));
      cur = paint->current_layer->data;
      read(fd, pixels, sizeof(unsigned int) * header.workzone.x
	   * header.workzone.y);
      my_memcpy(cur->pix->pixels, pixels,
		sizeof(unsigned int) * header.workzone.x * header.workzone.y);
    }
  bunny_free(pixels);
  return (0);
}
コード例 #12
0
ファイル: save.c プロジェクト: Arthok/tek_paint
int			save(t_struct *my_st, int tmp, int j)
{
  int			i;
  int			fd;
  unsigned int		*pixarray;

  pixarray = my_st->pix->pixels;
  if (tmp == 0)
    {
      good_save(my_st);
      if ((fd = open(my_st->file, O_RDWR | O_CREAT, 00644)) == 1)
	return (1);
    }
  else if ((fd = open(".tmp", O_RDWR | O_CREAT, 00644)) == 1)
    return (1);
  while (j++ < my_st->pix->clipable.clip_height)
    {
      i = 160;
      while (i++ < my_st->pix->clipable.clip_width)
	write(fd, &pixarray[i + j * my_st->pix->clipable.clip_width], 4);
    }
  close(fd);
  bunny_free(my_st->file);
  if ((my_st->file = bunny_malloc(sizeof(char) * 1)) == NULL)
    return (EXIT_ON_ERROR);
  my_st->file[0] = '\0';
  return (0);
}
コード例 #13
0
int		load_hole_cube(t_rt *rt,
			  t_bunny_ini *ini,
			  char *scope)
{
  t_object	*it;
  t_hole_cube	*s;

  if ((s = bunny_malloc(sizeof(t_hole_cube))) == NULL)
    return (-1);
  if (rt->obj == NULL)
    {
      if ((rt->obj = create_obj_list()) == NULL)
	return (-1);
    }
  else
    {
      if (add_obj_elem(rt->obj) == -1)
	return (-1);
    }
  it = rt->obj;
  while (it->next != NULL)
    it = it->next;
  it->type = HOLE_CUBE;
  if (load_hole_cube_datas1(s, ini, scope) == -1)
    return (-1);
  it->datas = s;
  return (0);
}
コード例 #14
0
ファイル: tekpaint.c プロジェクト: PierreBougon/Chroma
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);
}
コード例 #15
0
ファイル: scrolling.c プロジェクト: plean/Info
void			scrolling(t_bunny_pixelarray *pix, int *i)
{
  static t_scrolling	**scroll = NULL;
  static unsigned int	*pixel[NB_SCROLLS];
  int			x;
  int			k;
  int			p;

  *i = (*i - 1 + WIDTH) % WIDTH;
  full_color(pix, BLACK);
  if (scroll == NULL)
    {
      if ((scroll = bunny_malloc(sizeof(t_scrolling*) * (NB_SCROLLS + 1))) == NULL)
	return ;
      k = -1;
      while (++k < NB_SCROLLS && (scroll[k] = init_scroll(k)))
	pixel[k] = (unsigned int *)scroll[k]->pix->pixels;
    }
  k = -1;
  while (++k < NB_SCROLLS && (p = -1))
    while (++p <= WIDTH / scroll[k]->pix->clipable.clip_width && (x = -1))
	while (++x < scroll[k]->pix->clipable.clip_width *
	       (scroll[k]->pix->clipable.clip_height - 1))
	    t_tekpixel(pix, scroll[k]->pos + x / scroll[k]->pix->clipable.clip_width,
      ((*i * scroll[k]->vit) + x % scroll[k]->pix->clipable.clip_width +
       p * scroll[k]->pix->clipable.clip_width) % WIDTH, pixel[k][x]);
}
コード例 #16
0
ファイル: main.c プロジェクト: ubertil/my_projects
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);
}
コード例 #17
0
ファイル: print_screen.c プロジェクト: plean/Info
void			print_screen(t_base *a)
{
  t_bunny_position	pos;
  int			i;

  i = -1;
  a->color_pixel = bunny_malloc(sizeof(t_color_pixel));
  while (++i < a->pix->clipable.clip_width * a->pix->clipable.clip_height)
    {
      a->color_pixel->delt = -1;
      pos.x = i % a->pix->clipable.clip_width;
      pos.y = i / a->pix->clipable.clip_width;
      print_pixel(a, pos);
      if (a->color_pixel->delt != -1)
	{
	  dist_light(a);
	  pixel(a->pix, &pos, a->color_pixel->color);
	}
    }
  bunny_free(a->color_pixel);
  while (a->element)
    a->element = del_mylist(a->element);
  while (a->light)
    a->light = del_mylist(a->light);
}
コード例 #18
0
ファイル: shape_2.c プロジェクト: mairesb/my_epi_work
void			paint_circle(t_bunny_position *pos, int radius,
				     t_bunny_pixelarray *pix, t_color *color)
{
  int			x;
  int			y;
  int			corr;
  t_bunny_position	*coord;

  y = -radius;
  coord = bunny_malloc(sizeof(coord));
  while (y <= radius)
    {
      x = -radius - 1;
      corr = 0;
      while (++x <= radius)
	{
	  if (x * x + y * y <= radius * radius)
	    {
	      corr = 1;
	      coord->x = pos->x + x;
	      coord->y = pos->y + y;
	      tekpixel(pix, coord, color);
	    }
	  else if (corr == 1)
	    x = radius;
	}
      y++;
    }
}
コード例 #19
0
ファイル: memory.c プロジェクト: Antonito/Raytracer
void		*my_malloc(size_t size)
{
  void		*ptr;

  if (!(ptr = bunny_malloc(size)))
    my_puterr("Malloc Failed !\n");
  return (ptr);
}
コード例 #20
0
ファイル: load_node.c プロジェクト: Blanchard-A/TekAdventure
int	malloc_node_2(t_data *data)
{
  int	i;

  i = 0;
  if ((data->plan[0]->node = bunny_malloc(sizeof(t_node *) * 4)) == NULL)
    return (-1);
  while (i < 3)
    {
      if ((PLAN->node[i] = bunny_malloc(sizeof(t_node) * 1)) == NULL ||
	  (PLAN->node[i]->way = bunny_malloc(sizeof(int) * 3)) == NULL)
	return (-1);
      i++;
    }
  data->plan[0]->node[3] = NULL;
  return (0);
}
コード例 #21
0
t_scope		*init_scope(void *scope)
{
  t_scope	*head;

  if ((head = bunny_malloc(sizeof(t_scope))) == NULL)
    return (NULL);
  head->scope = scope;
  head->next = NULL;
  return (head);
}
コード例 #22
0
ファイル: init_board.c プロジェクト: Blanchard-A/TekAdventure
int	init_obj(t_obj **obj)
{
  int	i;

  i = - 1;
  while (++i < NB_OBJ)
    {
      if ((obj[i] = bunny_malloc(sizeof(*obj[i]))) == NULL ||
	  (obj[i]->calque = bunny_malloc(sizeof(*obj[i]->calque))) == NULL)
	return (- 1);
      obj[i]->calque->x = X_OBJ + (i % (NB_OBJ / 2)) * (OBJ_WIDTH + OBJ_STEP);
      obj[i]->calque->y = Y_OBJ + (i / (NB_OBJ / 2)) * (OBJ_HEIGHT + OBJ_STEP);
      obj[i]->name = NULL;
      obj[i]->desc = NULL;
      obj[i]->close = 0;
    }
  obj[i] = NULL;
  return (0);
}
コード例 #23
0
t_bunny_position	*mouse_history_add(const t_bunny_position *mouse_pos)
{
  t_bunny_position	*pos;

  if ((pos = bunny_malloc(sizeof(t_bunny_position))) == NULL)
    return (NULL);
  pos->x = mouse_pos->x;
  pos->y = mouse_pos->y;
  return (pos);
}
コード例 #24
0
ファイル: calloc.cpp プロジェクト: Blanchard-A/TekAdventure
void			*bunny_calloc(size_t		nmemb,
				      size_t		data)
{
  void			*ptr;
  int			i;

  if ((ptr = bunny_malloc(i = nmemb * data)) == NULL)
    return (NULL);
  return (memset(ptr, 0, i));
}
コード例 #25
0
ファイル: font.c プロジェクト: Arthok/tek_paint
char			*str_realloc(char *str, int size)
{
  char			*tmp;

  if ((tmp = bunny_malloc(sizeof(char) * size)) == NULL)
    return (NULL);
  str_all(tmp, NULL, 0, size);
  str_all(tmp, str, 1, 0);
  bunny_free(str);
  return (tmp);
}
コード例 #26
0
int		my_malloc_plan(t_data *data, int nb_calc)
{
  int		j;

  j = 0;
  if ((data->plan = bunny_malloc(sizeof(t_plan *) * 1)) == NULL ||
      (data->plan[0] = bunny_malloc(sizeof(t_plan) * 1)) == NULL ||
      (data->plan[0]->calque = bunny_malloc(sizeof(t_calque *) *
					    (nb_calc + 1))) == NULL)
    return (-1);
  j = 0;
  while (j < nb_calc)
    {
      if ((data->plan[0]->calque[j] =
	   bunny_malloc(sizeof(t_calque) * 1)) == NULL)
	return (-1);
      j++;
    }
  return (0);
}
コード例 #27
0
ファイル: main.c プロジェクト: kotra97/wolf3D
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);
}
コード例 #28
0
t_data		*my_init_data()
{
  t_data	*data;

  if ((data = bunny_malloc(sizeof(t_data))) == NULL ||
      (my_malloc_plan(data, 8) != 0) ||
      (data->pix = bunny_new_pixelarray(WIN_X, WIN_Y)) == NULL ||
      (data->win = bunny_start(WIN_X, WIN_Y, false, WIN_NAME)) == NULL ||
      (data->pos = bunny_malloc(sizeof(t_bunny_position))) == NULL ||
      (data->board = my_init_board()) == NULL ||
      (data->text = init_text()) == NULL ||
      load_decor_1(data) == NULL || load_node_1(data) == -1 ||
      malloc_and_load_perso(data) == NULL ||
      (data->player->chemin = bunny_malloc(sizeof(int) * 11)) == NULL)
    return (NULL);
  my_init_value(data);
#ifdef DEBUG
  write(1, "INIT: OK\n", 9);
#endif
  return (data);
}
コード例 #29
0
ファイル: init_board.c プロジェクト: Blanchard-A/TekAdventure
t_board		*my_init_board()
{
  t_board	*board;

  if ((board = bunny_malloc(sizeof(*board))) == NULL ||
      (board->button =
       bunny_malloc(sizeof(*board->button) * (NB_BUTTON + 1))) == NULL ||
      (board->obj =
       bunny_malloc(sizeof(*board->obj) * (NB_OBJ + 1))) == NULL ||
      init_button(board->button) == - 1 || init_obj(board->obj) == - 1 ||
      (board->calque = bunny_malloc(sizeof(*board->calque))) == NULL ||
      (board->calque->pix = load_bitmap(BOARD_BMP)) == NULL)
    return (NULL);
  board->calque->x_speed = 0;
  board->calque->y_speed = 0;
  board->calque->x_init = 0;
  board->calque->y_init = 0;
  board->calque->x = 0;
  board->calque->y = 720;
  board->calque->scale = 100;
  board->sel = ID_GO;
  return (board);
}
コード例 #30
0
ファイル: get_chmp.c プロジェクト: MrDarkSkil/coreware
char                    *get_chmp(char *chmp,
                                  t_bunny_ini *file,
				  int i)
{
  int                   size;
  char                  *str;

  size = my_strlen((char *)bunny_ini_get_field(file, NULL, chmp, i));
  if (size == 0)
    return (NULL);
  if ((str = bunny_malloc(sizeof(char *) * size)) == NULL)
    return (NULL);
  my_strcpy(str, (char *)bunny_ini_get_field(file, NULL, chmp, i));
  return (str);
}