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); }
t_bunny_response bunny_box_move(const t_bunny_position *rel, void *data) { const t_bunny_position *mpos = bunny_get_mouse_position(); t_bunny_box_system *box = (t_bunny_box_system*)data; t_bunny_gui_box *x = &box->screen; t_bunny_response ret; (void)rel; if ((ret = search_box(data, x, *mpos)) < GO_ON) return (ret); if (ret == NOTHING_HAPPENED) { if (box->hovered && box->hovered->mouse_out) box->hovered->mouse_out(box, box->hovered); box->hovered = NULL; if (box->head.subcontext.move) if ((ret = box->head.subcontext.move(mpos, data)) < GO_ON) return (ret); if (box->subhead) if ((ret = box->subhead->subcontext.move(mpos, data)) < GO_ON) return (ret); } return (ret); }
t_bunny_response on_palette_event_click(t_bunny_event_state state, t_bunny_mousebutton key, void *datas) { t_tekpaint *tekpaint; t_palette *palette; unsigned int color; tekpaint = (t_tekpaint*) datas; palette = &tekpaint->tool.palette; tekpaint->tool.current_tool = 0; color = get_pixel(palette->buffer, bunny_get_mouse_position()->x, bunny_get_mouse_position()->y); tekpaint->tool.color = color; return (EXIT_ON_CROSS); }
void set_color_tool(t_data *data) { t_bunny_position pos[1]; data->crs.pencil_pos.x = bunny_get_mouse_position()[0].x; data->crs.pencil_pos.y = bunny_get_mouse_position()[0].y; if (data->crs.pencil_pos.x - 255 <= WIN_WIDTH - 5 && data->crs.pencil_pos.x >= WIN_WIDTH - 260 && data->crs.pencil_pos.y >= 112 && data->crs.pencil_pos.y <= 142 && data->crs.left_click == 1) { data->swatch.col_tofade.full = getpixelcolor (data->swatch.pix2, poser(data->crs.pencil_pos.x - (WIN_WIDTH - 260), 0, pos)); } set_color_tool2(data); }
void set_color_tool2(t_data *data) { t_bunny_position pos[1]; data->crs.pencil_pos.x = bunny_get_mouse_position()[0].x; data->crs.pencil_pos.y = bunny_get_mouse_position()[0].y; if (data->crs.pencil_pos.x - 255 <= WIN_WIDTH - 5 && data->crs.pencil_pos.x >= WIN_WIDTH - 260 && data->crs.pencil_pos.y >= 2 && data->crs.pencil_pos.y <= 102 && data->crs.left_click == 1) { data->tools.color.full = getpixelcolor (data->swatch.pix, poser(data->crs.pencil_pos.x - (WIN_WIDTH - 260), data->crs.pencil_pos.y - 2, pos)); data->tools.color.argb[3] = 255; } }
void get_line_init(void *_data) { t_data *data; const t_bunny_position *pos; data = _data; pos = bunny_get_mouse_position(); data->line.init_pos.x = pos->x - data->crs.calc->pos.x; data->line.init_pos.y = pos->y - data->crs.calc->pos.y; }
void print_mouse_position() { const t_bunny_position *mouse_pos; mouse_pos = bunny_get_mouse_position(); my_putstr("Mouse position : X --> "); my_putnbr(mouse_pos->x); my_putstr(" Y --> "); my_putnbr(mouse_pos->y); my_putstr("\n"); }
void get_line_final(void *_data) { t_data *data; const t_bunny_position *pos; data = _data; pos = bunny_get_mouse_position(); data->line.final_pos.x = pos->x - data->crs.calc->pos.x; data->line.final_pos.y = pos->y - data->crs.calc->pos.y; draw_final_line(data); }
void my_init_value(t_data *data) { data->id_plan = 0; data->player->vec[0] = 0; data->player->vec[1] = 0; data->player->coef[0] = 0; data->player->coef[1] = 0; data->loop = 0; data->player->chemin[0] = -1; data->pos->x = PIX_X; data->pos->x = PIX_Y; data->mouse = (t_bunny_position *) bunny_get_mouse_position(); }
t_bunny_response mouse_click(t_bunny_event_state state, t_bunny_mousebutton button, void *data) { t_bunny_position pos; t_struct *b; b = (t_struct*)data; (void)b; pos = *bunny_get_mouse_position(); if (state == GO_UP && button == BMB_LEFT) incr_case(b, &pos, 1); else if (state == GO_UP && button == BMB_RIGHT) incr_case(b, &pos, -1); return (GO_ON); }
t_bunny_response mouse_draw(t_bunny_event_state state, t_bunny_mousebutton button, void *your_data) { t_box *data; t_bunny_position *pos; int tmp; data = (t_box *)your_data; (void)button; if (state == GO_DOWN && data->pause != 2) { pos = (t_bunny_position *)bunny_get_mouse_position(); tmp = pos->x; pos->x = pos->y; pos->y = tmp; if (data->pause == 1 && data->board[pos->y / 10][pos->x / 10] == 1) { if (data->maillon->pos.y != -1 && data->maillon->pos.x != -1) data->board[data->maillon->pos.y][data->maillon->pos.x] = 1; data->board[pos->y / 10][pos->x / 10] = 2; data->maillon->pos.y = pos->y / 10; data->maillon->pos.x = pos->x / 10; return (GO_ON); } if (data->pause == 1 && data->board[pos->y / 10][pos->x / 10] == 2) { data->board[pos->y / 10][pos->x / 10] = 1; return (GO_ON); } if (data->pause == 0 && data->board[pos->y / 10][pos->x / 10] == 1) { data->board[pos->y / 10][pos->x / 10] = 0; return (GO_ON); } if (data->pause == 0 && data->board[pos->y / 10][pos->x / 10] == 0) { data->board[pos->y / 10][pos->x / 10] = 1; return (GO_ON); } } return (GO_ON); }
t_bunny_response my_exit(t_bunny_event_state state, t_bunny_keysym key, void *data) { t_bunny_position pos; t_struct *b; b = (t_struct*)data; (void)b; pos = *bunny_get_mouse_position(); if (state == GO_DOWN && key == BKS_ESCAPE) return (EXIT_ON_SUCCESS); else if (state == GO_DOWN && key == BKS_C) b->is_printable[pos.y / (b->pix->clipable.clip_height / 9)] [pos.x / (b->pix->clipable.clip_width / 9)] = (check_same(b->grille, b->res_grille, pos.y / (b->pix->clipable.clip_height / 9), pos.x / (b->pix->clipable.clip_width / 9))); else if (state == GO_DOWN && key == BKS_RETURN) check_is_finish(b); return (GO_ON); }
void event_boot(t_tek *tekpaint) { int i; i = 0; tekpaint->mouse.mouse_pos = (t_bunny_position *)bunny_get_mouse_position(); while (i <= NB_EVENT) { if (tekpaint->mouse.mouse_pos->x >= tekpaint->mouse.zone[i][0].x && tekpaint->mouse.mouse_pos->x <= tekpaint->mouse.zone[i][1].x && tekpaint->mouse.mouse_pos->y >= tekpaint->mouse.zone[i][0].y && tekpaint->mouse.mouse_pos->y <= tekpaint->mouse.zone[i][1].y) { tekpaint->mouse.func_event[i](tekpaint, &tekpaint->mouse); return ; } else { i++; } } }