-
Notifications
You must be signed in to change notification settings - Fork 0
/
key_controls_bonus.c
71 lines (66 loc) · 1.9 KB
/
key_controls_bonus.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* key_controls_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vmustone <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/08 00:55:40 by vmustone #+# #+# */
/* Updated: 2023/03/08 00:55:46 by vmustone ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void close_esc(t_vars *vars)
{
mlx_destroy_image(vars->mlx, vars->img);
mlx_destroy_window(vars->mlx, vars->win);
exit (0);
}
int close_cross(t_vars *vars)
{
mlx_destroy_image(vars->mlx, vars->img);
mlx_destroy_window(vars->mlx, vars->win);
exit (0);
return (0);
}
void arrow_move(int button, t_vars *vars)
{
if (button == UP_ARROW)
{
vars->minim += 0.05;
vars->maxim += 0.05;
}
if (button == DOWN_ARROW)
{
vars->minim -= 0.05;
vars->maxim -= 0.05;
}
if (button == LEFT_ARROW)
{
vars->minre -= 0.05;
vars->maxre -= 0.05;
}
if (button == RIGHT_ARROW)
{
vars->minre += 0.05;
vars->maxre += 0.05;
}
}
int key_controls(int button, t_vars *vars)
{
if (button == ESC)
close_esc(vars);
if (button == UP_ARROW)
arrow_move(button, vars);
if (button == DOWN_ARROW)
arrow_move(button, vars);
if (button == LEFT_ARROW)
arrow_move(button, vars);
if (button == RIGHT_ARROW)
arrow_move(button, vars);
if (vars->set == JULIA)
draw_julia(vars);
else
draw_mandelbrot(vars);
return (0);
}