From 293ac316aa0cd6c1170861fae64801a35d0442a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=CC=81o?= Date: Sat, 17 Jun 2023 14:25:14 +0200 Subject: [PATCH] fix: fix offset --- src/init.c | 6 +++--- src/mouse_and_keys.c | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/init.c b/src/init.c index 2586b88..570206f 100644 --- a/src/init.c +++ b/src/init.c @@ -6,7 +6,7 @@ /* By: lgaudin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/06/16 13:32:20 by lgaudin #+# #+# */ -/* Updated: 2023/06/17 14:09:22 by lgaudin ### ########.fr */ +/* Updated: 2023/06/17 14:21:03 by lgaudin ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,8 +23,8 @@ void init_fractal(t_fractal *fractal) fractal->y = 0; fractal->color = 0xFCBE11; fractal->zoom = 300; - fractal->offset_x = 0; - fractal->offset_y = 0; + fractal->offset_x = -1.21; + fractal->offset_y = -1.21; } /** diff --git a/src/mouse_and_keys.c b/src/mouse_and_keys.c index 0a23cb3..36122e9 100644 --- a/src/mouse_and_keys.c +++ b/src/mouse_and_keys.c @@ -6,7 +6,7 @@ /* By: lgaudin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/06/16 18:11:08 by lgaudin #+# #+# */ -/* Updated: 2023/06/17 14:06:46 by lgaudin ### ########.fr */ +/* Updated: 2023/06/17 14:19:09 by lgaudin ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,21 +37,21 @@ void zoom(t_fractal *fractal, int x, int y, int zoom) return ; } -int key_hook(int keycode, t_fractal *fractal) +int key_hook(int key_code, t_fractal *fractal) { - if (keycode == 53) + if (key_code == 53) exit(1); - else if (keycode == LEFT) + else if (key_code == LEFT) fractal->offset_x -= 42 / fractal->zoom; - else if (keycode == RIGHT) + else if (key_code == RIGHT) fractal->offset_x += 42 / fractal->zoom; - else if (keycode == UP) - fractal->offset_y += 42 / fractal->zoom; - else if (keycode == DOWN) + else if (key_code == UP) fractal->offset_y -= 42 / fractal->zoom; - else if (keycode == R) + else if (key_code == DOWN) + fractal->offset_y += 42 / fractal->zoom; + else if (key_code == R) init_fractal(fractal); - else if (keycode == C) + else if (key_code == C) fractal->color += (255 * 255 * 255) / 100; draw_fractal(fractal, fractal->name); return (0); @@ -66,3 +66,4 @@ int mouse_hook(int mouse_code, int x, int y, t_fractal *fractal) draw_fractal(fractal, fractal->name); return (0); } +