{"id":20684181,"url":"https://github.com/chrispritchard/tiny-ray-caster","last_synced_at":"2025-04-22T12:40:24.176Z","repository":{"id":50971002,"uuid":"174422267","full_name":"ChrisPritchard/tiny-ray-caster","owner":"ChrisPritchard","description":"A tiny ray caster game rendered using raw SDL2, written in F#","archived":false,"fork":false,"pushed_at":"2019-06-08T05:50:17.000Z","size":11743,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T15:11:33.118Z","etag":null,"topics":["fsharp","raycasting","sdl2"],"latest_commit_sha":null,"homepage":"","language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChrisPritchard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-07T21:22:49.000Z","updated_at":"2024-12-03T10:52:23.000Z","dependencies_parsed_at":"2022-09-11T02:10:08.670Z","dependency_job_id":null,"html_url":"https://github.com/ChrisPritchard/tiny-ray-caster","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisPritchard%2Ftiny-ray-caster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisPritchard%2Ftiny-ray-caster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisPritchard%2Ftiny-ray-caster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisPritchard%2Ftiny-ray-caster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChrisPritchard","download_url":"https://codeload.github.com/ChrisPritchard/tiny-ray-caster/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250242840,"owners_count":21398207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fsharp","raycasting","sdl2"],"created_at":"2024-11-16T22:19:41.920Z","updated_at":"2025-04-22T12:40:24.152Z","avatar_url":"https://github.com/ChrisPritchard.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tiny-ray-caster\n\nA tiny ray caster game rendered using raw SDL2, written in F#:\n\n\u003cimg align=\"center\" src=\"screencast.gif\" /\u003e\n\nThis is an F# version of the excellent tutorial **[here](https://github.com/ssloy/tinyraycaster)** by [Dmitry V. Sokolov](https://github.com/ssloy).\n\nWhy? Because I wanted to have a go using raw SDL2 from F# (not even using the SDL2-CS bindings from [flibitijibibo](https://github.com/flibitijibibo/SDL2-CS)).\n\nAlso, given that Dmitry's work is just 486 lines of C++, I was interested to see how a language almost on the other end of the high/low spectrum from C++ would do :)\n\n## Running and Building\n\nThis has been coded in .NET Core 2.2, using VS Community 2017 on Windows 10. You can run it either using VS, or via `dotnet run` on the command line.\n\nI have not tested it on other platforms - the only likely point of incompatibility would be the SDL2 library: included is the SDL2.dll from 2.0.9 for 64 bit windows. \n\nAlternative versions of SDL can be acquired from **[here](https://www.libsdl.org/download-2.0.php)**\n\n## Learnings\n\nThings I learned building this include:\n\n- the netbpm format (https://en.wikipedia.org/wiki/Netpbm_format)\n  - to open/view ppm files, I had to install **[gimp](https://www.gimp.org/)** on windows.\n  - on linux/osx, it might be easier to install \u0026 use **display** in the terminal\n  - ppm is an uncompressed image format, so is not generally recommended for images (which is probably why the support is so poor, plus its almost 40 years old)\n  - Note: when I move to SDL, I removed the ppm code. Its in the history around [this commit](https://github.com/ChrisPritchard/tiny-ray-caster/blob/3edaf4ae00c5643363a00b4ed7ca1d6f5f526226/Program.fs#L76) if you want to see it.\n- basic raycasting for wolfenstein 3D-esque rendering\n  - the 'fish-eye' issue when rendering is something I learned more about (specifically how to solve it) from **[The Black Book](http://fabiensanglard.net/gebbwolf3d/)** by Fabien Sanglard. I recommend it.\n  - I didn't include the monsters from Dmitry's demo - I was more interested in ray casting and SDL interop, to be honest. Maybe something to do in future.\n  - As a performance improvement, the raycasting uses a more granular jump rate, then walks back to find the exact point once it finds a hit.\n- SDL2 Interop and Interop and general\n  - My implementation is a combination of replicating what Dmitry did, with a conversion of the interop declarations by Flibit\n  - I restricted to just what I need, so the SDL interop module is quite small. Where appropriate, I would declare flag-like constants as their raw value, generally derived by running SDL2-CS as a console app to get the value and then putting it here (e.g. SDL_PIXELFORMAT_ABGR8888 as 376840196u)\n  - Event polling was complicated, and I ended up restricting to just the event I needed. The union hack in the SDL2-CS lib I couldn't get working with F# (ironic, since F# actually has unions)\n  - Other reasons for not using SDL2-CS (i.e. other than the educational challenge) is that I only need a small subset of SDL2's signature, and SDL2-CS is not net standard (its Net Framework 4, as opposed to this project which is Net Core 2.2).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrispritchard%2Ftiny-ray-caster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrispritchard%2Ftiny-ray-caster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrispritchard%2Ftiny-ray-caster/lists"}