Git Product home page Git Product logo

tinyraycaster's Introduction

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!

tinyraycaster's People

Contributors

maximevince avatar niko-dunixi avatar razorneko avatar ssloy avatar svenefftinge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinyraycaster's Issues

sizeof(map) issue

When I try to run this the assert on line 64 always fails
assert (sizeof(map) == map_w * map_h + 1); // +1 for the null terminated string
because they are different sizes. When I checked with a std::cout statement it returned that sizeof(map) was 165 while map_w * map_h + 1 was 257. Is this not an issue on other computers? I'm just curious to see if I'm the only one that ran into this issue.

I used CLion, C++ 17, mingw.

Build on Windows - incorrectly saved .ppm format

Hi!
First of all thank you for great tutorials on 3D graphics.

There is an issue when building project on Windows with GCC. In initial commit in file tinyraycaster.cpp in function drop_ppm_image you have:

std::ofstream ofs(filename);
ofs << "P6\n" << w << " " << h << "\n255\n";

On Windows GCC replaces \n in output file with platform specific code 0x0D0A, what is incorrect (it should be 0x0A in the file). This result in incorrect *.ppm image representation.
This happens because of opening file in "text" mode. To fix this, file should be opened in "binary" mode, for example like this:

std::ofstream ofs;
ofs.open(filename, std::ofstream::out | std::ofstream::binary);
ofs << "P6\n" << w << " " << h << "\n255\n";

Then everything works correctly. I think this patch would not affect other platforms.

Perfomance

How much faster is the way to render without graphics libraries, and with the help of standard language functions as you have in the game? Would it be better to switch to sdl?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.