Working renderer and movement 5

Wan • 3 months ago on 9th Kajam entry  Ancient Digipts

My first attempt at a raycaster is made in Rust and finally getting some progress. I'm basically following the Lodev tutorial while making the code a bit more object-oriented.

The first fancy thing I've done is making the game map load from a PNG file, with each pixel matching with a tile. Even the color palette is dynamically loaded (from another PNG holding a single row of pixels), and can be easily changed. Indexes in the palette hold the semantics of each tile:

  • Index 0 is a floor
  • Index Len - 1 is the player spawn
  • Index Len - 2 is the initial tile the player is looking at
  • Other indexes are walls of various colors

Comments (5)

 • 3 months ago • 

Wow, that's a bit hardcore! What made you want to load it from a PNG? Is that easier to edit than, say, a tilemap? I guess the minimap is just that image, right? Looks very cool.

Congrats on getting the renderer up and running. Can't wait to play it :)

  • 3 months ago • 

It was mostly me making the most of the code I already have! If felt fun to reuse the PNG loader instead of using an additional lib to parse tilemaps. Yes the minimap is the map itself, it shouldn't be in the final version though :D

 • 3 months ago • 

Looks like a solid start, how do you like rust?

  • 3 months ago • 

@voxel It's pretty enjoyable as long as I clone plenty of data around to avoid what they call borrowing issues :D

Things I like most about it are the modern API (functional manipulation of collections + lambdas for instance), the npm-like package manager, the lack of null, the friendly compiler errors, the safe memory management… But yeah the latter takes quite a while to get used to ; it's not even just about syntax but really designing solutions in an appropriate way, there's quite a learning curve to that.

Still unsure whether it's worth it for people who are already used to C++, but in my case not having used C/C++ for years it feels like a good choice.

 • 3 months ago • 

Looks great! I like loading levels from png, especially when the time is short. Most frameworks can easily access the pixel values of a png, and then it is easier than parsing some tmx or json file. I am looking forward to your final result!

Login to comment