Coder Social home page Coder Social logo

kuninoto / 42_cub3d Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 83.37 MB

A simple 3D 'game' using MinilLibX (mlx), the graphic library of the 42School and the raycasting algorithm

Makefile 1.70% C 71.36% Roff 16.16% Perl 0.24% Shell 0.63% Objective-C 9.91%
42 42born2code 42cursus 42ecole 42projects 42school ecole42 school42 1337school 21school

42_cub3d's Introduction

cub3D (42Porto - 42Cursus) C Logo 

Project done in collaboration with Rodrigo Ramos

Grade: 115/100

Demonstration:

Installing and running cub3D:

1- Installing dependencies

sudo apt-get install make xorg libxext-dev zlib1g-dev libbsd-dev

2- Clone this repository:

git clone https://github.com/Kuninoto/42_cub3D

3- Navigate to lvl_4_cub3D and run make

cd 42_cub3D/lvl_4_cub3D && make

4- make clean so that you don't keep those object files that you won't need anymore

make clean

5- Run cub3D with your desired map

./cub3D scenes/<map_of_your_choice>.cub

Controls:

ESC - Quit cub3D
WASD / Arrows - Player movement
Mouse - Change Player's POV 

Creating new scenes:

Scene elements:
	'NO' - North texture file path;
	'SO' - South texture file path;
	'EA' - East texture file path;
	'WE' - West texture file path;

	'F' - Floor color in RGB;
	'C' - Ceiling color in RGB;
Map:
	'0' - Free space;  
	'1' - Wall;  
	'N', 'S', 'E', 'W' - Player's starting position
	(and which coordinate he will be facing at spawn);  

To be valid, a scene must respect the following:
	- Be in .cub file extension;
	- All textures must be 64x64 and in .xpm file extension;  
The map must:
	- Be composed only by valid characters;  
	- Be closed by walls;  
	- Contain only one Player;  
(You can check examples of valid scenes on 42_cub3D/lvl_4_cub3D/scenes);

Makefile Available Targets:

make or make all - compiles cub3D
make clean - wipes all object files
make fclean - deletes cub3D and all object files
make re - fclean + all

NOTE:

This project was developed for Linux. Although we've added conditional compilation and mlx for macOS (which do not have some functions that Linux has), it was for development and test purposes.

NOTE for 42 students:

mlx_mouse_hide() has memory leaks product of the mlx library, you can't in any way solve them.
So that's why running this cub3D on a sucessful run with valgrind outputs exactly 28,772 still reachable bytes in 293 blocks. If you wish to check valgrind without the boycotted memory leakage comment mlx_mouse_hide() on line 26 of main.c

Useful links

What is Raycasting?
Raycasting implementation
Mlx documentation

Disclaimer

At 42School, almost every project must be written in accordance to the Norm, the schools' coding standard. As a result, the implementation of certain parts may appear strange and for sure had room for improvement.


Made by Nuno Carvalho (Kuninoto) | [email protected]

42_cub3d's People

Contributors

kuninoto avatar ramos21rodrigo avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.