486 lines of C++: old-school FPS in a weekend
Branch: master
Clone or download
Latest commit d0d86bd Feb 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc readthis arrow :) Feb 11, 2019
.gitignore save the framebuffer to a file Feb 10, 2019
.gitpod.yml Added libsdl2-dev to dockerfile Feb 11, 2019
CMakeLists.txt SDL window Feb 10, 2019
Dockerfile Added libsdl2-dev to dockerfile Feb 11, 2019
FindSDL2.cmake SDL window Feb 10, 2019
LICENSE.txt text update Feb 10, 2019
README.md Update README.md Feb 16, 2019
build.sh Buildscripts - Because we like fast interations while also over-engin… Feb 11, 2019
framebuffer.cpp sprite positioning bugfix + a bit of cleaning Feb 10, 2019
framebuffer.h Make it compile on gcc 6.3.0 (size_t error) Feb 16, 2019
gui.cpp Fixing building on macOS. Backward compatible with Linux Feb 11, 2019
map.cpp std::chrono for FPS control; smooth sliding along the walls Feb 10, 2019
map.h a bit of refactoring Feb 10, 2019
monsters.bmp Few bugfixes (e.g. FPS control); SDL knows to load .bmp files, so I r… Feb 10, 2019
monsters.png monsters shown on the map Feb 10, 2019
player.h crude SDL event handling; walking in the game shows plenty of bugs :) Feb 10, 2019
sprite.cpp sprite positioning bugfix + a bit of cleaning Feb 10, 2019
sprite.h correct sprite ordering Feb 10, 2019
textures.cpp Few bugfixes (e.g. FPS control); SDL knows to load .bmp files, so I r… Feb 10, 2019
textures.h Few bugfixes (e.g. FPS control); SDL knows to load .bmp files, so I r… Feb 10, 2019
tinyraycaster.cpp std::chrono for FPS control; smooth sliding along the walls Feb 10, 2019
tinyraycaster.h sprite positioning bugfix + a bit of cleaning Feb 10, 2019
utils.cpp Add extra argument. Feb 13, 2019
utils.h refactoring time! Feb 10, 2019
walltext.bmp Few bugfixes (e.g. FPS control); SDL knows to load .bmp files, so I r… Feb 10, 2019
walltext.png load textures Feb 10, 2019

README.md

Project based learning: build your own 3D shooter in a weekend

Check the wiki for the detailed description of what is under the hood. Screw the source code, read the wiki.

If you are interested by this project, you might want to check my other tiny* repositories, they were fun for me to make, I hope it will be fun for you to read.


This video shows what lies in this repository: TinyRayCaster

At the time I write this text, the repository contains mere 486 lines of code:

haqreu@daffodil:~/tinyraycaster$ cat *.cpp *.h | wc -l
486

Few things tinyraycaster is NOT:

  • it is NOT a game, it is a mere stub;
  • it is NOT even a 3d engine;
  • it is NOT a place for design patterns lectures;
  • it is NOT a competitor for id Software products. People, please, I am not John Carmack and neither my students are. Focus on the word "initiation".

Few things tinyraycaster IS:

  • it IS fun;
  • it IS a blank you can start from;
  • it IS created in one day, check the commit history. I broke my leg, so I wrote some code instead of walking!
  • it IS a project you can participate to, pull requests are welcome, and anyone can edit the wiki;
  • it IS full of bugs. Bugreports are welcome!

As an example, here are the sources for the game made by my students Salih Nascimento and Stephane Hulot, also check the following youtube video for a preview:

Thanksgiving party

Compilation

sudo apt install -y libsdl2-dev git
git clone https://github.com/ssloy/tinyraycaster.git
cd tinyraycaster
mkdir build
cd build
cmake ..
make

You can open the project in Gitpod, a free online dev environment for GitHub:

Open in Gitpod

On open, the editor will compile & run the program as well as open the resulting image in the editor's preview. Just change the code in the editor and rerun the script (use the terminal's history) to see updated images. Note how awesome Gitpod is, it allows to run SDL2 games directly in the browser!