This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathon_button_press.c
84 lines (78 loc) · 2.12 KB
/
on_button_press.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
72
73
74
75
76
77
78
79
80
81
82
83
84
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* on_button_press.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: drestles <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/10 15:51:58 by gkessler #+# #+# */
/* Updated: 2019/02/17 18:08:29 by drestles ### ########.fr */
/* */
/* ************************************************************************** */
#include "rtv1.h"
int exit_x(int a)
{
exit(a);
}
void on_button_press(int key, t_rt *rt)
{
if (key == 69)
{
rt->move.x = 0.0;
rt->move.y = 0.0;
rt->move.z = 0.1;
rt->cam = vec_plus(rt->cam, rt->move);
}
if (key == 78 && rt->cam.z >= 0.1)
{
rt->move.x = 0.0;
rt->move.y = 0.0;
rt->move.z = -0.1;
rt->cam = vec_plus(rt->cam, rt->move);
}
}
void on_button_press_3(int key, t_rt *rt)
{
if (key == 24 && rt->amb < 1.0000)
rt->amb += 0.01;
if (key == 27 && rt->amb > 0.01)
rt->amb -= 0.01;
if (key == 47)
rt->rot_xy += 0.1;
if (key == 43)
rt->rot_xy -= 0.1;
if (key == 37)
rt->rot_yz += 0.1;
if (key == 40)
rt->rot_yz -= 0.1;
if (key == 31)
rt->rot_xz += 0.1;
if (key == 34)
rt->rot_xz -= 0.1;
if (key == 53)
exit(1);
}
void on_button_press_4(int key, t_rt *rt)
{
if (key == 13)
rt->light[0].dot.y += 0.1;
if (key == 1)
rt->light[0].dot.y -= 0.1;
if (key == 2)
rt->light[0].dot.x += 0.1;
if (key == 0)
rt->light[0].dot.x -= 0.1;
if (key == 15)
rt->light[0].dot.z += 0.2;
if (key == 3)
rt->light[0].dot.z -= 0.2;
}
int deal_key(int key, t_rt *rt)
{
on_button_press(key, rt);
on_button_press_3(key, rt);
on_button_press_4(key, rt);
mlx_clear_window(rt->mlx_ptr, rt->win_ptr);
rtv1(rt);
return (0);
}