Skip to content

Latest commit

 

History

History
94 lines (85 loc) · 3.84 KB

README.md

File metadata and controls

94 lines (85 loc) · 3.84 KB

Cub3d

A Raycaster programmed in C by pdruart and rdrazsky for the Cub3d subject of Codam as part of the 42 network.

Made using MLX42, commit 13a181d73868fbd1ef8aee0b85c3bc0003ee4c40 with a couple changes, and thus requires GLFW to be installed.

Compiling

On Mac and Linux run make within the project directory to compile the mandatory part. And run make bonus to compile the bonus part.

Running

Syntax: <executeable> <path_to_scene_file> where the executable name generated for the mandatory is cub3d and the bonus executable name is cub3d_bonus.

Features

Mandatory

  • Different wall textures depending on the side of a wall hit by a ray
  • Floor and ceiling colors
  • and for looking left and right
  • W A S D movement
  • ESC to close the program

Bonus

  • Wall collisions
  • Minimap
  • Doors that can be opened and closed with E if the player isn't standing in an open door
  • Animated sprite
  • Rotate with mouse

Extra (things we added that weren't asked for in either mandatory or bonus)

  • Mirrors reflecting walls
  • Looking up/down with mouse
  • Floor and ceiling textures instead of solid color
  • Animated door texture
  • Holding SHIFT for faster movement

File Format

Every valid scene file has .cub as its extension. A scene consists of 2 parts; Definitions and a Map, in that order.

Definitions have an identifier followed by at least 1 space and then their definition followed by a newline. Definitions can be spaced out with empty lines between them and be in any order so long as they are defined only once.

A Map is a tiled grid using characters that's always enclosed such that only walls are touching spaces/the outside. A map always has exactly 1 player spawn position.

<file> : path to texture (.png or .xpm42 (XPM42)) relative to the executeable.

<color> : RGB color described as R,G,B.

Mandatory

Identifiers

Syntax Description
NO <file> the wall's north face
SO <file> the wall's south face
EA <file> the wall's east face
WE <file> the wall's west face
C <color> color of the ceiling
F <color> color of the floor

Map Tiles

Syntax Description
1 wall
0 walkable space
N player spawn position facing north
S player spawn position facing south
E player spawn position facing east
W player spawn position facing west

Bonus

Identifiers

Syntax Description
NO <file> the wall's north face
SO <file> the wall's south face
WE <file> the wall's west face
EA <file> the wall's east face
D0 <file> the door's first frame
D1 <file> the door's second frame
D2 <file> the door's third frame
S0 <file> the sprite's first frame
S1 <file> the sprite's second frame
S2 <file> the sprite's third frame
CI <file> the ceiling's repeating texture
FI <file> the floor's repeating texture

Map Tiles

Syntax Description
1 wall
0 walkable space
N player spawn position facing north
S player spawn position facing south
E player spawn position facing east
W player spawn position facing west
C sprite
D door
M mirror