Adding the starting of cub
This commit is contained in:
parent
3c74145832
commit
9415f843e7
7 changed files with 230 additions and 0 deletions
5
.clangd
Normal file
5
.clangd
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
CompilerFlags:
|
||||||
|
Add:
|
||||||
|
- "-xc"
|
||||||
|
- "-I/Users/raphael/Documents/42_cursus/circle4/Cub3D//sources"
|
||||||
|
- "-I/Users/raphael/Documents/42_cursus/circle4/Cub3D/includes"
|
||||||
BIN
Cub3D
Executable file
BIN
Cub3D
Executable file
Binary file not shown.
122
Makefile
Normal file
122
Makefile
Normal file
|
|
@ -0,0 +1,122 @@
|
||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# ::: :::::::: #
|
||||||
|
# Makefile :+: :+: :+: #
|
||||||
|
# +:+ +:+ +:+ #
|
||||||
|
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||||
|
# +#+#+#+#+#+ +#+ #
|
||||||
|
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||||
|
# Updated: 2024/10/30 16:48:22 by rparodi ### ########.fr #
|
||||||
|
# #
|
||||||
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
|
||||||
|
# Name
|
||||||
|
NAME = Cub3D
|
||||||
|
|
||||||
|
# Commands
|
||||||
|
CC = cc
|
||||||
|
RM = rm -rf
|
||||||
|
|
||||||
|
# Flags
|
||||||
|
CFLAGS = -Werror -Wextra -Wall
|
||||||
|
CFLAGS += -g3 -MMD
|
||||||
|
#-lm
|
||||||
|
|
||||||
|
# CFLAGS += -fsanitize=address
|
||||||
|
# CFLAGS += -fsanitize=thread
|
||||||
|
|
||||||
|
INCLUDES = ./includes/
|
||||||
|
|
||||||
|
SRC = sources/main.c \
|
||||||
|
parsing/arguments.c
|
||||||
|
|
||||||
|
# Objects
|
||||||
|
OBJDIRNAME = ./objects
|
||||||
|
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o))
|
||||||
|
|
||||||
|
# Colors
|
||||||
|
GREEN = \033[32m
|
||||||
|
GREY = \033[0;90m
|
||||||
|
RED = \033[0;31m
|
||||||
|
GOLD = \033[38;5;220m
|
||||||
|
END = \033[0m
|
||||||
|
|
||||||
|
# Rules
|
||||||
|
|
||||||
|
# All (make all)
|
||||||
|
all: header $(NAME) footer
|
||||||
|
|
||||||
|
# Bonus (make bonus)
|
||||||
|
bonus: header $(OBJ) $(LIB_OBJ) footer
|
||||||
|
@mkdir -p $(OBJDIRNAME)
|
||||||
|
@mkdir -p $(OBJDIRNAME)/$(SRCDIRNAME)
|
||||||
|
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
|
||||||
|
@printf '$(GREY) Be Carefull ur in $(END)$(GREEN)Debug Mode$(END)\n'
|
||||||
|
@cc $(CFLAGS) -D BONUS=1 -o $(NAME) $(OBJ) $(LIB_OBJ)
|
||||||
|
|
||||||
|
# Clean (make clean)
|
||||||
|
clean:
|
||||||
|
@printf '$(GREY) Removing $(END)$(RED)Objects$(END)\n'
|
||||||
|
@printf '$(GREY) Removing $(END)$(RED)Objects Folder$(END)\n'
|
||||||
|
@$(RM) $(OBJDIRNAME)
|
||||||
|
|
||||||
|
# Clean (make fclean)
|
||||||
|
fclean: clean
|
||||||
|
@printf '$(GREY) Removing $(END)$(RED)Program$(END)\n'
|
||||||
|
@$(RM) $(NAME)
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
# Restart (make re)
|
||||||
|
re: header fclean all
|
||||||
|
|
||||||
|
# Dependences for all
|
||||||
|
$(NAME): $(OBJ)
|
||||||
|
@mkdir -p $(OBJDIRNAME)
|
||||||
|
@mkdir -p $(OBJDIRNAME)/$(SRCDIRNAME)
|
||||||
|
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
|
||||||
|
@cc $(CFLAGS) -o $(NAME) $(OBJ)
|
||||||
|
|
||||||
|
# Creating the objects
|
||||||
|
$(OBJDIRNAME)/%.o: %.c
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
@printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n'
|
||||||
|
@cc $(CFLAGS) -o $@ -c $< -I$(INCLUDES)
|
||||||
|
|
||||||
|
# Header
|
||||||
|
header:
|
||||||
|
@clear
|
||||||
|
@printf '\n\n'
|
||||||
|
@printf '$(GOLD) ******* ****** ******* $(END)\n'
|
||||||
|
@printf '$(GOLD) ****** *** ******* $(END)\n'
|
||||||
|
@printf '$(GOLD) ******* * ******* $(END)\n'
|
||||||
|
@printf '$(GOLD) ****** ******* $(END)\n'
|
||||||
|
@printf '$(GOLD) ******* ******* $(END)\n'
|
||||||
|
@printf '$(GOLD) ******************* ******* * $(END)\n'
|
||||||
|
@printf '$(GOLD) ******************* ******* *** $(END)\n'
|
||||||
|
@printf '$(GOLD) ****** ******* ****** $(END)\n'
|
||||||
|
@printf '$(GOLD) ****** $(END)\n'
|
||||||
|
@printf '$(GOLD) ****** $(END)\n'
|
||||||
|
@printf '$(GREY) Made by rparodi$(END)\n\n'
|
||||||
|
|
||||||
|
# Footer
|
||||||
|
footer:
|
||||||
|
@printf "\n"
|
||||||
|
@printf "$(GOLD) ,_ _,$(END)\n"
|
||||||
|
@printf "$(GOLD) | \\___//|$(END)\n"
|
||||||
|
@printf "$(GOLD) |=6 6=|$(END)\n"
|
||||||
|
@printf "$(GOLD) \\=._Y_.=/$(END)\n"
|
||||||
|
@printf "$(GOLD) ) \` ( ,$(END)\n"
|
||||||
|
@printf "$(GOLD) / \\ (('$(END)\n"
|
||||||
|
@printf "$(GOLD) | | ))$(END)\n"
|
||||||
|
@printf "$(GOLD) /| | | |\\_//$(END)\n"
|
||||||
|
@printf "$(GOLD) \\| |._.| |/-\`$(END)\n"
|
||||||
|
@printf "$(GOLD) '\"' '\"'$(END)\n"
|
||||||
|
@printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n'
|
||||||
|
|
||||||
|
# Phony
|
||||||
|
.PHONY: all bonus clean fclean re
|
||||||
|
|
||||||
|
-include ${OBJ:.o=.d}
|
||||||
33
includes/cub3d.h
Normal file
33
includes/cub3d.h
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* cub3d.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/10/30 16:30:26 by rparodi #+# #+# */
|
||||||
|
/* Updated: 2024/10/30 17:01:03 by rparodi ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef CUB3D_H
|
||||||
|
# define CUB3D_H
|
||||||
|
|
||||||
|
# include <stdio.h>
|
||||||
|
# include <math.h>
|
||||||
|
# include <fcntl.h>
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include <sys/time.h>
|
||||||
|
# include <unistd.h>
|
||||||
|
# include <stdbool.h>
|
||||||
|
|
||||||
|
# include "message_error.h"
|
||||||
|
|
||||||
|
# ifndef BONUS
|
||||||
|
# define BONUS 0
|
||||||
|
# endif
|
||||||
|
|
||||||
|
bool ft_parse_args(int argc, char *argv[]);
|
||||||
|
int main(int argc, char *argv[]);
|
||||||
|
|
||||||
|
#endif
|
||||||
18
includes/message_error.h
Normal file
18
includes/message_error.h
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* message_error.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/10/30 16:43:20 by rparodi #+# #+# */
|
||||||
|
/* Updated: 2024/10/30 16:46:28 by rparodi ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef MESSAGE_ERROR_H
|
||||||
|
# define MESSAGE_ERROR_H
|
||||||
|
|
||||||
|
# define ERR_ARGS_COUNT "Error:\nYou have to give only the map on arguments !"
|
||||||
|
|
||||||
|
#endif
|
||||||
32
parsing/arguments.c
Normal file
32
parsing/arguments.c
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* arguments.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/10/30 16:41:32 by rparodi #+# #+# */
|
||||||
|
/* Updated: 2024/10/30 17:26:17 by rparodi ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "cub3d.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief checking if the args given to the executable is valid
|
||||||
|
*
|
||||||
|
* @param argc the arguments count
|
||||||
|
* @param argv the arguments value
|
||||||
|
* @return false if an error / true if no error
|
||||||
|
*/
|
||||||
|
bool ft_parse_args(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (argc != 2)
|
||||||
|
return (write(2, ERR_ARGS_COUNT, strlen(ERR_ARGS_COUNT)), false);
|
||||||
|
if (strlen(argv[1]) < 4 || \
|
||||||
|
strcmp((argv[1] + (strlen(argv[1]) - 4)), ".cub") != 0)
|
||||||
|
return (write(2, "PB\n", 3), false);
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
20
sources/main.c
Normal file
20
sources/main.c
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* main.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/10/30 16:30:03 by rparodi #+# #+# */
|
||||||
|
/* Updated: 2024/10/30 17:00:20 by rparodi ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "cub3d.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (!ft_parse_args(argc, argv))
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue