static t_bunny_response loop(void *data) { t_bunny_position pos; t_bunny_position mid; (void)data; bunny_fill(&win->buffer, ALPHA(32, BLACK)); pos.x = win->buffer.width / 2; pos.y = win->buffer.height / 2; pic[0]->rotation = rotation; pic[1]->rotation = rotation + cos(8 * rotation * M_PI / 180.0); pic[0]->scale.x = 2 + cos(scale * M_PI / 180.0); pic[0]->scale.y = 2 + cos(scale * M_PI / 180.0); pic[1]->scale.x = 2.2 + sin(scale2 * M_PI / 180.0); pic[1]->scale.y = 2.2 + sin(scale2 * M_PI / 180.0); rotation += 1; scale += 2; scale2 -= 1; mid.x = win->buffer.width / 2; mid.y = win->buffer.height / 2; bunny->rotation = -rotation * 2; bunny->scale.x = 2 - cos(scale * M_PI / 180.0); bunny->scale.y = 2 + sin(scale * M_PI / 180.0); bunny_blit(&win->buffer, pic[0], &pos); bunny_blit(&win->buffer, bunny, &mid); bunny_blit(&win->buffer, pic[1], &pos); bunny_display(win); return (GO_ON); }
void kala_afterslam(t_kala *data) { if (data->intro.state == 4) { bunny_fill(&data->shard->buffer, data->intro.black.full); bunny_clear(&data->win->buffer, 0xFF000000); data->intro.blit.x = (data->win->buffer.width / 2 - data->shard->buffer.width / 2) + ((rand() % (int)(data->intro.slam + 1)) - data->intro.slam / 2) + data->shard->origin.x; data->intro.blit.y = (data->win->buffer.height / 2 - data->shard->buffer.height / 2) + ((rand() % (int)(data->intro.slam + 1)) - data->intro.slam / 2) + data->shard->origin.y; data->shard->rotation = (rand() % (int)((data->intro.slam / 5) + 1) - data->intro.slam / 10); bunny_blit(&data->win->buffer, data->shard, &data->intro.blit); kala_afterslam_second(data); if (data->intro.black.argb[3] >= 50) { data->intro.state = 5; data->intro.black.full = 0x00000000; } } }
static void square(t_bunny_picture *pic, int x, int y, int w, int h, unsigned int c) { pic->clip_x_position = x; pic->clip_y_position = y; pic->clip_width = w; pic->clip_height = h; bunny_fill(&pic->buffer, c); }
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); } }
t_bunny_response display_function(void *d) { t_main_data *data = (t_main_data*)d; bunny_fill(&data->win->buffer, ALPHA(64, BLACK)); t_bunny_position circle_position; t_bunny_position circle_size; circle_position.x = data->win->buffer.width / 2; circle_position.y = data->win->buffer.height / 2; circle_size.x = cos(data->step) * data->win->buffer.width / 2; circle_size.y = sin(data->step) * data->win->buffer.height / 2; bunny_set_circle(&data->win->buffer, circle_position, circle_size, RED); unsigned int col[2] = {BLACK, RED}; t_bunny_position pos[2]; double additional_step; pos[0].x = circle_position.x; pos[0].y = circle_position.y; for (additional_step = 0; additional_step < 1; additional_step += 0.05) { pos[1].x = pos[0].x + cos(2.3 * data->step + additional_step) * circle_size.x * (1 - additional_step); pos[1].y = pos[0].y + sin(2.3 *data->step + additional_step) * circle_size.y * (1 - additional_step); bunny_set_line(&data->win->buffer, &pos[0], &col[0]); pos[1].x = pos[0].x - cos(2.3 * data->step + additional_step) * circle_size.x * (1 - additional_step); pos[1].y = pos[0].y - sin(2.3 * data->step + additional_step) * circle_size.y * (1 - additional_step); bunny_set_line(&data->win->buffer, &pos[0], &col[0]); } bunny_display(data->win); return (GO_ON); }