Skip to content

Commit

Permalink
fix: fix offset
Browse files Browse the repository at this point in the history
  • Loading branch information
leogaudin committed Jun 17, 2023
1 parent d616fac commit 293ac31
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: lgaudin <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

Expand All @@ -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;
}

/**
Expand Down
21 changes: 11 additions & 10 deletions src/mouse_and_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: lgaudin <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -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);
Expand All @@ -66,3 +66,4 @@ int mouse_hook(int mouse_code, int x, int y, t_fractal *fractal)
draw_fractal(fractal, fractal->name);
return (0);
}

0 comments on commit 293ac31

Please sign in to comment.