TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: I made a web game called Almost Pong

1135 点作者 lessmilk大约 3 年前
Hi HN!<p>I made many small web games in the past with Unity or Phaser. But this time I wanted to make something completely on my own. So I coded a basic game framework in plain JavaScript, and used it to make Almost Pong.<p>This was a really fun project that taught me a lot about JavaScript, and I plan to make more minimalist games with this framework. Interesting fact: Almost Pong doesn&#x27;t load any assets, all sprites and sounds are generated with code.<p>Happy to answer questions, and please let me know if you have any feedback on the game. Thanks!

112 条评论

zhichu大约 3 年前
I like small games like this. We can have a simple playing while resting.
indigochill大约 3 年前
This is a wonderful little game. The concept and execution is extremely concise but the thing that really sealed the deal for me was noticing the escalating difficulty by making the paddles shrink.
评论 #30525074 未加载
maaaaattttt大约 3 年前
Let me use this thread to tell this somewhat related story of mine.<p>When I was still at university we had a C class and were doing it in a computer lab with partners (back then very few students could afford a laptop). I was always partnering up with the same friend. Since we were a bit bored with the class we started building our own pong in C. Rendering was done in ASCII in the command line, with paddles being 3 pipes, the ball a capital 0 and the walls &quot;#&quot;. We would spend some time at the beginning of the class building&#x2F;improving it and at the end playing it. We used keys like &quot;W&quot; and &quot;S&quot; for the left player and &quot;O&quot; and &quot;L&quot; for the right player. Since the initial setup with rendering and &quot;physics&quot; of the game went quite fast, we thought about how to improve it and make it more fun.<p>What made it incredibly fun (at least for us) in the end, was the addition of bonus squares. So, between the two paddles, if the ball that you just touched hit a bonus square, it would activate an effect for you or for the game depending on the bonus. We had: - &quot;wall&quot;, would create a 3 squares wall at the location of the bonus - &quot;turn of the lights&quot;, would hide everything but the ball (even the paddles) - &quot;gun&quot;, would allow you to shoot and destroy walls and bonuses - &quot;bigger&#x2F;smaller paddle&quot;, self explanatory - &quot;net&quot;, would temporarily put a net behind you preventing you from missing the ball - and some more, like speed up the ball, add an extra ball, etc.<p>It&#x27;s been my one and only experience building a game but I think it was the most fun I&#x27;ve had programming… If anybody is up for re-building a pong with bonuses I&#x27;d be definitely up for that ;)<p>Back on the topic: love the implementation OP, pretty addictive. And, as can be read above, it brought back some nice memories.
评论 #30531944 未加载
hyperpallium2大约 3 年前
&quot;flappy badminton&quot; - the shuttlecock aka a &quot;birdie&quot; is traditionally made with feathers <a href="https:&#x2F;&#x2F;wikipedia.org&#x2F;wiki&#x2F;Shuttlecock" rel="nofollow">https:&#x2F;&#x2F;wikipedia.org&#x2F;wiki&#x2F;Shuttlecock</a> )
评论 #30527346 未加载
评论 #30528926 未加载
danielandrews43大约 3 年前
You were one of my biggest inspirations for going into software engineering, I absolutely loved your website in high school and would always mess around with the source code to your games. Happy to see you’re still going!
评论 #30525165 未加载
cercatrova大约 3 年前
Remember when Flappy Bird was making $50k a day (or something like that [0]) and the creator should shut it down? Ah, memories. You could potentially recreate this to put on the mobile app stores and see how it does, I think a lot of people would play it.<p>Oh, and soon you&#x27;ll see people here on HN competing to hack the top score as with previous games [1], either though writing an AI to play the game or by modifying the JS itself on the site.<p>[0] <a href="https:&#x2F;&#x2F;www.cnet.com&#x2F;tech&#x2F;services-and-software&#x2F;no-flappy-bird-developer-didnt-give-up-on-50000-a-day&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.cnet.com&#x2F;tech&#x2F;services-and-software&#x2F;no-flappy-bi...</a><p>[1] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29921419" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29921419</a>
dang大约 3 年前
I think the second-chance pool* lobbed this one onto the front page while the OP was offline. I emailed to let him know that it&#x27;s at #1...twill be quite a thread to come back to!<p>* <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;pool" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;pool</a>, explained at <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26998308" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26998308</a>
throwaddzuzxd大约 3 年前
That&#x27;s a fun concept, but you might want to speed it up a little bit. I stopped at 20 because I got bored, it&#x27;s way too slow. The ball moves too slowly and the paddles should shrink a bit faster. The change that occurs between 1 and 20 should probably happen between 1 and 5, or 1 and 3 instead.<p>Edit: oh wait, it&#x27;s way more fun on Safari. On Firefox it feels slow and slugish, but on Safari it&#x27;s great!
评论 #30527066 未加载
评论 #30529385 未加载
评论 #30526929 未加载
schiffern大约 3 年前
If this isn&#x27;t working for you on Firefox, check that dom.webaudio.enabled isn&#x27;t set to false.<p>If Web Audio is disabled then window.AudioContext is undefined, causing a crash:<p><pre><code> Uncaught TypeError: AudioContext is not a constructor Sound https:&#x2F;&#x2F;d33wubrfki0l68.cloudfront.net&#x2F;bundles&#x2F;72f7c09a3e8485a33911cdf084acaeaf58ce17ce.js:5 startGame https:&#x2F;&#x2F;d33wubrfki0l68.cloudfront.net&#x2F;bundles&#x2F;72f7c09a3e8485a33911cdf084acaeaf58ce17ce.js:482</code></pre>
zebracanevra大约 3 年前
Impossible to play on a 280hz monitor. I see you&#x27;re using Date.now() to calculate the delta. Instead, use the first argument given to you by requestAnimationFrame for higher resolution, which is a DOMHighResTimeStamp[0]<p>[0] <a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;DOMHighResTimeStamp" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;DOMHighResT...</a>
评论 #30526108 未加载
评论 #30524647 未加载
Sydneyco大约 3 年前
This is funny. I feel this could evolve into a different game based on the number of players:<p>1 Player = Almost Pong<p>2 Players = Pong<p>3 Players = Pong + Almost Pong
评论 #30526550 未加载
andai大约 3 年前
Hey! Your 12 games in 12 weeks thing (back in ...2014? Jesus, time flies) was what got me into HTML5 game dev! So I wanted to say thank you for the inspiration :)<p>I especially appreciate the &quot;loads no assets&quot; aspect. I will take a look at the code in the morning!<p>p.s. have you considered the name &quot;Flappy Pong&quot;?
评论 #30525288 未加载
justinhj大约 3 年前
Really fun and addictive. I would extend the screen downwards so there is a clickable area that is not part of the play area. Then you will be able to see what is going on better. Just an idea.
评论 #30525078 未加载
评论 #30525094 未加载
creakingstairs大约 3 年前
This was pretty fun to play. Half way through the game I realised this was like flappy birds but within one screen. In saying that, this felt more fun to me because the space between each challenges was bigger, letting me I feel like I was more in control.
评论 #30525266 未加载
评论 #30523878 未加载
Laremere大约 3 年前
Be careful, especially if you do anything commercial with this: &quot;Pong&quot; is trademarked by Atari. Fun game, but might need to choose a different name...
评论 #30525278 未加载
评论 #30525066 未加载
评论 #30525386 未加载
评论 #30534676 未加载
Wingy大约 3 年前
I find it fun to write scripts to play games like this, here&#x27;s my solution:<p><pre><code> setInterval(() =&gt; { function jump() { function fireSpaceBarToDocumentElement(eventName) { const SPACE_BAR = 32 const ev = new KeyboardEvent(eventName, { bubbles: true, keyCode: SPACE_BAR }) document.documentElement.dispatchEvent(ev) } fireSpaceBarToDocumentElement(&#x27;keydown&#x27;) fireSpaceBarToDocumentElement(&#x27;keyup&#x27;) } function shouldJump() { function goingLeft() { return ball.speedX &lt; 0 } function goingRight() { return ball.speedX &gt; 0 } function leftPaddleAboveBall() { return ball.y &lt; paddle1.y } function rightPaddleAboveBall() { return ball.y &lt; paddle2.y } if (goingLeft() &amp;&amp; leftPaddleAboveBall()) return true if (goingRight() &amp;&amp; rightPaddleAboveBall()) return true return false } if (shouldJump()) jump() }, 1)</code></pre>
mysterydip大约 3 年前
I&#x27;m working on a game right now, and one of my roadblocks is how to handle the myriad of resolutions, aspect ratios, and portrait vs landscape modes, plus the overriding some mobile browsers do for touch (scrolling the screen, etc). What has been your approach to consolidating all of those differences so a game &quot;just works&quot; on all platforms?
评论 #30528080 未加载
MrLispy大约 3 年前
My best score at Almost Pong is 49! <a href="https:&#x2F;&#x2F;www.lessmilk.com&#x2F;almost-pong&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.lessmilk.com&#x2F;almost-pong&#x2F;</a><p>Good game! I had fun playing it.
dylan604大约 3 年前
Ha! I read the instructions and did exactly what it said. Hit space once and the &quot;ball&quot; started to move on non-touch device, I was trying to figure out how to move the paddles so continuously kept watching the ball drop with 0 score. I was halfway convinced that it was a joke game (which would have been pretty clever).
评论 #30526580 未加载
noufalibrahim大约 3 年前
Very nice. Well done. I love takes like this which subvert the ideas from the old classics. Reminds of of <a href="http:&#x2F;&#x2F;hcs64.com&#x2F;efp.html" rel="nofollow">http:&#x2F;&#x2F;hcs64.com&#x2F;efp.html</a> which is Pong but from the balls point of view.
mushyhammer大约 3 年前
Missed the chance to name it Flappy Pong
评论 #30523943 未加载
scrame大约 3 年前
Good Job, I hate you for tempting me to play more.<p>I&#x27;m afraid to play more because I think a bunch of random objects will pop up and make me go crazy, and its a little too late at night for me to start doing that and get sucked into something.<p>Otherwise excellent execution, and I think you pulled off a nice, simple runner style game with a classic look and good polish!
dpix大约 3 年前
This has THE MOST satisfying sounds of any game I&#x27;ve ever played
评论 #30526422 未加载
6gvONxR4sf7o大约 3 年前
Bug report: On an iphone with text size larger than default, you can’t see the whole game area. I read with text at 115% (hit the “aA” next to the url on the mobile browser to access font size), so it took me a while to even realize there was supposed to be another paddle on the right side that was off screen.
ilkke大约 3 年前
Reminds me very much of AdamAtomic&#x27;s Flappy Jam entry [1] that was later cloned as a fairly popular mobile game called Don&#x27;t Touch The Spikes<p>[1] <a href="https:&#x2F;&#x2F;haxeflixel.com&#x2F;demos&#x2F;Flappybalt&#x2F;" rel="nofollow">https:&#x2F;&#x2F;haxeflixel.com&#x2F;demos&#x2F;Flappybalt&#x2F;</a>
Nowado大约 3 年前
You have about 48h to be the first to put it in a mobile app store if you&#x27;re into that. Cool concept!
loxias大约 3 年前
This is fantastic! I love it. &quot;I don&#x27;t even like video games&quot; :D<p>Having the experience of fail, score 1, score 1, score 14,... is really fun. I think it has just the right mix of difficulty&#x2F;friction and reward, such that it&#x27;s pretty easy to get success once you &quot;lock in&quot;.<p>I&#x27;d be curious what your creative process is, if you start with a goal idea and then code to build it, or if you go the opposite direction, starting with what can be built and seeing how to make something fun out of it. I&#x27;ve never written any games, though it&#x27;s something I think about.
userSumo大约 3 年前
Cant belive your project of making a game a week was 8 years ago. it was such a nice project! Over the years lessmilk stuck in my mind as a example of a very cool project that also made some money.
mninm大约 3 年前
Cool gameplay loop! Lots of short jumps makes it easier. Maybe change it so that every time a paddle is hit the player gets 10 points but looses a point every time they jump.
xmorse大约 3 年前
Cool game!<p>It would be even better if every time you hit the paddles the speed increases, this way it becomes more difficult with time and makes the game less boring.
评论 #30527910 未加载
skeeter2020大约 3 年前
My immediate reaction was pong + flappy bird. I think the execution, engagement and yes, frustration, matches your intended goals, so good job!
emmaLe大约 3 年前
It&#x27;s really hard to play on the phone. At first I kept tapping on the links below the game when I focused more on the game and less on my finger position. After I got used to tapping a bit higher and not letting my finger slip down I got another problem: when the paddle was really low, my thumb would block the view so I couldn&#x27;t see the paddle or the ball.
modernerd大约 3 年前
Reminds me of qomp by Stuffed Wombat (“You are the Ball. Escape.”).<p><a href="https:&#x2F;&#x2F;store.steampowered.com&#x2F;app&#x2F;1066900&#x2F;qomp&#x2F;" rel="nofollow">https:&#x2F;&#x2F;store.steampowered.com&#x2F;app&#x2F;1066900&#x2F;qomp&#x2F;</a><p><a href="https:&#x2F;&#x2F;twitter.com&#x2F;wombatstuff" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;wombatstuff</a>
kohlerm大约 3 年前
Haha nice. Hard to play on my QMK based keyboard, probably because I mapped space to be ctrl if hold and that causes some latency
jhanschoo大约 3 年前
One thing to consider to increase the difficulty is to make jumping add to the vertical velocity a la flappy bird, rather than fix it to a certain positive vertical velocity. Right now a reliable strategy is to let the ball fall to a certain angle below the paddle, then spam jump to get a fixed trajectory to the paddle.
评论 #30524699 未加载
评论 #30527208 未加载
antirez大约 3 年前
It&#x27;s incredible how in a matter of minutes the game becomes so much simpler compared to the first times.
shelbyKiraM大约 3 年前
HAHAH, Fun little thing I did with this fabulous game was... I&#x27;m running a userscript. The game isn&#x27;t VISIBLE. How far can you get, only with SOUND? <i>cough</i> I gave up pretty quick. But kinda an intriguing thought experiment!
zagrebian大约 3 年前
On mobile, it would be useful if the tap area was extended below the board by an inch or so.
winrid大约 3 年前
The highest I got was 20, having to stop as I could spend an hour on this.<p>Fun experiment for simple games like this: Play this game every day just for 5-10 rounds before bed and in the morning. You&#x27;ll get a little better every time you get sleep.
wanderer_大约 3 年前
This has a real chance to be a successful mobile game, if I were you I may start thinking about an app. Every project has to stop somewhere, though, so leaving it as a fun little game in the browser would be fine too!
评论 #30527520 未加载
Bluecobra大约 3 年前
This is a lot of fun! I can’t wait until this gets released on the Atari 2600!
TimTheTinker大约 3 年前
Wow, the parabolic motion for this is spot-on. It seems you faithfully reproduced s=(a*t^2)&#x2F;2, or got extremely close to it - very impressive :) It&#x27;s also very responsive.<p>(max score of 47 on macOS Safari)
p0la大约 3 年前
My best score at Almost Pong is 34! <a href="https:&#x2F;&#x2F;www.lessmilk.com&#x2F;almost-pong&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.lessmilk.com&#x2F;almost-pong&#x2F;</a>
__s大约 3 年前
Is the name a nod to Almost Pizza <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=KLHRjaUBb3o" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=KLHRjaUBb3o</a> ?
krossitalk大约 3 年前
Missed a golden opportunity to name it &quot;Flappy Pong&quot;.
XCSme大约 3 年前
This is a really cool idea, it has flappy bird vibes. The only complaint is that it&#x27;s a bit too easy and gets boring after a while because there&#x27;s no challenge.
johnmaguire大约 3 年前
Great game! On mobile my finger naturally drifted toward the bottom of the hit pad for visibility and I ended up clicking the link below it a couple times. Disappointing. :(
yoz-y大约 3 年前
I really like this one. My hope is that the upcoming Play date console would be full of these kinds of “I have 30 seconds and want to play a game” jewels.
ChrisArchitect大约 3 年前
Reminds me of one of the standard version Easter eggs in Android a few versions ago was a game with this exact same &#x27;press to make float&#x27; action
评论 #30524351 未加载
superasn大约 3 年前
Fun game. On the mobile it would be great if I could tap anywhere on the screen and not just the black area as my thumb obscured the paddles sometimes.
napolux大约 3 年前
And in 1 week from now AppStore will be full of clones.
minusSeven大约 3 年前
His other games didn&#x27;t load on firefox for me.
chrisvalleybay大约 3 年前
A lot of fun! What might also be fun is if you could hold space &#x2F; mouse 1 to «charge» the jump so that you jump higher if you hold.
mfkp大约 3 年前
73 on my first try :)<p><a href="https:&#x2F;&#x2F;i.imgur.com&#x2F;2M6ce5h.jpg" rel="nofollow">https:&#x2F;&#x2F;i.imgur.com&#x2F;2M6ce5h.jpg</a>
Vetch大约 3 年前
This is excellent, creative and could also serve as a much less boring than pong project for starting reinforcement learning.
评论 #30524661 未加载
radicalriddler大约 3 年前
Nice! What a fun little game. Ended up with 36, and I feel like after 30, the bars stopped getting smaller, not sure though.
nix23大约 3 年前
Thanks for looking like a dump ass to my coworkers for hammering my mechanical space-bar for 5 minutes strait......
umurgdk大约 3 年前
These games are so much fun (I&#x27;m talking about your other games too). Especially loved gravity snake and square
jacksonkmarley大约 3 年前
Cool.<p>Would be handy if the main page indicated which games were mobile capable so you didn&#x27;t have to click through to find out.
samstave大约 3 年前
Great game.<p>Now to modernize it ; NFT ball colors! and store every successful bounce in a blockchain! Grandma will get it. haha
nickkell大约 3 年前
Can anyone hear audio on mobile? I’ve tried it with both safari and chrome on iPhone and it’s completely mute
评论 #30527114 未加载
GistNoesis大约 3 年前
For more fun you should play it on the beats of &quot;another brick in the wall&quot; (with some beats skips).
bertman大约 3 年前
Fun game! Also Kudos for the &quot;Wordle&quot;-esque share function, i.e. no stupid Twitter or Facebook.
scosman大约 3 年前
* flappy pong *
dnate大约 3 年前
FYI: Your old games (Run, Pixel War etc.) seem to not work in firefox for me while they work in safari.
dietrichepp大约 3 年前
Hah! I recognize this website from the “one game a week” stuff a while back. Had some fun playing those.
tagersenim大约 3 年前
This is awesome! I did however accidentally click on the links below the game, ruining my streak
adenozine大约 3 年前
I think I&#x27;m too old to do any better, I got 29. What a neat little idea, very clever!
robbiejs大约 3 年前
Flappy Pong. Fun stuff! Well done
hyperpallium2大约 3 年前
flappy pong!<p>Great game-feel and sound.<p>Only complaint is a standard one: on mobile, your thumb obscures the play area. Maybe have a surrounding area be touch sensitive? Or say it&#x27;s part of the challenge, to switch thumbs, like you&#x27;re playing both sides...
评论 #30526773 未加载
nextaccountic大约 3 年前
Very good! The secret is to focus the eyesight on the target, not the ball
itsbits大约 3 年前
Nice..<p>minor feedback...sometimes I mistakenly tap `Follow Me on twitter` which opens up twitter app :(
smnplk大约 3 年前
First 5 attempts I couldn&#x27;t make it past 4, after that I could get to 20 :D
xwdv大约 3 年前
Next I would like to play a basketball game where I play as the basketball.
Andrew_nenakhov大约 3 年前
Pong meets Flappy bird. Nice.
srazzaque大约 3 年前
Very cool!<p>Brought back old memories of the &quot;Paddle War&quot; in Commander Keen.
Proddducts大约 3 年前
amazing Little game and other games are also next level.<p>I will feature this in upcoming issue of <a href="https:&#x2F;&#x2F;proddducts.com" rel="nofollow">https:&#x2F;&#x2F;proddducts.com</a>
hungryforcodes大约 3 年前
I have no idea why your games make me laugh so much when I play them.
umtksa大约 3 年前
I dont know why but I love one button games, really enjoyed it cheers
uranium大约 3 年前
That&#x27;s lovely, thank you. I just laughed out loud playing it.
takladev大约 3 年前
Just burnt my hour playing this. Goes on to say how awesome it is.
blable2大约 3 年前
OK, well done but boy I&#x27;m really bad at playing games. ha ha
sedivy94大约 3 年前
Gosh that was fun to play! Thank you so much for sharing.
afterburner大约 3 年前
Gravity Snake is great!
TeeWEE大约 3 年前
This is addicting! Make it a mobile app! (Should be simple with Unity) Create a launching website, add branding (keep it simple)<p>And ad a daily challenge &#x2F; and allow users to share it. 80% sure your game will grow fast in MAU
评论 #30526343 未加载
评论 #30526031 未加载
评论 #30525880 未加载
crispyalmond大约 3 年前
This is such a good take on a classic. I love it!
jgauth大约 3 年前
Nice. Simple and fun for a few minutes. I got 45
indigodaddy大约 3 年前
This is kind of brilliant<p>Great fun
Simon_O_Rourke大约 3 年前
Great thinking outside the box on a classic!
rubyron大约 3 年前
29 on fifth try, on iPhone Safari. Love it!
robbywashere_大约 3 年前
best score was 21. my strategy was to keep the &#x27;ball&#x27; as low as possible until it came time to hit the paddle.<p>Nice Work!
JMS2021大约 3 年前
Flappy Balls... Like mine in old age ...
bberenberg大约 3 年前
This is great, I love it. Max score of 20.
billyboar大约 3 年前
Cool game! Also has an addictive element.
adrianomartins大约 3 年前
Congrats for the dead simple creativity!
ccakes大约 3 年前
Awesome work! Super fun to burn 10mins on
nadermx大约 3 年前
I applaud this, simply devilishly hard.
m4rc3lv大约 3 年前
I like it. Also the sounds are neat.
评论 #30523780 未加载
rezmason大约 3 年前
It&#x27;s got a good feel to it.
bodge5000大约 3 年前
love seeing this kind of thing, a simple concept perfectly executed
farzher大约 3 年前
why does this have so many upvotes???????????????????????????
评论 #30524775 未加载
评论 #30524835 未加载
madc大约 3 年前
This is brilliant.
rotanibmocy2大约 3 年前
Fun game. Love it
tzot大约 3 年前
Flapping Pong?
cottsak大约 3 年前
this is awesome!
taurusnoises大约 3 年前
I made it to 7.
heroku大约 3 年前
Source code?
评论 #30525117 未加载
评论 #30524756 未加载
6510大约 3 年前
very nice, it needs full screen
nro337大约 3 年前
Great game!
TruthWillHurt大约 3 年前
Genius.
dekken_大约 3 年前
ctrl+f &quot;flappy pong&quot;<p>7 hits<p>yep
alana314大约 3 年前
26
评论 #30524736 未加载