void init_params(t_params *par) { par->config.oculus = 0; par->sound_toggle = 50; par->curr_opacity = 0; par->intro_volume = 100; par->intro_sound = bunny_load_music("assets/musics/menu_loop.wav"); par->menu_sound = bunny_load_music("assets/musics/menu.wav"); par->window = bunny_start(1920, 1080, 1, "Emmanuel can't, but {DOOM}inique Strauss can"); par->background = bunny_new_pixelarray(1920, 1080); par->game_bg = bunny_new_pixelarray(1920, 1080); par->option = bunny_new_pixelarray(500, 70); par->cur_pos = *bunny_get_mouse_position(); if (!(par->option) || !(par->background) || !(par->window) || !(par->game_bg)) err("Error: can't start Doom\n"); init_buttons(&par->menu_buttons); init_connect(&par->connect_buttons); par->again = GO_ON; par->current = &menu; par->fullscreen = 0; par->origin.x = (par->origin.y = 0); par->data = malloc(sizeof(t_data)); par->data->win = NULL; par->data->message.indice = 200; bunny_sound_play(par->intro_sound); bunny_sound_volume(par->intro_sound, 60); }
int main(int ac, char **av) { t_struct a; if (init_tabl(&a)) return (0); a.k = 0; a.music = NULL; a.back = (ac > 1) ? bunny_load_pixelarray(av[1]) : bunny_load_pixelarray("img/carré2.png"); a.lettre = bunny_load_pixelarray("img/nombres.png"); if (a.lettre == NULL || a.back == NULL) return (0); a.square = bunny_new_pixelarray(SQUARE_SIZE, SQUARE_SIZE); fox_mod_stretch(a.square, a.back); a.nb = bunny_new_pixelarray(SQUARE_SIZE * 9, SQUARE_SIZE); fox_mod_stretch(a.nb, a.lettre); a.win = bunny_start_style(SQUARE_SIZE * 9 + ECART * 2, SQUARE_SIZE * 9 + ECART * 2, TITLEBAR | CLOSE_BUTTON, "Sudoku"); a.pix = bunny_new_pixelarray(SQUARE_SIZE * 9 + ECART * 2, SQUARE_SIZE * 9 + ECART * 2); destroy_windows(a); return (0); }
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); }
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); }
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); }
char alert_box(char *str, t_windows *windows, char type) { t_tektext _tektext; if (NULL == (windows->buffer[2] = bunny_start_style(600, 80, TITLEBAR | CLOSE_BUTTON, "AlertBox"))) return (0); if (NULL == (windows->buff_background[2] = bunny_new_pixelarray(600, 80))) return (0); fill_buffer(windows->buff_background[2], BLACK); _tektext.buff_background = windows->buff_background[2]; if (type == SUCCESS_ALERT_TYPE) _tektext.color = GREEN; else if (type == ERROR_ALERT_TYPE) _tektext.color = RED; else if (type == SUCCESS_ALERT_TYPE) _tektext.color = WHITE; _tektext.pos.x = 10; _tektext.pos.y = 10; _tektext.margin[0] = 5; _tektext.margin[1] = 5; _tektext.text = str; _tektext.scale[0] = 2; _tektext.scale[1] = 2; _tektext.flags = TEKTEXT_X_CENTER | TEKTEXT_Y_CENTER; tektext(&_tektext); }
t_bunny_pixelarray *convert_to_pixelarray(int fd, int width, int height, unsigned char bytes_per_pix) { int nbr_pixs; t_rgb_color color; t_bunny_pixelarray *img_buffer; unsigned int i; unsigned int i2; int pixel; nbr_pixs = width * height; if (NULL == (img_buffer = bunny_new_pixelarray(width, height))) return (NULL); i = 0; while (i < nbr_pixs/width) { i2 = width; while (i2 > 0) { pixel = nbr_pixs - (i * width) - i2--; if (-1 == read(fd, &color, bytes_per_pix)) return (NULL); set_rgb_pixel(img_buffer, pixel, &color); } read(fd, &color, width % 4); i++; } return (img_buffer); }
t_bunny_pixelarray *load_bmp(t_data *data, const char *name) { int fd; int readed; t_bunny_position pos; if ((fd = open(name, O_RDONLY)) == -1) return (NULL); if ((readed = read(fd, &data->bmp, 54)) == -1) return (NULL); data->image = bunny_new_pixelarray(data->bmp.width, data->bmp.height); pos.y = data->bmp.height - 1; while (pos.y != -1) { pos.x = 0; while (readed > 0 && pos.x != data->bmp.width) { pos.x += 1; if ((read(fd, data->buffer, (data->bmp.bits / 8))) == -1) return (NULL); col_tek(data); tekpixel(data->image, pos, data->col_image); } pos.y--; } return (data->image); }
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); }
t_bunny_pixelarray *buttons_load() { t_bunny_pixelarray *pix; t_bunny_square squar; pix = bunny_new_pixelarray(50, 50); init_icon_border(pix); squar.pos.x = 5; squar.pos.y = 40; squar.width = 40; squar.height = 5; square(pix, &squar, WHITE); squar.pos.x = 5; squar.pos.y = 35; squar.width = 5; squar.height = 5; square(pix, &squar, WHITE); squar.pos.x = 40; squar.pos.y = 35; squar.width = 5; squar.height = 5; square(pix, &squar, WHITE); next_load(pix, squar); return (pix); }
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); }
void init_pixel_array(t_lapin *lapin) { int width; int height; if (lapin->pixelarray_2 == NULL) { lapin->pixelarray_2 = bunny_new_pixelarray(1024, 768); background(lapin->pixelarray_2, WHITE); } width = lapin->pixelarray_2->clipable.clip_width; height = lapin->pixelarray_2->clipable.clip_height; lapin->pixelarray_1 = bunny_new_pixelarray(50, 768); lapin->font = bunny_new_pixelarray(1024, 768); lapin->pixelarray_tmp_2 = bunny_new_pixelarray(width, height); lapin->pixelarray_tmp = bunny_new_pixelarray(width, height); lapin->pixelarray_3 = bunny_new_pixelarray(255, 255); lapin->pixelarray_4 = bunny_new_pixelarray(150, 50); lapin->pixelarray_3 = load_bitmap("resoucre/Color_palette.bmp"); background(lapin->pixelarray_tmp, WHITE); background(lapin->font, 0xBEBEBE); background(lapin->pixelarray_tmp_2, WHITE); background(lapin->pixelarray_1, 0x282828); background(lapin->pixelarray_4, 0x282828); }
t_bunny_pixelarray *buttons_empty_border() { t_bunny_pixelarray *pix; if (NULL == (pix = bunny_new_pixelarray(50, 50))) return (NULL); init_icon_border(pix); return (pix); }
void initialisation(t_data *data) { data->map->level = 0; data->ini_name = "ress/map/level0.ini\0"; data->time = 0; data->col = 0; data->pl->move = 0; data->sound = bunny_load_effect("ress/sound/next.ogg"); data->bad = bunny_load_effect("ress/sound/bad.ogg"); data->pos.x = 0; data->pos.y = 0; data->win = bunny_start(800, 600, 0, "wolf"); data->pix = bunny_new_pixelarray(800, 600); data->pl->angle = (data->pl->angle * M_PI) / 180; }
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); }
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); }
int main(void) { t_fire *fire; if ((fire = bunny_malloc(sizeof(t_fire))) == NULL) return (1); fire->win = bunny_start(WIDTH, HEIGHT, false, "Effet de flamme uberti_l"); fire->pix = bunny_new_pixelarray(WIDTH, HEIGHT); set_gradient(fire); set_background(fire->pix, 0x00000000); fixed_col(fire); bunny_set_loop_main_function(main_loop); bunny_loop(fire->win, 60, fire); free_all(fire); return (0); }
void prepare_window(t_data *data) { get_keys2(data->keys); data->win = bunny_start(WIN_X, WIN_Y, data->fullscreen, "TekDoom"); data->pix = bunny_new_pixelarray(WIN_X, WIN_Y); data->interface.map = NULL; data->interface.chat = NULL; data->interface.life = NULL; data->interface.weapon = NULL; data->interface.crosshair = NULL; data->cursor_toggle = 0; data->cursor_pos.x = 5; data->cursor_pos.y = 681; data->max_chat = MAX_CHAT_MSG; data->area = OTHER; }
t_bunny_pixelarray *buttons_circle_border() { t_bunny_pixelarray *pix; t_bunny_position origin; t_bunny_position dist; if (NULL == (pix = bunny_new_pixelarray(50, 50))) return (NULL); init_icon_border(pix); origin.x = 25; origin.y = 25; dist.x = 10; dist.y = 24; my_set_circle(pix, &origin, &dist, WHITE); return (pix); }
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); }
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); }
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); }
t_bunny_pixelarray *bmp_create_pixelarray(int fd) { char buffer[4096]; t_bmp_head head; t_bmp_info info; int len; if ((len = read(fd, &head, sizeof(head))) != sizeof(head)) return (NULL); if ((len = read(fd, &info, sizeof(info))) != sizeof(info)) return (NULL); if ((len = head.offset - (sizeof(head) + sizeof(info))) > 0) { if (read(fd, buffer, len) > 0) (void)buffer; } return (bunny_new_pixelarray(info.width, info.height)); }
static t_scrolling *init_scroll(int k) { t_bunny_pixelarray *pix; t_scrolling *scroll; if ((scroll = bunny_malloc(sizeof(t_scrolling))) == NULL) return (NULL); if (k == 0) pix = bunny_load_pixelarray(PATH_P "para1.png"); else if (k == 1) pix = bunny_load_pixelarray(PATH_P "para2.png"); else pix = bunny_load_pixelarray(PATH_P "para3.png"); scroll->vit = 1 * (k + 1); scroll->pix = bunny_new_pixelarray(WIDTH, HEIGHT); fox_mod_stretch(scroll->pix, pix); scroll->pos = 0; return (scroll); }
t_bunny_pixelarray *fox_load_bmp(const char *path) { t_bunny_pixelarray *img; t_fox_bmpheader bitmap; int fd; fd = open(path, O_RDONLY); bitmap = fox_getbmpheader(fd); my_printf(1, "[Image][BMP] Loading...\n"); if (bitmap.fileheader.filetype[0] == 'B' && bitmap.fileheader.filetype[1] == 'M') { img = bunny_new_pixelarray(bitmap.width, bitmap.height); if (img != NULL) my_printf(1, "Loading: %s%sOk !%s\n", FOREGREEN, STYLEBOLD, STYLERESET); fox_bmptopixel(fd, img, &bitmap); } else my_printf(1, "Loading: %s%sError !%s\n", FORERED, STYLEBOLD, STYLERESET); return (img); }
t_bunny_pixelarray *bmp_loader(const char *path) { t_bunny_pixelarray *img; t_bitmap_header bitmap; int fd; fd = open_bmp(path); bitmap = bmp_header(fd); my_printf("[Image][BMP] load...\n"); if (bitmap.fileheader.filetype[0] == 'B' && bitmap.fileheader.filetype[1] == 'M') { img = bunny_new_pixelarray(bitmap.width, bitmap.height); if (img != NULL) my_printf("[Image][BMP] Ok...\n"); bmp_to_pixel(fd, img, &bitmap); } else my_printf("[Image][BMP] Error...\n"); return (img); }
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); }
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); }
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); }
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); }