/cub3D_ecole42

3D game using raycasting

Primary LanguageC

Cub3D

cub3dm

Introduction

This project is inspired by the world-famous Wolfenstein 3D game, which was the first FPS ever. It enable us to explore ray-casting. Our goal was to make a dynamic view inside a maze, in which we had to find your way.

Demonstration

Demo gameplay showing menus.

Mídia1

Demo gamplay showing weapons, crosshair, enemies and doors.

Mídia2

Skills that we have improved

  • Math applied to computer science
  • Computer graphics
  • Game events management
  • Algorithms
  • Trigonometry
  • Bitwise operation
  • Project management

How to run it ?

  • Clone the repository
git clone https://github.com/adrianofaus/cub3D_ecole42.git
  • Run make to compile common part and make bonus to bonus part
  • To clean objects files execute: make clean
  • To clean executable file and objects: make fclean
  • Recompile: make re
  • Run ./cub3D or ./cub3D_bonus followed by map path e.g. ./maps/map_0.ber

Mídia1

File configuration

To run the game, you must pass as first argument a scene description file with the .cub extension.

Identifiers

The file must have 6 element identifiers:

  • 'NO', 'SO', 'WE' and 'EA' : Represents the wall texture path on each direction.

  • 'C', 'F' : Represents the RGB color scale of the floor and celling respectively.

For example:

NO ./assets/xpm/walls/blue_wall_01.xpm
SO ./assets/xpm/walls/blue_wall_02.xpm
WE ./assets/xpm/walls/blue_wall_02.xpm
EA ./assets/xpm/walls/blue_wall_01.xpm

F 220,100,0
C 225,30,0

Map configuration

The map construction is composed by the following characters:

Common Part

Walls: '1'

Empty spaces inside: '0'

Empty spaces outside: ' '

Initial player direction: 'N', 'S', 'W' or 'E'

Bonus Part

Doors: 'D'

Enemies: 'e'

Map Rules

  • It must be completely surrounded by walls
  • It must have a player

Map example:

111111111111111111111
100001000000000000001
101000000000000000001
100S00100100100100101
100000000000000000001
100000100000000000001
111111111111111111111

How to play ?

Common part

  • The '→' and '←' keys of the keyboard allow you to look left and right in the maze.
  • The 'W', 'A', 'S', and 'D' keys allow you to move the point of view through the maze.
  • You can run holding 'Shift' key.
  • 'Esc' key exits the game.

Bonus part

  • Move the mouse to look left and right in the maze.
  • The player shoots on left mouse click or 'Ctrl' key.
  • The player opens the doors with 'E' key.
  • The 'M' key pauses the game and displays a menu.
  • Using '→', '←', '↓' and '↑' arrows allows you to navigate through the menu.
  • Press 'Enter' key to select an option in the menu.