Skip to content

cpp-niel/wsterm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raycasting in the Terminal

Just a bit of fun. Inspired by OneLoneCoder's First Person Shooter Video, I wanted to try to get rid of the "blocky" appearance that would seem to be inevitable in a console based raycaster. So this is a C++20 raycaster using ncurses which is functionally more or less the same as in OneLoneCoder's video, but with the edges smoothed a bit.

This is an example of what a scene looks like with blocky edges in a fairly high resolution terminal:

This is the same scene with the edges smoothed:

The smoothing is achieved by rendering the walls as solid blocks and using the fractional component of the wall height for a given column to choose from the fractional block characters:

  • U+2581 ▁
  • U+2582 ▂
  • U+2583 ▃
  • U+2584 ▄
  • U+2585 ▅
  • U+2586 ▆
  • U+2587 ▇
  • U+2588 █

So if the wall height is for instance 4.5, then four full block characters are drawn for the wall and additional fractional block characters are added to the top and bottom of those four blocks. In this case it would be two quarter blocks to make up the missing 0.5 units.

It's quite simple to implement and has the nice property that all the necessary information is already available and no additional rays need to be cast.

This is tested on OSX. It should run on any system that has ncurses.

About

Raycaster in the terminal

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published