Exemple #1
0
int		main(int ac, char **av, char **env)
{
  t_data	*data;
  int		nb;

  (void) ac;
  (void) av;
#ifdef	DEBUG
  memory_check = 1;
#endif
  if (*env == NULL || (nb = bunny_set_max_ram()) == - 1)
    return (1);
  set_max_heap_size(nb);
  if ((data = my_init_data()) == NULL)
    return (1);
  bunny_set_loop_main_function((t_bunny_loop)mainloop);
  bunny_set_key_response((t_bunny_key)escape);
  bunny_set_move_response((t_bunny_move)move);
  bunny_set_click_response((t_bunny_click)click);
  if (bunny_loop(data->win, 90, data) == EXIT_ON_ERROR)
    return (1);
 #ifdef	DEBUG
  write(1, "STATUS: OK\n", 11);
#endif
  return (0);
}
Exemple #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);
}
Exemple #3
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);
}
Exemple #4
0
t_bunny_response	main_loop(t_data *pic)
{
  if (pic->wolf->left == 1)
    left(pic);
  if (pic->wolf->up == 1)
    if (up(pic) == 1)
      return (0);
  if (pic->wolf->down == 1)
    if (down(pic) == 1)
      return (0);
  if (pic->wolf->right == 1)
    right(pic);
  if (pic->wolf->player.health < 0)
    {
      my_putstr("Game Over\n");
      return (0);
    }
  bunny_set_key_response(get_mykey);
  set_background(pic->pix, &pic->color[0]);
  raycasting(pic->wolf, pic->pix);
  health(pic->wolf, pic->pix);
  bunny_blit(&pic->win->buffer, &pic->pix->clipable, NULL);
  bunny_display(pic->win);
  return (GO_ON);
}
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;
}
Exemple #6
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);
}
Exemple #7
0
Fichier : main.c Projet : 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));
}
char			explorer(t_tekpaint *tekpaint, t_explorer *explorer)
{
  tekpaint->tool.explorer = explorer;
  explorer->current_path = "./";
  explorer->img = NULL;
  explorer->win = bunny_start_style(EXPLORER_WIDTH,
			  EXPLORER_HEIGHT, TITLEBAR | CLOSE_BUTTON,
			  explorer->win_name);
  explorer->buffer = bunny_new_pixelarray(EXPLORER_WIDTH, EXPLORER_HEIGHT);
  if (explorer->buffer == NULL)
    return (0);
  fill_buffer(explorer->buffer, BLACK);
  read_files(explorer);
  display_files(tekpaint, explorer, 0);
  bunny_set_key_response(explorer_on_key);
  bunny_set_click_response(NULL);
  bunny_set_loop_main_function((t_bunny_loop)main_loop_explorer);
  bunny_loop(explorer->win, 50, tekpaint);
  explorer_reset(tekpaint, explorer);
  return (1);
}
Exemple #9
0
void		fox_window_starter(t_fox_window *window)
{
  if (window->loop == NULL)
    {
      my_printf(1, "[Fox] no loop set !\n");
      return ;
    }
  bunny_set_loop_main_function(window->loop);
  if (window->key != NULL)
    {
      my_printf(1, "[Fox] Listening keyboard event...\n");
      bunny_set_key_response(window->key);
    }
  if (window->move != NULL && window->click != NULL)
    {
      my_printf(1, "[Fox] Listening mouse event...\n");
      bunny_set_click_response(window->click);
      bunny_set_move_response(window->move);
    }
  bunny_loop(window->win, 60, window);
}
Exemple #10
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);
}
Exemple #11
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);
}
Exemple #12
0
t_bunny_response	loop(void *pass)
{
  t_box		*data;
  t_bunny_key		key;
  t_bunny_click		mouse;

  data = (t_box *)pass;
  key = &echap_down;
  mouse = &mouse_draw;
  bunny_set_key_response(key);
  bunny_set_click_response(mouse);
  if (data->pause == 3)
    exit(0);
  if (data->pause == 2)
    modify_board(data);
  display_board(data);
  bunny_blit(&data->graph->win->buffer, &data->graph->pix->clipable, NULL);
  bunny_display(data->graph->win);
  /* The "2" in the "sleep" below is referring to the time (in second) to wait between two frames during the solving part*/
  if (data->pause > 1)
    sleep(2);
  return (GO_ON);
}
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);
}
Exemple #14
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);
}
Exemple #15
0
t_bunny_response	refresh_my_game(void *data)
{
  t_lapin		*lapin;

  lapin = data;
  bunny_set_key_response(&key);
  bunny_set_click_response(&mouse);
  mouse_position(lapin);
  blit_to_window(lapin->window_1, lapin->pixelarray_1);
  size_bar(lapin->window_1, lapin->font, 50, 0);
  print_bar(lapin);
  if (lapin->save == 1)
    {
      save_bitmap(lapin->str, lapin->pixelarray_2);
      return (EXIT_SUCCESS);
    }
  else if (lapin->save == 2)
    {
      save_file_ftn(lapin->pixelarray_2, lapin->str);
      return (EXIT_SUCCESS);
    }
  return (GO_ON);
}
Exemple #16
0
int		main(int ac, char **av)
{
  t_visu	*visu;

  if (ac == 2 && my_strcmp(av[1], "--help") == 0)
    return (show_help());
  if ((visu = bunny_malloc(sizeof(t_visu))) == NULL)
    return (-1);
  visu->start_rendu = 0;
  if (!(visu->win = bunny_start(WIDTH, HEIGHT, false, "LEMIN DISPLAYER"))
      || (!(visu->pix = bunny_new_pixelarray(WIDTH, HEIGHT)))
      || (check_args(visu) == -1) || (load_ant(visu, av[1]) == -1)
      || (load_screen(visu, av[1]) == -1) || (start_music(visu, av[1]) == -1)
      || (init_ant_struct(visu) == -1))
    return (-1);
  visu->rooms = reverse_rooms(visu->rooms);
  bunny_set_key_response(events);
  bunny_set_loop_main_function(main_loop);
  bunny_loop(visu->win, 60, visu);
  close_music(visu);
  delete_all_clipables(visu);
  free_all(visu);
  return (0);
}