This is a rendering engine that uses raycasting to draw pseudo 3D graphics. It outputs the result in console using default 16 colors.
The font is selected inside the terminal settings. The arguments only changed the renderer type and the font graphic ratio.
Argument | Short | Long | Options | Default option | Required | Description |
---|---|---|---|---|---|---|
Help | -h |
--help |
--- | --- | no | Prints the help message |
Resolution scaling | -s |
--resolution-scale |
NUMBER(0.25 - 2.0 ) |
1.0 | no | Sets the resolution factor of the rendered image (0.25 for quarter resolution, 1 is normal, 2 is double) |
Field of View | -f |
--fov |
NUMBER(60 - 140 ) |
130 | no | Sets the field of view of the camera |
Font graphic ratio | -p |
--font-ratio |
NUMBER(0.375 - 2.0 ) |
0.5 | no | Sets the ratio width/height of the used font to correct the stretching with certain fonts |
Renderer | -r |
--renderer |
TEXT(ascii OR shade ) |
ascii |
no | Sets the renderer (ascii for letter only rendering, shade for shading pseudo graphic character) |
Level file | -l |
--level |
TEXT() | --- | YES | Sets the played level (without .lvl.json ) |
For each column on the screen, the program shoots a ray and finds the closest wall. Knowing the distance between the wall and the virtual camera, we can calculate the visible height. For horizontal surfaces, the program projects the vector between the camera and the wall onto the surface. See references for more info.
I use built-in Windows libraries, so it is Windows only. In future, I might rewrite some parts so it runs on Linux as well. It was tested on different Windows terminal applications and I can assure full compatibility with:
- Windows Command Prompt
- Windows PowerShell
- Windows Terminal
The levels are stored inside data/levels/
folder. Level files are essentially .json
files. The level file should contain the following sections:
-
This section contains the start location and rotation of the player.
-
x
coordinate of the player start (1 unit is one cell).
-
y
coordinate of the player start (1 unit is one cell).
-
angle
of the player in degrees.
-
-
This section contains the layout of the level.
-
- The look up data which describes what each number in
tileData
corresponds to. - That means that each entry should correspond to the tile name inside the
data/tiles/
folder. This also means that each index inside thetileData
should have a corresponding entry intileLookUp
. - It is devided in 3 arrays for wall, floor, and ceiling tiles.
- The first entry in each section is a special tile. In the
wall
, it is an empty tile which will not be rendered. In thefloor
, it is the "pit" texture, that will be drawn over void floor tiles of index 0. For theceiling
, it is the sky texture that will be displayed where ceiling data contains a 0.
- The look up data which describes what each number in
-
- The layout of the level. The indexes inside the array are interpreted as tiles using
tileLookUp
. - It is divided in 3 arrays for wall, floor, and ceiling tiles. They should all be rectangular arrays with the same dimensions.
- The layout of the level. The indexes inside the array are interpreted as tiles using
-
-
This section contains the lighting information.
-
- The distance where the fog will be fully "opaque".
-
- Tthe brightess of each cell from 0 to 7.
-
The tiles are stored inside data/tiles/
folder. Tile files are essentially .json
files. The tile file should contain the following sections:
-
This describes how the tile reacts to different traces (only applicable for wall tiles).
-
- Should the tile be rendered
-
- Should the physics object collide with it
-
-
This section describes the information necessary to render the tile. Tile rendering data arrays should be the squares of the same dimensions.
-
- 2D array of values corresponding to the lightness of the texels.
- It contains values from -7 to 7.
- 7 for bright and 0 for dark tixels.
- Negative vales represent fullbright texels (they will be drawn in their original brightness no matter the lighting conditions).
-
- 2D array of values corresponding to the color of the texels.
- It contains values from 0 to 7 (8 possible colors where light/dark variations are automatically selected depending on the tile brightness).
- The numbers correspond to:
-
- Creating user-friendly editing tools (level and tile editor)