A simple experiment with ray casting and C.
Play online: https://reznakt.github.io/ray-casting/
This project is a simple experiment with ray casting and C. It's not really a game, but rather a proof of concept. You can walk around and observe the environment, which consists of walls and an open sky.
I previously made something similar in Python, but it was quite slow (~100 fps), so I wanted to see how fast it could be in C (it's ~2000 fps). I also really like C and ray casting, so it's a fun project indeed.
- C99
- CMake
- SDL2
Tip
On Debian-based systems, you can install all necessary dependencies with:
sudo apt-get install -y cmake libsdl2-dev libsdl2-gfx-dev
Tip
You can also download a pre-built binary.
To get a local copy up and running, follow these simple steps:
git clone https://github.com/reznakt/ray-casting.git && cd ray-casting
cmake -B build/
cmake --build build/ -j$(nproc)
You can also run the app with Docker. Here's an example docker-compose.yml
file:
services:
ray-casting:
image: ghcr.io/reznakt/ray-casting:latest
container_name: ray-casting
tty: true
user: 1000:1000
environment:
XDG_RUNTIME_DIR: /tmp
WAYLAND_DISPLAY: $WAYLAND_DISPLAY
SDL_VIDEODRIVER: wayland,x11
DISPLAY: $DISPLAY
volumes:
- $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY
- /usr/share/wayland-sessions/:/usr/share/wayland-sessions/:ro
- /tmp/.X11-unix:/tmp/.X11-unix:ro
devices:
- /dev/dri:/dev/dri
Currently, there are no game features per se. You can walk around and observe the environment. However, you can configure various parameters by modifying the header files:
- Screen size
- Field of view
- Number of rays
- Keymappings
Normal mode |
Flat mode |
This project is licensed under the MIT license - see the LICENSE file for details.
- Lode Vandevenne for the legendary ray casting tutorial