Hacker News new | past | comments | ask | show | jobs | submit login

Someone with your level of optimism has an advantage.

The tricky thing is, this project's renderer is currently a queue of circles to draw to a canvas. It's under 100 lines of JavaScript. So any increase in complexity will require substantial changes, like abstracting over types of drawables.




There’s probably a simple but effective way to do it, like drawing the body itself as a few black circles.


Exactly. Whenever drawing a pair of red circles for tailights, draw ~10 overlapping black circles between them. Bam. Done. I don't think this requires naive optimism, just 5 minutes of additional effort. Maybe less.


Only five minutes! - Here's the source, show us. https://github.com/jes/nightdrive


I'm not the previous poster but thought this would be a fun challenge. No way it was 5 min though; took me at least 20 min to understand what to change.

Anyways, run this in your browser inspector to hot-patch the live demo so that each car has an opaque black circle as its body/chassis:

    for (let i = 0; i < cars.length; i++) { console.log(i);
        cars[i].headlights = cars[i].headlights.concat([ {xy: new V2d(0,0), z: cars[i].headlights[0].z, r:cars[i].headlights[1].xy.x, col: "black"} ]);
        cars[i].rearlights = cars[i].rearlights.concat([ {xy: new V2d(0,0), z: cars[i].rearlights[0].z, r:cars[i].rearlights[1].xy.x, col: "black"} ]);
}


Well done, nice job rising to the challenge! I definitely did not care enough to do it myself, so I applaud you. I just tried it out and it's perfect.

To be clear, since of course this is the internet and one must be precise or else get nit-picked and "outplayed," I obviously meant 5 minutes for the author who already knows the layout of the code. Obviously. Any charitable interpretation would have taken that as a given. 25-40 minutes sounds more appropriate for a newcomer examining it for the first time.


Oh yeah I totally get you, I just added the disclaimer about it taking me 20 min because I didn't want people to think I was trying to brag/flex about doing it in 5 min, which I didn't do and don't want to try to claim any credit for.


Really nice! I hadn't considered making the opaque car bodies out of circles too :).


hmm, this doesn't seem to change anything on Firefox.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: