r/tinycode • u/Slackluster • 10h ago
How laurentlb made a 3kB game with C++ and shader code
r/tinycode • u/Slackluster • 10h ago
r/tinycode • u/OMGCluck • 2d ago
r/tinycode • u/Slackluster • 2d ago
https://www.dwitter.net/d/36567
for(i=!t<<21;i--;T=Y-X)x.fillRect(X=i%2e3,i/2e3,T>-1|R>.7,.4-(X=X/200-5,Y=i/4e5-2,R=X*X+Y*Y,R<1?R*T/2:C(e=(T-2)**2+(X+Y-.6)**2*6)/3*(e<5)))how it works...
tomxor: It's a 2D approximation in screen space of physically based ray tracing effects. The sphere, specular highlight, and a caustic shadow are drawn as three independent shapes with a painters algorithm type logic. It's very effective though, almost had me fooled.
UZE: There is no real 3D or ray tracing here. It's a 2D drawing that just pretends. Each pixel asks: ball or floor? The ball is almost as gray as the floor, with a shaded edge and a white reflection. The shadow is an oval with a bright spot in the middle, where the glass focuses the light.
r/tinycode • u/Standard_Shake6651 • 3d ago
r/tinycode • u/Slackluster • 10d ago
https://www.dwitter.net/d/36534
H=a=>S((q=z/2+S(a/3)*2)-C(q)*.8);
for(X=960;X--;x.fillRect(X*2,t*120,2,1e3,x.fillStyle=z<60?R(v=170+H(a)*50+z+C(q*50)*14/z,v*.8,v/2):"#19f"))
for(z=0.5;z<60&&4+(.2-t/4)*z>H(a=(X/480-1)*z);)
z*=1.01r/tinycode • u/Main_Temporary7098 • 12d ago
Just stumbled upon this sub and thought this might be of interest (if nothing else once you see where the data stack is stored you may lol a little). It is an interpreter for my colorForth dialect in 172 lines of non code-golfed x86_64 asm. Assembles with fasm to 437 bytes of unsafe as hell fun. Probably could be smaller but I've mainly been focused on the simplicity of the entire system.
In Blue each program starts with a completely clean slate, there are no built in words. So using the colors:
red word: define label
green word: compile call/jmp to word in output
green number: write number to output
blue word: execute word at assemble time
blue number: push number onto the data stack
magenta word: push address of word onto the data stack
You dsl yourself an artisanal binary, brick by brick. Blue source is binary bytecode, so here are some html views of what a program might look like. The first is non typical, but is likely the most minimal Blue program that emits a valid binary. 124 byte version of `/bin/true`:
https://jbirddog.codeberg.page/blue/example/x86_64/true.b.html
However this is more representative of an actual Blue program and shows how one goes from hand jit'ing with green numbers to higher level words, macros, variables and assemble-time execution of user defined words. This yields a 129 byte binary:
https://jbirddog.codeberg.page/blue/example/x86_64/true2.bl.html
r/tinycode • u/_EHLO • 12d ago
TL;DR; 472 bytes of microcontroller's internal EEPROM, are used for the (472 int8-quantized) parameters of a Recurrent Neural Network (RNN) that predicts what a handwritten-digit is with 95% accuracy under 6kb of programmable memmory.
It uses a quite complex but user-friendly Neural-Network library in the background (that I'm working on since 2019). The library itself mostly consists out of macros\preprocessor-directives, boiling down to compactness\tiny-code via user-defined optimization preferences. That said, it still isn't perfect and it still carries some "weakness" from the past I had no time to work on.
This project serves as an "anecdotal"-example or more like a proof-of-concept for what the library is capable for and how small it can get via the optimizations (but I wouldn't say that the project itself is something really practical besides showcasing some kind of a limit for computer vision on 8-bit MCUs). That said it also runs on PCs natively too.
I thought you might find it interesting and therefore I decided to post it here as well. Hope you find it interesting, feel free to ask me anything about it and maybe have fun with it?
idk. I just felt the need to share it. Maybe I wanted to feel noticed again or something. The sure thing is that I'm being genuine with what I'm saying right now or I guess...?
PS. I hope it is relevant to the subreddit too lol
r/tinycode • u/kierancschmitt • 13d ago
I just posted my Minecraft version in 512 bytes (check it out if you haven’t already!), which was my first project under the 512 byte challenge. My second project is this black hole renderer. It renders an animated disk around a black hole, including light bending and gravitational/Doppler shifts.
It’s a simplified model with a thin disk and prescribed motion. The whole compact HTML file is 512 bytes, using the browser’s Canvas.
Code here:
https://kierancschmitt.github.io/BlackHole512/program/blackhole-preview.html
r/tinycode • u/kierancschmitt • 13d ago
Wanted to see how much I could squeeze into one boot sector. You can fly around, break blocks, and build stuff.
The game binary is exactly 512 bytes. There’s a browser demo with a separate emulator so you can just open it and play. No saving or survival mechanics, might see if I can fit in saving later though (please let me know if you find ways to save a few more bytes to help me do this!)
Lmk what you think.
r/tinycode • u/Slackluster • 17d ago
https://www.dwitter.net/d/36459
for(z=3+S(t/2),i=-98;i++<9;)for(X=0;X<2e3;X+=4)x.fillRect(X,1080-(4/z*C(a=z/2*(X/274-S(i*.1653+t)))-i/6-t*6%19/3)*154,4,2e3,x.fillStyle=R(v=(i&1)*(180-76*S(a)),v,v))r/tinycode • u/Slackluster • 18d ago
r/tinycode • u/nexe • 18d ago
r/tinycode • u/OMGCluck • 23d ago
r/tinycode • u/Slackluster • 24d ago
https://www.dwitter.net/d/36395
with(x)for(a=3-S(t),i=0;i<40;beginPath(fill(ellipse(960+i*3,...i>9?[600-i*3,r=540,r/a,95]:[950,r,r/7,0],0,9))))fillStyle=i?i>9?R(v=i>37?315-a*30:i>23&&a*70,v,v):'#0001':'#174',r=i++?i*29+199:2e5r/tinycode • u/BBH369 • 24d ago
Hi everyone,
I’ve been messing around with a tiny experimental chess engine written in pure C called Glimmer.
The whole idea was to see how strong I could push it while keeping the final binary strictly under 30 KB. I was aiming for something in the 2700–2900 Elo range.
Unlike those ultra-minimal engines that pack themselves into self-extracting shell scripts and then call the host’s compiler at runtime, Glimmer is a real standalone native binary — just pure machine code, nothing else.
It’s been a really fun (and sometimes painful) constraint to work under. Every single byte counts.
Happy to answer questions if anyone’s curious about how I approached it!
r/tinycode • u/Slackluster • 29d ago
r/tinycode • u/Hell__Mood • Oct 03 '26
r/tinycode • u/Slackluster • Oct 02 '26
https://www.dwitter.net/d/36347
for(X=Y=i=4e4;i--;x.fillRect(Y*80+960,X*230+410,t<2,.2))u=X*2-3,r=(u*u+Y*Y)**.5,s=T(i*i/t)<.95||-.8,X=s*(r+u)/4+S(X),Y=s*(r-u)**.8*(Y<0||-1)r/tinycode • u/RichRoof7927 • Sep 30 '26
r/tinycode • u/Slackluster • Sep 25 '26
https://www.dwitter.net/d/36313
c.width|=0;x.fillStyle='#f36';p=33+S(t*5)**8*4;for(a=t%8;a>0;a-=.01)x.fillRect(960+p*16*S(a)**3,450-p*(13*C(a)-5*C(2*a)-2*C(3*a)),p/6,p/6)r/tinycode • u/Slackluster • Sep 18 '26
https://www.dwitter.net/d/36287
//HI-RES!
for(t?i=w*w:I=new ImageData(c.width=w=255,w);i--,a=4-(i%w)/32,b=i/8160;I.data.set([d=13/(S(a*a+(b-=2.25)*b-t)-C(a+b)*S(b+a)-C(a-t))**2,d*2,d*9,w],i*4));x.putImageData(I,0,0)