A Rust based Raycaster engine

This is a full featured raycaster engine to produce game graphics similar to Wolfenstein 3D. I need it to create 3D dungeons for my retro RPG creator Eldiron.

The caster renders into a Vec<u8> frame. Next to rayon, which is needed for multithreading, the only other dependency of the crate right now is rustc-hash for a fast HashMap.

For single threaded rendering enable the "single_threaded" feature (for example for WASM targets). Multi threaded rendering is about 2 times faster than single threaded rendering on my machine.

A demo application using pixels is available in the demo directory.

Features

Todo

Usage

Create a world map:

```rust use raycaster::prelude::*;

let mut world = WorldMap::new();

// Add an image containing the tilemap to the world let imageid = world.addimage(tilemap, tilemapwidth, tilemapheight);

// Create a textured tile and use it for the ceiling default // The rectangle defines the tile in the tilemap let ceilingtile = Tile::textured(imageid, (0, 0, 24, 24)); world.setceilingtile();

// Set a colored tile for the floor world.setfloortile(Tile::colored([50, 50, 50, 255]));

// Add a wall with a tile at the given location // Add as many walls as you like world.set_wall(5, 7, tile...);

// Add a sprite at the given location. // You can manage the sprites yourself as WorldMap::sprites is public. let sprite = Sprite::new(7.0, 7.0, tile...); world.add_sprite(sprite);

// Set the fog color and the fog distance, the distance is in tiles. world.set_fog([10, 10, 10, 255], 6.0); ```

When we have set up the world we can render it:

```rust

const width: usize = 800; const height: usize = 600;

let frame = vec![0; width * height * 4];

let mut caster = Raycaster::new();

// Set the position pf the player caster.set_pos(9, 7);

// Render into the given rectangle inside the frame (here the full frame), the stride (i.e. the width of the frame) and the world. caster.render(&mut frame[..], (0, 0, width, height), width, &world); ```

Acknowledgements