Live data from Hacker News

Annotated code: Circles bouncing off lines

annotated-code.maryrosecook.com

31–40 of 70 posts

Re: Annotated code: Circles bouncing off lines

#32

I think this is awesome but I think it's a little too spaced out. I like the side-by-side display (gives the code an approachable narrative) but I wish I had to scroll up and down (to remind myself of what's going on) less.

On mobile it combines the sides together in a way that I find an appealing option. Screenshot: http://imgur.com/xRvDubc Anybody know if there's an easy way to get something like the mobile view on desktop (without spoofing user agents, etc)?

The view will switch to this layout if you make the display window narrow enough (320px)

doco.css:202

> /* ---------------------- Low resolutions (> 320px) --------------------- */

> @media only screen and (min-width: 320px) {

Re: Annotated code: Circles bouncing off lines

#33
post #21

I hate this left/right code documentation fad with passion. Making my eyes jump horizontally across the page every few lines is about the worst you can possibly do for readability. Just keep the damn comments inline and use colors/font-faces/fold markers to make it readable.

Do you also prefer footnotes and sidebars inline when reading articles? These are standard typographical practices. I do set my comment color to super light so comments don't distract me too much when reading code, but I wish there was a better way.

Not the parent, but I prefer footnotes/sidenotes when reading physical texts, but prefer inline commentary when reading on the computer screen. Jumping up and down to read a footnote (either manually scrolling or with a hyperlink) or having the sidenotes take up a large percentage of the screen is disorienting for me.

It helps if the inline commentary is differently colored or in a separate box.

I also use light colors for comments when reading source code, but I personally prefer this over having them as footnotes or sidenotes.

Re: Annotated code: Circles bouncing off lines

#34

Earlier quoted context omitted.

Inline comments are a part of the code's core layout, so you get into trouble when you make them disappear (as is the trouble with most folding systems). It is like parenthetical statements in prose: you can't really make them disappear, they are right their in your face. It is considered bad style if they aren't extremely brief, otherwise you should use a foot or side note.

Why are people trying to make comments disappear? They are there for a reason. I agree with what moe is saying, though not moe's tone.

Comments get in the way of the flow in reading code; they are often of little value that easily goes negative when they distract.

Re: Annotated code: Circles bouncing off lines

#35

That's pretty educational. OT: I'm not a game developer. What are the other patterns - besides the global state and mutation functions - that one can use for a game loop?

I don't have a specific answer for your question, but I know this site was written specifically for game programming patterns: http://gameprogrammingpatterns.com/contents.html

Re: Annotated code: Circles bouncing off lines

#36

Earlier quoted context omitted.

Why are people trying to make comments disappear? They are there for a reason. I agree with what moe is saying, though not moe's tone.

Comments get in the way of the flow in reading code; they are often of little value that easily goes negative when they distract.

[deleted]

Re: Annotated code: Circles bouncing off lines

#37
Nice code. Thank you. Are those ball-to-line collisions energy preserving? I believe they are... However it seems there might be an edge case, where moving a colliding circle until it no longer intersects the line, might cause it to skip past another line. Because of this, the lines should not intersect each other. Sorry to ramble but I love this sort of stuff. Collision detection is covered well in many game development texts.

Re: Annotated code: Circles bouncing off lines

#40

Just have to say, it gets more amusing with more balls and lines: https://zifnab.net/circles-bouncing-off-lines/

would be interesting to plot the probability of a ball going to the right direction against the number of lines, when lines are moving clockwise or vice-versa.
Post reply on HN