Live data from Hacker News

Show HN: Looptap – A minimal game to waste your time

looptap.vasanthv.com

161–170 of 183 posts

Re: Show HN: Looptap – A minimal game to waste your time

#162
post #119

Earlier quoted context omitted.

Thank you! I didn't peek and ended up with the same solution as you, so for an extra bit of fun I tried to golf it to be as short as possible. There's probably room for much improvement: (94 chars) setInterval("l=loopTapApp;b=l.getBallAngle();a=l.arc;b+6>a[0]&b-6<a[1]&&l.tap(new Event(1))")

This entire comment thread is hilarious

Strangely enough this shorter version reads and clicks better into my tiny brain

Re: Show HN: Looptap – A minimal game to waste your time

#163
post #51
post #42

One of my favorite things to do with these neat little games is to build something that plays them for me by just pasting stuff into the browser JS console. https://pastebin.com/aTYuaNVS At a score of 1,619 the ball is moving so fast it no longer works! I switched to a new tab (hoping that the event loop would be sent to the background/context switch/whatever) and ta-da - it misclicked. High score of 1,637.

You beat me to it, haha, This is what I just did: function intersectRect(rectA, rectB) { return !( rectB.left >= rectA.right || rectB.right = rectA.bottom || rectB.bottom const arc = document.getElementById("arc"); const ball = document.getElementById("ball"); setInterval(() => { if (intersectRect(arc.getBoundingClientRect(), ball.getBoundingClientRect())) { window.dispatchEvent(new KeyboardEvent('keypress', { keyCod…

What the hell is happening past the point of 2k where the ball remains in the centre? Is it all happening too fast for my tiny brain to comprehend?

Re: Show HN: Looptap – A minimal game to waste your time

#168

Earlier quoted context omitted.

Not anymore loopTapApp.score = Infinity

loopTapApp.score = Infinity^Infinity

You want loopTapApp.score = Infinity*Infinity, yours is 0 because ^ is XOR na anything XORed with itself is zero

Re: Show HN: Looptap – A minimal game to waste your time

#169
post #114

There might be a bug. I “died” but the ball appears in the live zone https://i.imgur.com/XJdKgDL.png . Happened to my partner too.

The ball resets to that 3 o'clock position when you lose, so this doesn't show where it was when you clicked.

Re: Show HN: Looptap – A minimal game to waste your time

#170
post #84

Earlier quoted context omitted.

Oh neat! You did the Harder version and didn't use the game's own code to check it. I find that with JS games it's better to imitate the game's exact logic and call it's functions to make sure the state is working/updates correctly. Of course, for how delightfully simple this one is, your approach is definitely faster/better!

Definitely seems like alfon's solution is faster/better, as it's more accurate when the game speeds up. However, it's also more resource intensive! getBoundingClientRect (used to at least, long time I go I did browser performance stuff) forces a new layout calculation each time it's called, which is one of the most expensive things you can do in the DOM, and can lead to jank in the website. Some more information here…

I believe that getBoundingClientRect does not force a layout calculation by itself, it only forces queued recalculations to happen synchronously.

So calling it 100 times in a loop should be fast, but calling it 100 times in a loot that also updates the DOM should be cripplingly slow.

Post reply on HN