-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add:(vSKAH): "esc" key now exit game add:(vSKAH): Nb of movements are now print in shell add:(vSKAH): ft_printf is now in libft
- Loading branch information
Showing
19 changed files
with
414 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_base.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: jbadaire <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/10/14 15:22:00 by jbadaire #+# #+# */ | ||
/* Updated: 2023/10/14 15:22:00 by jbadaire ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "libft.h" | ||
|
||
int ft_base(unsigned long number, int base_number, char base_array[], int value) | ||
{ | ||
char character; | ||
|
||
value = 0; | ||
if (number >= (unsigned long)base_number) | ||
{ | ||
value += ft_base(number / base_number, base_number, base_array, value); | ||
value += ft_base(number % base_number, base_number, base_array, value); | ||
} | ||
else | ||
{ | ||
character = base_array[number]; | ||
value += ft_putchar_fd(character, 1); | ||
return (value); | ||
} | ||
return (value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* args_handler.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: jbadaire <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/09/06 18:39:32 by jbadaire #+# #+# */ | ||
/* Updated: 2023/09/18 08:23:56 by jbadaire ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "../libft.h" | ||
|
||
int ft_args_handler(char c, va_list params) | ||
{ | ||
int value; | ||
|
||
value = 0; | ||
if (c == 'c') | ||
value = ft_get_char(params); | ||
else if (c == 's') | ||
value = ft_get_string(params); | ||
else if (c == 'u') | ||
value = ft_get_unsigned_integer(params); | ||
else if (c == 'd' || c == 'i') | ||
value = ft_get_integer(params); | ||
else if (c == 'x') | ||
value = ft_get_base16(params, "0123456789abcdef"); | ||
else if (c == 'X') | ||
value = ft_get_base16(params, "0123456789ABCDEF"); | ||
else if (c == 'p') | ||
value = ft_get_address(params, "0123456789abcdef"); | ||
else if (c == '%') | ||
value = ft_putchar_fd('%', 1); | ||
return (value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* get_address.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: jbadaire <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/09/07 18:21:53 by jbadaire #+# #+# */ | ||
/* Updated: 2023/09/18 08:54:49 by jbadaire ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "../libft.h" | ||
|
||
int ft_get_address(va_list param, char *base_array) | ||
{ | ||
size_t number; | ||
int value; | ||
|
||
number = va_arg(param, size_t); | ||
value = 0; | ||
if (number == 0) | ||
return (ft_putstr_fd("(nil)", 1)); | ||
value += ft_putstr_fd("0x", 1); | ||
value += ft_base(number, 16, base_array, 0); | ||
return (value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* get_base16.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: jbadaire <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/09/07 18:10:35 by jbadaire #+# #+# */ | ||
/* Updated: 2023/09/12 14:58:19 by jbadaire ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "../libft.h" | ||
|
||
int ft_get_base16(va_list param, char *base) | ||
{ | ||
unsigned int number; | ||
|
||
number = va_arg(param, unsigned int); | ||
return (ft_base(number, 16, base, 0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* get_char.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: jbadaire <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/09/06 18:47:16 by jbadaire #+# #+# */ | ||
/* Updated: 2023/09/12 13:56:35 by jbadaire ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "../libft.h" | ||
|
||
int ft_get_char(va_list param) | ||
{ | ||
char c; | ||
|
||
c = va_arg(param, int); | ||
return (ft_putchar_fd(c, 1)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* get_integer.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: jbadaire <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/09/07 18:18:42 by jbadaire #+# #+# */ | ||
/* Updated: 2023/09/12 13:57:52 by jbadaire ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "../libft.h" | ||
|
||
int ft_get_integer(va_list param) | ||
{ | ||
int value; | ||
|
||
value = va_arg(param, int); | ||
return (ft_putnbr_fd(value, 1)); | ||
} | ||
|
||
int ft_get_unsigned_integer(va_list param) | ||
{ | ||
unsigned int value; | ||
int return_value; | ||
|
||
value = va_arg(param, unsigned int); | ||
return_value = 0; | ||
return_value += ft_put_unsigned_nbr_fd(value, 1); | ||
return (return_value); | ||
} |
Oops, something went wrong.