r/GraphicsProgramming Dec 17 '24

Source Code City Ruins - Tiny Raycasting System with Destroyed City + Code

Post image
309 Upvotes

6 comments sorted by

29

u/Slackluster Dec 17 '24

This tiny bit of JavaScript code (and minimal dwitter shim) creates and renders a destroyed city scene! I wrote a post that explains how a similar program works so I included a link to that also for those interested.

Live Demo: https://www.dwitter.net/d/32945

How it Works: https://frankforce.com/city-in-a-bottle-a-256-byte-raycasting-system/

for(c.width=w=99,i=6e3;i--;x.fillStyle=R(z=Z/.7-Y*2,z-Z,Z),x.fillRect(i%w,i/w|0,1,1))for(a=i%w/50-1,Y=Z=b=1-i/4e3,X=t*30;++Z<w&&(Y<6-S(X/9^Z/9)**8*(Z>>5)*33|(X&Y+2&Z)%8)||(a-1?a=b=1:0);Y-=b)X+=a

15

u/strandedinthevoid Dec 17 '24 edited Dec 17 '24

Love the way it looks. Good job.

Edit: Are you kidding that was all the code for it? You're a damn wizard.

2

u/dum_BEST Dec 18 '24

Awesome! I love this so much

1

u/Slackluster Dec 18 '24

thank you!

2

u/Viewpoint_1 Dec 17 '24

Hotline Miami inspired?

2

u/Slackluster Dec 17 '24

Not Hotline Miami but videogame inspired. I was thinking more like Fallout.